diff options
-rw-r--r-- | Scenes/Dungeon.gd | 4 | ||||
-rw-r--r-- | Scenes/PlateDamage.gd | 3 | ||||
-rw-r--r-- | Scenes/Player.gd | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/Scenes/Dungeon.gd b/Scenes/Dungeon.gd index c9df4a2..35a1714 100644 --- a/Scenes/Dungeon.gd +++ b/Scenes/Dungeon.gd @@ -79,6 +79,7 @@ func damage_player(damage): func build_floor(): player = Player.instance() + player.connect("damaged", self, "damage_player") camera.follow(player) Builder.build(player, self) @@ -152,8 +153,7 @@ func process_turn_logic(): Monster.MonsterActionType.IDLE: pass Monster.MonsterActionType.ATTACK: - player.add_action("cor_damage", [0.2]) - damage_player(1) + player.add_action("cor_damage", [0.2, 1]) Global.turns -= 1 Monster.MonsterActionType.MOVE: move_entity(monster, monster_action.dir) diff --git a/Scenes/PlateDamage.gd b/Scenes/PlateDamage.gd index a51e7c2..2a022cb 100644 --- a/Scenes/PlateDamage.gd +++ b/Scenes/PlateDamage.gd @@ -3,8 +3,7 @@ extends Plate func activate(entity : Entity, dungeon): if entity is Player: var damage = int(entity.get_top()) - entity.add_action("cor_damage", [0.2]) - dungeon.damage_player(damage) + entity.add_action("cor_damage", [0.2, damage]) Global.turns -= damage return diff --git a/Scenes/Player.gd b/Scenes/Player.gd index 7ffb1dd..11cd068 100644 --- a/Scenes/Player.gd +++ b/Scenes/Player.gd @@ -39,6 +39,8 @@ var symbols = ['1', '3', '5', '2', '4', '6'] var side = 0 var spin = 0 +signal damaged(damage) + func get_top() -> String: return symbols[side] @@ -157,4 +159,5 @@ func cor_shake(args : Array): func cor_damage(args : Array): $Damage.play() + emit_signal("damaged", args[1]) yield(cor_shake(args), "completed") |