add attacks and death

This commit is contained in:
2025-02-26 16:17:14 +09:00
parent 151a757e3e
commit 3f1f4b1811
9 changed files with 83 additions and 14 deletions
+5
View File
@@ -1,12 +1,17 @@
extends State
func enter() -> void:
super()
subject.rotation_base.global_rotation.z = PI / 2
subject.collider.disabled = true
func exit() -> void:
super()
subject.rotation_base.global_rotation.z = 0
subject.collider.disabled = false
func process_physics(_delta: float) -> State:
if not multiplayer.is_server(): return
if not subject.dead: return %Idle
return
+1
View File
@@ -6,6 +6,7 @@ func process_physics(delta: float) -> State:
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.air_deceleration)
if not subject.is_on_floor(): return
if has_node("%Dead") and subject.dead: return %Dead
if %Input.direction.length() < 0.05: return %Idle
if has_node("%Walk") and %Input.walk: return %Walk
return %Run
+3 -3
View File
@@ -3,12 +3,12 @@ extends State
func process_physics(delta: float) -> State:
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
var input_direction = %Input.direction
subject.apply_input_velocity(delta, Vector2.ZERO, 0.0, subject.acceleration)
if not subject.is_on_floor(): return %Fall
if has_node("%Lunge") and %Input.primary_interact: return %Lunge # TODO: Lunge attacks currently do nothing so Chasers can't move when they click in
var input_direction = %Input.direction
if has_node("%Dead") and subject.dead: return %Dead
if has_node("%Lunge") and %Input.primary_interact and (not has_node("%AttackCooldown") or %AttackCooldown.time_left == 0): return %Lunge
if input_direction.length() < 0.05: return
if has_node("%Walk") and %Input.walk: return %Walk
return %Run
+33 -2
View File
@@ -1,11 +1,42 @@
extends State
var hit = false
var players_in_area = {}
func enter() -> void:
super()
if has_node("%Attack"): %Attack.visible = true
if has_node("%AttackTimer"): %AttackTimer.start()
if has_node("%AttackCooldown"): %AttackCooldown.start()
hit = false
func exit() -> void:
super()
if has_node("%Attack"): %Attack.visible = false
func process_physics(delta: float) -> State:
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
var input_direction = %Input.direction if subject.is_on_floor() else Vector2.ZERO
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration if subject.is_on_floor() else subject.air_deceleration)
if players_in_area.size() > 0:
var hit_player = players_in_area[players_in_area.keys()[0]]
hit_player.dead = true
hit = true
if has_node("%AttackTimer") and %AttackTimer.time_left > 0 and not hit: return
if not subject.is_on_floor(): return %Fall
if input_direction.length() < 0.05: return %Idle
if has_node("%Walk") and %Input.walk: return %Walk
return
return %Run
func _on_attack_body_entered(body: Node3D) -> void:
if body == subject: return
if not "player" in body or not body.player: return
if body.dead: return
players_in_area[body.name] = body
func _on_attack_body_exited(body: Node3D) -> void:
players_in_area.erase(body.name)
+4 -3
View File
@@ -4,10 +4,11 @@ func process_physics(delta: float) -> State:
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
var input_direction = %Input.direction
if input_direction.length() < 0.05: return %Idle
subject.apply_input_velocity(delta, input_direction, subject.run_speed, subject.acceleration)
if has_node("%Walk") and %Input.walk: return %Walk
if not subject.is_on_floor(): return %Fall
if has_node("%Dead") and subject.dead: return %Dead
if has_node("%Lunge") and %Input.primary_interact and (not has_node("%AttackCooldown") or %AttackCooldown.time_left == 0): return %Lunge
if input_direction.length() < 0.05: return %Idle
if has_node("%Walk") and %Input.walk: return %Walk
return
+4 -3
View File
@@ -4,10 +4,11 @@ func process_physics(delta: float) -> State:
if not Main.is_server_or_predicting(subject.player_id, subject.client_prediction): return
var input_direction = %Input.direction
if input_direction.length() < 0.05: return %Idle
subject.apply_input_velocity(delta, input_direction, subject.walk_speed, subject.acceleration)
if not %Input.walk: return %Run
if not subject.is_on_floor(): return %Fall
if has_node("%Dead") and subject.dead: return %Dead
if has_node("%Lunge") and %Input.primary_interact and (not has_node("%AttackCooldown") or %AttackCooldown.time_left == 0): return %Lunge
if input_direction.length() < 0.05: return %Idle
if not %Input.walk: return %Run
return