mirror of
https://github.com/kristoferssolo/FuncIt.git
synced 2025-10-21 19:30:35 +00:00
[Minimal] Synchronization adjustments
This commit is contained in:
parent
63621fa52f
commit
c93281adc5
@ -84,6 +84,7 @@ var particleTexture = ImageTexture.new()
|
|||||||
var particleImage = Image.new()
|
var particleImage = Image.new()
|
||||||
|
|
||||||
var globalActivePhase = null
|
var globalActivePhase = null
|
||||||
|
var clientPhase = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
@ -144,7 +145,6 @@ func process_rotation():
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
globalActivePhase = Global.phase_update_global()
|
|
||||||
$"weaponHolder/Player-character-theme-gun".play(theme)
|
$"weaponHolder/Player-character-theme-gun".play(theme)
|
||||||
particleImage.load("res://source/assets/sprites/character/player/theme/" + theme + "/na/Player-character-theme-particle-"+theme+".png")
|
particleImage.load("res://source/assets/sprites/character/player/theme/" + theme + "/na/Player-character-theme-particle-"+theme+".png")
|
||||||
particleTexture.create_from_image(particleImage)
|
particleTexture.create_from_image(particleImage)
|
||||||
@ -256,8 +256,10 @@ func _physics_process(delta) -> void:
|
|||||||
rpc("shoot", trajectory, get_tree().get_network_unique_id())
|
rpc("shoot", trajectory, get_tree().get_network_unique_id())
|
||||||
is_reloading = true
|
is_reloading = true
|
||||||
reload_timer.start()
|
reload_timer.start()
|
||||||
|
globalActivePhase = Global.phase_update_global()
|
||||||
|
clientPhase = Global.get_client_phase()
|
||||||
else:
|
else:
|
||||||
|
Global.phase_update_puppet(clientPhase)
|
||||||
rotation = lerp_angle(rotation, puppet_rotation, delta * 8)
|
rotation = lerp_angle(rotation, puppet_rotation, delta * 8)
|
||||||
$"weaponHolder/Player-character-theme-gun".position = puppet_weapon_position
|
$"weaponHolder/Player-character-theme-gun".position = puppet_weapon_position
|
||||||
weaponAngle = puppet_weapon_angle
|
weaponAngle = puppet_weapon_angle
|
||||||
|
|||||||
@ -7,22 +7,22 @@ var alive_players = []
|
|||||||
var clientPhase = {
|
var clientPhase = {
|
||||||
"0": {
|
"0": {
|
||||||
"phase_name": "Movement phase",
|
"phase_name": "Movement phase",
|
||||||
"length": 10,
|
"length": 2,
|
||||||
"start_time": null
|
"start_time": null
|
||||||
},
|
},
|
||||||
"1": {
|
"1": {
|
||||||
"phase_name": "Weapon adjustment phase",
|
"phase_name": "Weapon adjustment phase",
|
||||||
"length": 20,
|
"length": 2,
|
||||||
"start_time": null
|
"start_time": null
|
||||||
},
|
},
|
||||||
"2": {
|
"2": {
|
||||||
"phase_name": "Bullet simulation phase",
|
"phase_name": "Bullet simulation phase",
|
||||||
"length": 5,
|
"length": 2,
|
||||||
"start_time": null
|
"start_time": null
|
||||||
},
|
},
|
||||||
"3": {
|
"3": {
|
||||||
"phase_name": "Idle phase",
|
"phase_name": "Idle phase",
|
||||||
"length": 5,
|
"length": 2,
|
||||||
"start_time": null
|
"start_time": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ func phase_update_global():
|
|||||||
if gameStart:
|
if gameStart:
|
||||||
if activePhase != null:
|
if activePhase != null:
|
||||||
if clientPhase[str(activePhase)]["start_time"] != null:
|
if clientPhase[str(activePhase)]["start_time"] != null:
|
||||||
if currentTime["second"] - clientPhase[str(activePhase)]["start_time"]["second"] > clientPhase[str(activePhase)]["length"]:
|
if currentTime["second"] + currentTime["minute"] * 60 - clientPhase[str(activePhase)]["start_time"]["second"] - clientPhase[str(activePhase)]["start_time"]["minute"] * 60 > clientPhase[str(activePhase)]["length"]:
|
||||||
if activePhase + 1 == clientPhase.size():
|
if activePhase + 1 == clientPhase.size():
|
||||||
clientPhase[str(activePhase)]["start_time"] = null
|
clientPhase[str(activePhase)]["start_time"] = null
|
||||||
activePhase = 0
|
activePhase = 0
|
||||||
@ -51,6 +51,13 @@ func start_game():
|
|||||||
gameStart = true
|
gameStart = true
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func get_client_phase():
|
||||||
|
return {"clientPhase": clientPhase, "activePhase": activePhase, "gameStart": gameStart, "currentTime": currentTime}
|
||||||
|
|
||||||
|
func phase_update_puppet(phase):
|
||||||
|
clientPhase = phase["clientPhase"]
|
||||||
|
activePhase = phase["activePhase"]
|
||||||
|
|
||||||
func instance_node_at_location(node: Object, parent: Object, location: Vector2) -> Object:
|
func instance_node_at_location(node: Object, parent: Object, location: Vector2) -> Object:
|
||||||
var node_instance = instance_node(node, parent)
|
var node_instance = instance_node(node, parent)
|
||||||
node_instance.global_position = location
|
node_instance.global_position = location
|
||||||
|
|||||||
@ -33,5 +33,5 @@ func _on_timer_timeout():
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
globalActivePhase = Global.phase_update_global()
|
globalActivePhase = Global.get_client_phase()
|
||||||
$timer.text = str(globalActivePhase["phase_name"])
|
$timer.text = str(globalActivePhase["clientPhase"][str(globalActivePhase["activePhase"])]["phase_name"])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user