moved properties to GameData singleton
This commit is contained in:
parent
f18dc4336e
commit
a1dbbb72a9
|
@ -1,5 +1,6 @@
|
|||
extends Node
|
||||
|
||||
|
||||
var Weapons = {
|
||||
"knife" = {
|
||||
"number": 0,
|
||||
|
@ -18,6 +19,22 @@ var Weapons = {
|
|||
}
|
||||
}
|
||||
|
||||
var properties_example = {
|
||||
HP = 100,
|
||||
AP = 100,
|
||||
HACK = 1.0,
|
||||
class_type = 0,
|
||||
is_playable = false,
|
||||
internal_id = 0,
|
||||
nickname = "Unnamed",
|
||||
ready = false,
|
||||
current_weapon = Weapons["knife"].duplicate(),
|
||||
current_weapon_number = 0,
|
||||
last_shot = 0,
|
||||
reloading = false,
|
||||
position = Vector3(0, 5, 0)
|
||||
}
|
||||
|
||||
var client_settings
|
||||
var server_settings
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extends Node
|
||||
|
||||
var player_script := load("res://scripts/Player.gd")
|
||||
var player_script = load("res://scripts/Player.gd")
|
||||
var player_model = load("res://scenes/models/player.tscn")
|
||||
var peer = ENetMultiplayerPeer.new()
|
||||
var clients:Dictionary = {}
|
||||
|
@ -26,7 +26,7 @@ func _Peer_Connected(client_id):
|
|||
var internal_id = last_client_id + 1
|
||||
last_client_id += 1
|
||||
|
||||
clients[client_id] = player_script.new().properties.duplicate()
|
||||
clients[client_id] = GameData.properties_example.duplicate()
|
||||
var client = clients[client_id]
|
||||
client["position"] = Vector3(0, 10, 0)
|
||||
client["internal_id"] = internal_id
|
||||
|
@ -234,6 +234,7 @@ func get_map(client_id):
|
|||
func choose_class(client_id, class_id):
|
||||
var client = clients[client_id]
|
||||
client["class_type"] = class_id
|
||||
#client["HP"] = GameData.settings["game"]["classes"][class_id]["HP"]
|
||||
#here are must be checks if the teams are balanced. WIP.
|
||||
if class_id > 0:
|
||||
ServerUtils.team_OS["members"].push_back(client)
|
||||
|
@ -303,7 +304,7 @@ func spawn_player():
|
|||
print(str(player_model))
|
||||
playermodel = player_model.instantiate()
|
||||
print(str(playermodel))
|
||||
var properties = player_script.new().properties.duplicate()
|
||||
var properties = GameData.properties_example.duplicate()
|
||||
|
||||
properties = player
|
||||
properties["is_playable"] = false
|
||||
|
|
|
@ -18,22 +18,7 @@ enum Class_type {
|
|||
|
||||
var Weapons = GameData.Weapons
|
||||
|
||||
var properties = {
|
||||
HP = 100,
|
||||
AP = 100,
|
||||
HACK = 1.0,
|
||||
class_type = 0,
|
||||
is_playable = false,
|
||||
internal_id = 0,
|
||||
nickname = "Unnamed",
|
||||
ready = false,
|
||||
current_weapon = null,
|
||||
current_weapon_number = 0,
|
||||
last_shot = 0,
|
||||
reloading = false,
|
||||
offline_mode = false,
|
||||
position = Vector3(0, 5, 0)
|
||||
}
|
||||
var properties
|
||||
|
||||
var speed = 12
|
||||
var walk = 12
|
||||
|
@ -61,6 +46,7 @@ var round_status = {
|
|||
@onready var camera: Camera3D = $Head/Camera
|
||||
@onready var playerCharacterBody = $"."
|
||||
@onready var collision_shapes = find_children("collision*","",false)
|
||||
|
||||
var HUD
|
||||
var healthLabel
|
||||
var armorLabel
|
||||
|
@ -77,6 +63,7 @@ var winnerLabel
|
|||
var killLogList
|
||||
|
||||
func set_properties(props):
|
||||
print("Got props from server: " + str(props))
|
||||
properties = props
|
||||
$"Head/Nickname".text = properties["nickname"]
|
||||
name = "player" + str(properties["internal_id"])
|
||||
|
@ -183,12 +170,11 @@ func try_shoot():
|
|||
return
|
||||
if Input.is_action_pressed("shoot") and current_weapon_settings["fireRate"] >= 0.5 and not Input.is_action_just_pressed("shoot"):
|
||||
return
|
||||
time_since_last_shot = (Time.get_ticks_msec() - properties["last_shot"]) / 1000.
|
||||
time_since_last_shot = (Time.get_ticks_msec() - properties["last_shot"]) / 1000.
|
||||
|
||||
if (time_since_last_shot > current_weapon_settings["fireRate"]):
|
||||
if (!properties["offline_mode"]): Networking.shot.rpc_id(1, multiplayer.get_unique_id())
|
||||
if (properties["current_weapon"]["magazine"] > 0):
|
||||
properties["current_weapon"]["magazine"] -= 1
|
||||
Networking.shot.rpc_id(1, multiplayer.get_unique_id())
|
||||
properties["current_weapon"]["magazine"] -= 1
|
||||
properties["last_shot"] = Time.get_ticks_msec()
|
||||
|
||||
func reload():
|
||||
|
|
|
@ -12,10 +12,8 @@ func _ready():
|
|||
func _unhandled_input(event):
|
||||
if Input.is_action_pressed("MWU"):
|
||||
walk += walk / 5.
|
||||
print("UP " + str(walk))
|
||||
if Input.is_action_pressed("MWD"):
|
||||
walk -= walk / 5.
|
||||
print("DOWN " + str(walk))
|
||||
walk = clamp(walk, 0.01, 15)
|
||||
if event is InputEventMouseMotion:
|
||||
head.rotate_y(-event.relative.x * SENSETIVITY)
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
"gamemode": "TDM"
|
||||
},
|
||||
"game": {
|
||||
"classes":{
|
||||
"class_1":{
|
||||
"HP": 1100000,
|
||||
"AP": 10000,
|
||||
"damage_mul": 0.0001
|
||||
}
|
||||
},
|
||||
"gamemodes":{
|
||||
"TDM": {
|
||||
"duration": 15,
|
||||
|
|
Loading…
Reference in New Issue