From 0f2ab4af47dc53977bd6eddbfc333e5b32c14f4c Mon Sep 17 00:00:00 2001 From: Luna Brovchuk Date: Mon, 2 Oct 2023 22:56:04 +0200 Subject: [PATCH] Fix Explosion --- res/themes/default.tres | 1 - src/models/explosion/Explosion.tscn | 7 +++---- src/models/explosion/explosion.gd | 6 ++++-- src/models/player/player.gd | 1 + src/scenes/game/game.gd | 5 +++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/res/themes/default.tres b/res/themes/default.tres index 41f81a2..f806a20 100644 --- a/res/themes/default.tres +++ b/res/themes/default.tres @@ -3,7 +3,6 @@ [ext_resource path="res://res/fonts/silkscreen/Silkscreen-Regular.ttf" type="DynamicFontData" id=1] [sub_resource type="DynamicFont" id=1] -size = 8 font_data = ExtResource( 1 ) [resource] diff --git a/src/models/explosion/Explosion.tscn b/src/models/explosion/Explosion.tscn index 0763b44..1861a42 100644 --- a/src/models/explosion/Explosion.tscn +++ b/src/models/explosion/Explosion.tscn @@ -7,9 +7,8 @@ [ext_resource path="res://src/models/explosion/sprites/1.png" type="Texture" id=5] [ext_resource path="res://src/models/explosion/sprites/0.png" type="Texture" id=6] -[sub_resource type="CapsuleShape2D" id=1] -radius = 16.0 -height = 10.0 +[sub_resource type="CircleShape2D" id=3] +radius = 27.0 [sub_resource type="SpriteFrames" id=2] animations = [ { @@ -26,7 +25,7 @@ script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] rotation = 1.5708 -shape = SubResource( 1 ) +shape = SubResource( 3 ) [node name="AnimatedSprite" type="AnimatedSprite" parent="."] frames = SubResource( 2 ) diff --git a/src/models/explosion/explosion.gd b/src/models/explosion/explosion.gd index 9a5f338..de8e7b9 100644 --- a/src/models/explosion/explosion.gd +++ b/src/models/explosion/explosion.gd @@ -1,13 +1,15 @@ extends StaticBody2D var damage = 10 +var damaged = [] -func _ready(): +func _physics_process(delta): var areas = $Area2D.get_overlapping_areas() for area in areas: var parent = area.get_parent() - if parent.is_in_group("enemy"): + if parent.is_in_group("enemy") and not parent in damaged: parent.deal_damage(damage) + damaged.append(parent) func animation_finished(): call_deferred("free") diff --git a/src/models/player/player.gd b/src/models/player/player.gd index 5352b01..d2bbec4 100644 --- a/src/models/player/player.gd +++ b/src/models/player/player.gd @@ -93,6 +93,7 @@ func get_damage(): "fireball": dmg += 8 "explode": dmg += 10 "poison": dmg += 15 + return dmg func _shoot(): var ricochet_count = 0 diff --git a/src/scenes/game/game.gd b/src/scenes/game/game.gd index 7c2c744..18b3d41 100644 --- a/src/scenes/game/game.gd +++ b/src/scenes/game/game.gd @@ -75,5 +75,6 @@ func _process(delta): update_ui() func update_ui(): - $"UIWrapper/UI/Right/CastTime/CastTimeLabel".text = String(0) - $"UIWrapper/UI/Right/Damage/DamageLabel".text = String(0) + var player = $View/Player + $"UIWrapper/UI/Right/CastTime/CastTimeLabel".text = String(player.get_recharge()) + $"UIWrapper/UI/Right/Damage/DamageLabel".text = String(player.get_damage())