diff --git a/autoloads/global.gd b/autoloads/global.gd index e557051..b37dc8a 100644 --- a/autoloads/global.gd +++ b/autoloads/global.gd @@ -14,7 +14,7 @@ enum UpgradeTier { } var player: Player - +var game_paused := false # 尝试阻止敌人攻击,获取闪避, unit_stats block_chance 越大 # 成功率越高 func get_chance_success(chance: float) -> bool: diff --git a/resources/units/unit_stats.gd b/resources/units/unit_stats.gd index e8abb63..8954ada 100644 --- a/resources/units/unit_stats.gd +++ b/resources/units/unit_stats.gd @@ -9,7 +9,7 @@ enum UnitType { @export var name: String @export var type: UnitType @export var icon: Texture2D -@export var health := 1 +@export var health := 1.0 @export var health_increase_per_wave := 1.0 @export var damage := 1.0 @export var damage_increase_per_wave := 1.0 diff --git a/resources/waves/data/wave_1_to_5.tres b/resources/waves/data/wave_1_to_5.tres index 119df60..25ebb2f 100644 --- a/resources/waves/data/wave_1_to_5.tres +++ b/resources/waves/data/wave_1_to_5.tres @@ -28,7 +28,9 @@ metadata/_custom_type_script = "uid://rw3gxqh858sr" script = ExtResource("1_cx7cn") from = 1 to = 5 +wave_time = 5.0 units = Array[ExtResource("2_78wao")]([SubResource("Resource_3lh5k"), SubResource("Resource_aei4b"), SubResource("Resource_w8f67")]) +spawn_type = 0 fixed_spawn_time = 0.5 min_spawn_time = 0.5 max_spawn_time = 2.0 diff --git a/scenes/arena/arena.gd b/scenes/arena/arena.gd index 7bf0041..39401bb 100644 --- a/scenes/arena/arena.gd +++ b/scenes/arena/arena.gd @@ -8,12 +8,22 @@ class_name Arena @export var critical_color: Color @export var hp_color: Color +@onready var wave_index_label: Label = %WaveIndexLabel +@onready var wave_time_label: Label = %WaveTimeLabel +@onready var spawner: Spawner = $Spawner + # Called when the node enters the scene tree for the first time. func _ready() -> void: Global.player = player Global.on_create_block_text.connect(_on_create_block_text) Global.on_create_damage_text.connect(_on_create_damage_text) +func _process(delta: float) -> void: + if Global.game_paused: + return + wave_index_label.text = spawner.get_wave_text() + wave_time_label.text = spawner.get_wave_timer_text() + func crteat_floating_text(unit: Node2D) -> FloatingText: var instace := Global.FLOATING_TEXT_SCENE.instantiate() as FloatingText get_tree().root.add_child(instace) diff --git a/scenes/arena/arena.tscn b/scenes/arena/arena.tscn index aaade78..5e52fc1 100644 --- a/scenes/arena/arena.tscn +++ b/scenes/arena/arena.tscn @@ -5,252 +5,15 @@ [ext_resource type="Texture2D" uid="uid://ov4fmsbglo55" path="res://assets/sprites/Map.png" id="2_5tue2"] [ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="3_5tue2"] [ext_resource type="Script" uid="uid://cegcsi6n6r4gv" path="res://scenes/arena/camera_2d.gd" id="4_aj7ud"] -[ext_resource type="PackedScene" uid="uid://bot1mnbk3iu11" path="res://scenes/unit/enemy/enemy_charger.tscn" id="6_jx0ua"] -[ext_resource type="Script" uid="uid://b5j2awtdd1a4a" path="res://scenes/unit/enemy/enemy.gd" id="7_t3vx8"] -[ext_resource type="Resource" uid="uid://bnknrm368mpwb" path="res://resources/units/enemies/stats_enemy_shooter.tres" id="8_rhjlh"] -[ext_resource type="Texture2D" uid="uid://devt2xbk78rej" path="res://assets/sprites/shadow.png" id="9_tp84n"] -[ext_resource type="Texture2D" uid="uid://4mllmwdfhmce" path="res://assets/sprites/Enemies/Enemy_4.png" id="10_8kk48"] -[ext_resource type="PackedScene" uid="uid://bkyyic3okyjxx" path="res://scenes/components/hurtbox_component.tscn" id="11_wqbss"] -[ext_resource type="PackedScene" uid="uid://c0fyx8gj5uexl" path="res://scenes/components/hitbox_component.tscn" id="12_fir7s"] -[ext_resource type="PackedScene" uid="uid://2ew7i6g3p0v8" path="res://scenes/components/health_component.tscn" id="13_gy0qm"] -[ext_resource type="PackedScene" uid="uid://ifmw1e7gycc8" path="res://scenes/ui/health_bar/health_bar.tscn" id="14_dh340"] -[ext_resource type="Script" uid="uid://y47blv3332q8" path="res://scenes/unit/enemy/shooting_behavior.gd" id="15_l0cts"] -[ext_resource type="PackedScene" uid="uid://bmhud2e0x287r" path="res://scenes/projectiles/projectile_enemy.tscn" id="16_ybinm"] [ext_resource type="Script" uid="uid://bd5bscq0u8wld" path="res://scenes/arena/spawner.gd" id="17_rhjlh"] [ext_resource type="Script" uid="uid://dqhoumuppl4bx" path="res://resources/waves/wave_data.gd" id="18_8kk48"] [ext_resource type="Resource" uid="uid://cer6rdmxrnenh" path="res://resources/waves/data/wave_1_to_5.tres" id="18_tp84n"] -[sub_resource type="CircleShape2D" id="CircleShape2D_e15k4"] -radius = 4.0 +[sub_resource type="LabelSettings" id="LabelSettings_8kk48"] +font_size = 64 -[sub_resource type="Animation" id="Animation_bhlit"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Visuals/Sprite:scale") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(1, 1)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Visuals/Sprite:rotation") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [0.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Visuals/Sprite:position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, -61)] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Visuals/Shadow:scale") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0.8, 1)] -} -tracks/4/type = "value" -tracks/4/imported = false -tracks/4/enabled = true -tracks/4/path = NodePath("Visuals/Shadow:position") -tracks/4/interp = 1 -tracks/4/loop_wrap = true -tracks/4/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, 0)] -} - -[sub_resource type="Animation" id="Animation_0wuuu"] -resource_name = "move" -length = 0.5 -step = 0.05 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Visuals/Sprite:position") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(0, -61), Vector2(0, -100), Vector2(0, -61)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Visuals/Sprite:rotation") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 0.15, 0.4), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [0.0, 0.0, 1.5707963267948966] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Visuals/Sprite:scale") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 0.1, 0.15), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(0.8, 1.4), Vector2(0.9, 1)] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Visuals/Shadow:scale") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 0.1, 0.3), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 0, -"values": [Vector2(0.8, 1), Vector2(0.6, 1), Vector2(0.9, 1)] -} - -[sub_resource type="Animation" id="Animation_vgvef"] -resource_name = "die" -length = 0.8 -loop_mode = 1 -step = 0.05 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Visuals/Sprite:scale") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.20000845, 0.4000169, 0.60002536), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(1, 1), Vector2(1.2, 0.8), Vector2(1, 1), Vector2(1.2, 0.8)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Visuals/Sprite:rotation") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [0.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Visuals/Shadow:position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [Vector2(0, -4)] -} - -[sub_resource type="Animation" id="Animation_3po7s"] -resource_name = "idle" -length = 0.6 -loop_mode = 1 -step = 0.05 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Visuals/Sprite:scale") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.15, 0.3, 0.45), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(0.8, 1.1), Vector2(1, 1), Vector2(0.8, 1.1), Vector2(1, 1)] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Visuals/Sprite:rotation") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0, 0.15, 0.3, 0.45), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [0.2617993877991494, 0.0, -0.2617993877991494, 0.0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Visuals/Sprite:position") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 0.15, 0.3, 0.45), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(0, -61), Vector2(0, -75), Vector2(0, -61), Vector2(0, -75)] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Visuals/Shadow:scale") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 0.15, 0.3, 0.45), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 0, -"values": [Vector2(0.8, 1), Vector2(0.6, 1), Vector2(0.8, 1), Vector2(0.6, 1)] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_w7udy"] -_data = { -&"RESET": SubResource("Animation_bhlit"), -&"die": SubResource("Animation_0wuuu"), -&"idle": SubResource("Animation_vgvef"), -&"move": SubResource("Animation_3po7s") -} - -[sub_resource type="CircleShape2D" id="CircleShape2D_lmqbh"] -radius = 150.0 - -[sub_resource type="CircleShape2D" id="CircleShape2D_03rrj"] -radius = 38.0 - -[sub_resource type="CircleShape2D" id="CircleShape2D_421q1"] -radius = 40.0 +[sub_resource type="LabelSettings" id="LabelSettings_wqbss"] +font_size = 64 [node name="Arena" type="Node2D" unique_id=1021720471 node_paths=PackedStringArray("player")] script = ExtResource("1_asdgj") @@ -273,101 +36,43 @@ texture = ExtResource("2_5tue2") [node name="Camera2D" type="Camera2D" parent="." unique_id=758039070] script = ExtResource("4_aj7ud") -[node name="EnemyCharger" parent="." unique_id=2092979720 instance=ExtResource("6_jx0ua")] -position = Vector2(-481, 1) - -[node name="EnemyShooter" type="Area2D" parent="." unique_id=1617000445] -position = Vector2(-720, -233) -collision_layer = 2 -script = ExtResource("7_t3vx8") -stats = ExtResource("8_rhjlh") - -[node name="Visuals" type="Node2D" parent="EnemyShooter" unique_id=395976388] -unique_name_in_owner = true -scale = Vector2(0.5, 0.5) - -[node name="Shadow" type="Sprite2D" parent="EnemyShooter/Visuals" unique_id=2136480859] -modulate = Color(0.11119685, 0.11119684, 0.11119684, 1) -self_modulate = Color(0.101960786, 0.101960786, 0.101960786, 0.3372549) -scale = Vector2(0.8, 1) -texture = ExtResource("9_tp84n") - -[node name="Sprite" type="Sprite2D" parent="EnemyShooter/Visuals" unique_id=1925870318] -unique_name_in_owner = true -position = Vector2(0, -61) -texture = ExtResource("10_8kk48") - -[node name="FirePos" type="Marker2D" parent="EnemyShooter/Visuals" unique_id=815261850] -position = Vector2(-92, -50) - -[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter" unique_id=139786467] -position = Vector2(0, -30) -shape = SubResource("CircleShape2D_e15k4") -debug_color = Color(0.97292477, 0.10649621, 0.32710177, 0.41960785) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="EnemyShooter" unique_id=619019243] -libraries/ = SubResource("AnimationLibrary_w7udy") - -[node name="VisionArea" type="Area2D" parent="EnemyShooter" unique_id=466967301] -collision_layer = 0 -collision_mask = 2 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter/VisionArea" unique_id=715489053] -position = Vector2(0, -25) -shape = SubResource("CircleShape2D_lmqbh") - -[node name="HurtboxComponent" parent="EnemyShooter" unique_id=1155790880 instance=ExtResource("11_wqbss")] -collision_layer = 8 -collision_mask = 16 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter/HurtboxComponent" unique_id=880029571] -position = Vector2(0, -30) -shape = SubResource("CircleShape2D_03rrj") -debug_color = Color(0.59981126, 0.5382401, 0.22537157, 0.41960785) - -[node name="HitboxComponent" parent="EnemyShooter" unique_id=151235566 instance=ExtResource("12_fir7s")] -collision_layer = 4 -collision_mask = 32 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter/HitboxComponent" unique_id=906401181] -position = Vector2(0, -30) -shape = SubResource("CircleShape2D_421q1") -debug_color = Color(0.95670325, 0.056883797, 0.5071302, 0.41960785) - -[node name="HealthComponent" parent="EnemyShooter" unique_id=455886217 instance=ExtResource("13_gy0qm")] - -[node name="HealthBar" parent="EnemyShooter" unique_id=1540037291 instance=ExtResource("14_dh340")] -offset_left = -46.0 -offset_top = -95.0 -offset_right = 50.0 -offset_bottom = -75.0 -back_color = Color(0.015686275, 0.05490196, 0.16862746, 1) -fill_color = Color(0.37254903, 0.5372549, 0.75686276, 1) - -[node name="FlashTimer" type="Timer" parent="EnemyShooter" unique_id=2034069027] -wait_time = 0.2 -one_shot = true - -[node name="KnockbackTimer" type="Timer" parent="EnemyShooter" unique_id=1031574323] -wait_time = 0.4 -one_shot = true - -[node name="ShootingBehavior" type="Node2D" parent="EnemyShooter" unique_id=1533506602 node_paths=PackedStringArray("enemy", "fire_pos")] -script = ExtResource("15_l0cts") -enemy = NodePath("..") -fire_pos = NodePath("../Visuals/FirePos") -projectile_scene = ExtResource("16_ybinm") - [node name="Spawner" type="Node2D" parent="." unique_id=831614176] script = ExtResource("17_rhjlh") waves_data = Array[ExtResource("18_8kk48")]([ExtResource("18_tp84n")]) [node name="SpawnTimer" type="Timer" parent="Spawner" unique_id=1696770444] +one_shot = true [node name="WaveTimer" type="Timer" parent="Spawner" unique_id=2083072683] +one_shot = true + +[node name="GameUI" type="CanvasLayer" parent="." unique_id=1475247101] + +[node name="WaveIndexLabel" type="Label" parent="GameUI" unique_id=1301397499] +unique_name_in_owner = true +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -110.0 +offset_top = 20.0 +offset_right = 110.0 +offset_bottom = 97.333336 +grow_horizontal = 2 +text = "Wave 1" +label_settings = SubResource("LabelSettings_8kk48") + +[node name="WaveTimeLabel" type="Label" parent="GameUI" unique_id=1566213532] +unique_name_in_owner = true +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -34.0 +offset_top = 100.0 +offset_right = 34.0 +offset_bottom = 177.33334 +grow_horizontal = 2 +text = "10" +label_settings = SubResource("LabelSettings_wqbss") -[connection signal="on_damaged" from="EnemyShooter/HurtboxComponent" to="EnemyShooter" method="_on_hurtbox_component_on_damaged"] -[connection signal="on_health_changed" from="EnemyShooter/HealthComponent" to="EnemyShooter/HealthBar" method="_on_health_component_on_health_changed"] -[connection signal="timeout" from="EnemyShooter/FlashTimer" to="EnemyShooter" method="_on_flash_timer_timeout"] -[connection signal="timeout" from="EnemyShooter/KnockbackTimer" to="EnemyShooter" method="_on_knockback_timer_timeout"] [connection signal="timeout" from="Spawner/SpawnTimer" to="Spawner" method="_on_spawn_timer_timeout"] +[connection signal="timeout" from="Spawner/WaveTimer" to="Spawner" method="_on_wave_timer_timeout"] diff --git a/scenes/arena/spawner.gd b/scenes/arena/spawner.gd index 5ff8c52..f06597b 100644 --- a/scenes/arena/spawner.gd +++ b/scenes/arena/spawner.gd @@ -10,7 +10,7 @@ class_name Spawner var wave_index := 1 var current_wave_data: WaveData -var spawned_enemiese: Array[Enemy] = [] +var spawned_enemies: Array[Enemy] = [] # Called when the node enters the scene tree for the first time. @@ -27,7 +27,7 @@ func find_wave_data() -> WaveData: func start_wave() -> void: current_wave_data = find_wave_data() - if not current_wave_data : + if not current_wave_data: printerr("No valid wave.") spawn_timer.stop() wave_timer.stop() @@ -50,16 +50,58 @@ func set_spawn_timer() -> void: if spawn_timer.is_stopped(): spawn_timer.start() +func get_random_spawn_position() -> Vector2: + var random_x := randf_range(-spawn_area_size.x, spawn_area_size.x) + var random_y := randf_range(-spawn_area_size.y, spawn_area_size.y) + return Vector2(random_x, random_y) + func spawn_enemy() -> void: var enemy_scene := current_wave_data.get_randon_unit_scene() as PackedScene if enemy_scene: + var spawn_pos := get_random_spawn_position() var enemy_instance := enemy_scene.instantiate() as Enemy - enemy_instance.global_position = Vector2.ZERO + enemy_instance.global_position = spawn_pos get_parent().add_child(enemy_instance) - spawned_enemiese.append(enemy_instance) + spawned_enemies.append(enemy_instance) set_spawn_timer() + +func update_enemies_new_wave() -> void: + for stat: UnitStats in enemy_collection: + stat.health += stat.health_increase_per_wave + stat.damage += stat.damage_increase_per_wave + +func clear_enemies() -> void: + if spawned_enemies.size()>0: + for enemy: Enemy in spawned_enemies: + if is_instance_valid(enemy): + enemy.destroy_enemy() + + spawned_enemies.clear() + +func get_wave_text() -> String: + return "Wave %s" % wave_index + +func get_wave_timer_text() -> String: + return str(max(0, int(wave_timer.time_left))) func _on_spawn_timer_timeout() -> void: + if not current_wave_data or wave_timer.is_stopped(): + spawn_timer.stop() + return + spawn_enemy() + + +func _on_wave_timer_timeout() -> void: + Global.game_paused = true + spawn_timer.stop() + clear_enemies() + update_enemies_new_wave() + + + + + + diff --git a/scenes/ui/stats_container/stats_container.gd b/scenes/ui/stats_container/stats_container.gd new file mode 100644 index 0000000..10cb0d9 --- /dev/null +++ b/scenes/ui/stats_container/stats_container.gd @@ -0,0 +1,19 @@ +extends Panel +class_name StatsContainer + +@onready var health_label: Label = %HealthLabel +@onready var hp_regen_label: Label = %HPRegenLabel +@onready var life_steal_label: Label = %LifeStealLabel +@onready var damage_label: Label = %DamageLabel +@onready var luck_label: Label = %LuckLabel +@onready var speed_label: Label = %SpeedLabel +@onready var harvesting_label: Label = %HarvestingLabel + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/scenes/ui/stats_container/stats_container.gd.uid b/scenes/ui/stats_container/stats_container.gd.uid new file mode 100644 index 0000000..01b023b --- /dev/null +++ b/scenes/ui/stats_container/stats_container.gd.uid @@ -0,0 +1 @@ +uid://degcm5yugr3et diff --git a/scenes/ui/stats_container/stats_container.tscn b/scenes/ui/stats_container/stats_container.tscn new file mode 100644 index 0000000..6ae975d --- /dev/null +++ b/scenes/ui/stats_container/stats_container.tscn @@ -0,0 +1,332 @@ +[gd_scene format=3 uid="uid://cp1haphh1gj8t"] + +[ext_resource type="Script" uid="uid://degcm5yugr3et" path="res://scenes/ui/stats_container/stats_container.gd" id="1_agl2i"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_agl2i"] +bg_color = Color(0.09803922, 0.09803922, 0.09803922, 1) +corner_radius_top_left = 16 +corner_radius_top_right = 16 +corner_radius_bottom_right = 16 +corner_radius_bottom_left = 16 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_q67w4"] +bg_color = Color(0.039215688, 0.7137255, 0.8784314, 0.3137255) +corner_radius_top_left = 8 +corner_radius_top_right = 8 +corner_radius_bottom_right = 8 +corner_radius_bottom_left = 8 +corner_detail = 5 + +[sub_resource type="LabelSettings" id="LabelSettings_agl2i"] +font_size = 24 + +[node name="StatsContainer" type="Panel" unique_id=827713059] +custom_minimum_size = Vector2(480, 550) +offset_right = 40.0 +offset_bottom = 40.0 +theme_override_styles/panel = SubResource("StyleBoxFlat_agl2i") +script = ExtResource("1_agl2i") + +[node name="MarginContainer" type="MarginContainer" parent="." unique_id=407365169] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 16 +theme_override_constants/margin_top = 16 +theme_override_constants/margin_right = 16 +theme_override_constants/margin_bottom = 16 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=1469773019] +layout_mode = 2 +theme_override_constants/separation = 12 + +[node name="StatsHealth" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=1095380227] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsHealth" unique_id=33041130] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "max hp:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="HealthLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsHealth" unique_id=637203362] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsHPRegen" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=749196644] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsHPRegen" unique_id=81430696] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "hp regen:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="HPRegenLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsHPRegen" unique_id=187882447] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsLifeSteal" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=1147906155] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsLifeSteal" unique_id=1864994055] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "% life steal:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="LifeStealLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsLifeSteal" unique_id=202834641] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsDamage" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=1059591467] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsDamage" unique_id=175599987] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "damage:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="DamageLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsDamage" unique_id=934876879] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsLuck" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=1150530464] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsLuck" unique_id=657472168] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "luck:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="LuckLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsLuck" unique_id=78047560] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsSpeed" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=241478994] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsSpeed" unique_id=1544472169] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "speed:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="SpeedLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsSpeed" unique_id=1954700526] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsBlock" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=1547358929] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsBlock" unique_id=117742420] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "% block chance:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="BlockLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsBlock" unique_id=2127039878] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 + +[node name="StatsHarvesting" type="Panel" parent="MarginContainer/VBoxContainer" unique_id=69183424] +custom_minimum_size = Vector2(0, 45) +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_q67w4") + +[node name="Title" type="Label" parent="MarginContainer/VBoxContainer/StatsHarvesting" unique_id=333754868] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 5.0 +offset_top = -14.5 +offset_right = 107.0 +offset_bottom = 14.5 +grow_vertical = 2 +text = "harvesting:" +label_settings = SubResource("LabelSettings_agl2i") + +[node name="HarvestingLabel" type="Label" parent="MarginContainer/VBoxContainer/StatsHarvesting" unique_id=1473863706] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -112.0 +offset_top = -14.5 +offset_right = -10.0 +offset_bottom = 14.5 +grow_horizontal = 0 +grow_vertical = 2 +text = "10" +label_settings = SubResource("LabelSettings_agl2i") +horizontal_alignment = 2 diff --git a/scenes/unit/enemy/enemy.gd b/scenes/unit/enemy/enemy.gd index 052d52d..9cfeadc 100644 --- a/scenes/unit/enemy/enemy.gd +++ b/scenes/unit/enemy/enemy.gd @@ -18,6 +18,9 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: + if Global.game_paused: + return + if not can_move: return @@ -44,8 +47,6 @@ func get_move_direction() -> Vector2: func update_rotate() -> void: - print("11111111") - if !is_instance_valid(Global.player): return @@ -73,6 +74,11 @@ func reset_knockback() -> void: knockback_dir = Vector2.ZERO knockback_power = 0 +func destroy_enemy() -> void: + can_move = false + anim_player.play("die") + await anim_player.animation_finished + queue_free() func _on_knockback_timer_timeout() -> void: reset_knockback() diff --git a/scenes/unit/enemy/shooting_behavior.gd b/scenes/unit/enemy/shooting_behavior.gd index 6b48763..323b57b 100644 --- a/scenes/unit/enemy/shooting_behavior.gd +++ b/scenes/unit/enemy/shooting_behavior.gd @@ -18,6 +18,9 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: + if Global.game_paused: + return + if enemy == null: return diff --git a/scenes/unit/players/player.gd b/scenes/unit/players/player.gd index 201aae4..57f9a3e 100644 --- a/scenes/unit/players/player.gd +++ b/scenes/unit/players/player.gd @@ -35,6 +35,9 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: + if Global.game_paused: + return + move_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down") var current_velocity := move_dir * stats.speed diff --git a/scenes/weapons/weapon.gd b/scenes/weapons/weapon.gd index 073e18c..a886a67 100644 --- a/scenes/weapons/weapon.gd +++ b/scenes/weapons/weapon.gd @@ -18,6 +18,9 @@ func _ready() -> void: atk_start_pos = sprite_2d.position func _process(delta: float) -> void: + if Global.game_paused: + return + if not is_attacking: if targets.size() > 0: update_closest_target()