Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Commit

Permalink
New scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
superRaptor911 committed Dec 12, 2020
1 parent e5c4772 commit 1de051d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 41 deletions.
52 changes: 25 additions & 27 deletions Maps/BaseLevel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ export var capture_mod = false
# author , INC = "preinstalled"
export var author = "INC"

var team1 = preload("res://Objects/scripts/Team.gd").new(0,self)
var team2 = preload("res://Objects/scripts/Team.gd").new(1,self)
var teamSelector = load("res://Objects/Game_modes/BombDiffuse/BomTeamSelect.tscn")
var spec_mode = preload("res://Objects/Game_modes/Spectate.tscn").instance()
var dropedItem_manager = preload("res://Objects/Misc/DropedItemManager.tscn").instance()

var team1 = preload("res://Objects/scripts/Team.gd").new(0,self)
var team2 = preload("res://Objects/scripts/Team.gd").new(1,self)

var teamSelector = null
var spec_mode = preload("res://Objects/Game_modes/Spectate.tscn").instance()
var dropedItem_manager = preload("res://Objects/Misc/DropedItemManager.tscn").instance()

var spawned_units = Array()
var spawn_points = Array()
var spawned_units = Array()
var spawn_points = Array()
var is_server = false

#Unit attiributes
var unit_data_dict = {
Expand All @@ -44,10 +43,6 @@ var spawned_units_ids = Array()

func _ready():
MusicMan.music_player.stop()
if capture_mod:
captureMap()
return

if not game_states.game_settings.shadows:
$BaseMap/shadow.hide()

Expand All @@ -60,20 +55,22 @@ func _ready():
game_server._unit_data_list.clear()
spawn_points = get_tree().get_nodes_in_group("SpawnPoint")
network.connect("disconnected", self, "_on_disconnected")

loadGameMode()

#handle team selector
add_child(teamSelector)
teamSelector.connect("team_selected",self,"_on_player_selected_team")
teamSelector.connect("spectate_mode",self,"_on_specmode_selected")
spec_mode.connect("leave_spec_mode",self,"_on_spec_mode_leave")

if (get_tree().is_network_server()):
is_server = get_tree().is_network_server()
if is_server:
network.connect("player_removed", self, "_on_player_removed")
genNavigation()
else:
rpc_id(1,"S_getExistingUnits", String(game_states.player_info.net_id))

# For remote server
if game_states.is_server:
add_child(load("res://Objects/scripts/serverInfoUpdater.gd").new())

Expand Down Expand Up @@ -102,22 +99,19 @@ func loadGameMode():
game_mode = load("res://Objects/Game_modes/Elimination/Elimination.tscn").instance()
elif game_server.serverInfo.game_mode == "CheckPoints":
game_mode = load("res://Objects/Game_modes/CheckPoints/CheckPoints.tscn").instance()
#elif game_server.serverInfo.game_mode == "Bombing":
#game_mode = load("res://Objects/Game_modes/BombDiffuse.tscn").instance()

#add game mode
if game_mode:
game_mode.add_to_group("GameMode")
add_child(game_mode)

#Use custom team selector, if exist
var ts = game_mode.get("Custom_teamSelector")
var ts = game_mode.get("team_selector")

if ts:
teamSelector = load(ts).instance()
Logger.Log("Using custom team selector from %s" % [ts])
print("Loading not default team selector")
#switch to default team selector
teamSelector = ts.instance()
Logger.Log("Using custom team selector from %s")
# Switch to default team selector
else:
teamSelector = load("res://Objects/Game_modes/BombDiffuse/BomTeamSelect.tscn").instance()
print("Loading default team selector")
Expand Down Expand Up @@ -200,7 +194,7 @@ remote func S_getExistingUnits(peer_id : String):

# create player , server side
remotesync func S_createPlayer(pinfo,team : int):
if get_tree().is_network_server():
if is_server:
rpc("P_createPlayer",pinfo,getSpawnPosition(team),team)
else:
print("Error : S_createPlayer called on client")
Expand Down Expand Up @@ -333,7 +327,7 @@ func spawnBot(team_id : int = 0):

# Function to remove Unit, server side
func S_removeUnit(uid : String):
if get_tree().is_network_server():
if is_server:
rpc("P_removeUnit", uid)
else:
Logger.LogError("S_removeUnit", "Not network server")
Expand Down Expand Up @@ -367,7 +361,7 @@ remotesync func P_removeUnit(uid : String):

#Kick/remove all the bots from game
func removeAllBot():
if get_tree().is_network_server():
if is_server:
#get all bots
var bots = get_tree().get_nodes_in_group("Bot")
for i in bots:
Expand All @@ -384,7 +378,7 @@ func _on_disconnected():

# restart level, server side
func S_restartLevel():
if get_tree().is_network_server():
if is_server:
rpc("P_restartLevel")
else:
print("Error : S_restartLevel called on client")
Expand All @@ -409,7 +403,7 @@ remotesync func P_restartLevel():

# Func to change player's team
remotesync func S_changeUnitTeam(unit_id : String, team_id : int, kill_unit = true):
if get_tree().is_network_server():
if is_server:
var unit = game_server._unit_data_list.get(unit_id)
if not unit:
Logger.LogError("S_changeUnitTeam", "Unit with id %s not found" % [unit_id])
Expand Down Expand Up @@ -459,6 +453,10 @@ remotesync func P_changeUnitTeam(unit_id : String, team_id : int):
unit.ref.get_node("Model").setSkin(data.ct_model)


func S_swapTeams():
if is_server:
pass



################################################################################
Expand Down
2 changes: 2 additions & 0 deletions Objects/Game_modes/CheckPoints/CheckPoints.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ var mode_settings = {

var CP_minimap = preload("res://Objects/Game_modes/CheckPoints/CPMinimap.tscn")
var end_screen = preload("res://Objects/Game_modes/Elimination/EndScreen.tscn").instance()
var scoreboard = preload("res://Objects/Ui/elimScoreboard.tscn")

var time_elasped = 0
var focused_point = null
var teams = Array()


onready var timer_label = $top_panel/Label
onready var points_node = $top_panel/points
onready var progress_bar = $top_panel/ProgressBar
Expand Down
6 changes: 2 additions & 4 deletions Objects/Game_modes/Elimination/Elimination.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var mode_settings = {
}

var scoreboard = preload("res://Objects/Ui/elimScoreboard.tscn")
var end_screen = preload("res://Objects/Game_modes/Elimination/EndScreen.tscn").instance()

var time_elasped = 0 # Elasped time
var cur_round = 1 # Current round
Expand All @@ -19,9 +20,6 @@ onready var level = get_tree().get_nodes_in_group("Level")[0]
onready var teams = get_tree().get_nodes_in_group("Team")


var end_screen = preload("res://Objects/Game_modes/Elimination/EndScreen.tscn").instance()


# Called when the node enters the scene tree for the first time.
func _ready():
game_states.safe_cpy_dict(mode_settings, game_server.game_mode_settings)
Expand Down Expand Up @@ -178,7 +176,7 @@ func unfreezeEveryone():
func swapTeam():
var units = get_tree().get_nodes_in_group("Unit")
for i in units:
level.rpc_id(1,"S_changeUnitTeam", i.name, abs(i.team.team_id - 1), false)
level.rpc_id(1,"S_changeUnitTeam", i.name, abs(i.team.team_id - 1), true)
# Swap scores
var temp = teams[0].score
teams[0].score = teams[1].score
Expand Down
3 changes: 2 additions & 1 deletion Objects/Game_modes/TDM/TDM.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#####################
extends CanvasLayer

var end_screen_scn = preload("res://Objects/Game_modes/TDM/endScreen.tscn")
var end_screen_scn = preload("res://Objects/Game_modes/TDM/endScreen.tscn")
var scoreboard = preload("res://Objects/Ui/elimScoreboard.tscn")

var mode_settings = {
time_limit = 5,
Expand Down
2 changes: 1 addition & 1 deletion Objects/Game_modes/ZombieMod/ZombieMod.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends CanvasLayer

var Custom_teamSelector = "res://Objects/Game_modes/ZombieMod/Zm_TeamSelect.tscn"
var team_selector = preload("res://Objects/Game_modes/ZombieMod/Zm_TeamSelect.tscn")

var current_round = 0
var z_count = 0
Expand Down
2 changes: 1 addition & 1 deletion Objects/Global/game_states.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extends Node
#contains key resouces

#is exporting for android or not
var is_android = false
var is_android = true
var is_server = false
var is_sysAdmin = false

Expand Down
7 changes: 2 additions & 5 deletions Objects/scripts/Team.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@ func removePlayer(plr):
player_count -= 1

if player_count == 0 and plr.alive:
alive_players = 1
emit_signal("team_eliminated",self)

if plr.is_in_group("User"):
user_count -= 1
user_count -= 1

if plr.alive:
alive_players -= 1
# Error chk
if player_count < 0:
print("Error : Negative number of players")



func _on_player_killed():
Expand Down
4 changes: 2 additions & 2 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ custom_template/release=""
custom_template/use_custom_build=true
plugins/GodotAdMob=true
command_line/extra_args=""
version/code=51
version/name="1.51_armv7"
version/code=53
version/name="1.52_beta_armv7"
package/unique_name="com.raptor.inc"
package/name="warzone2"
package/signed=true
Expand Down

0 comments on commit 1de051d

Please sign in to comment.