Compare commits

..

1 commit

Author SHA1 Message Date
Varylios
d0d9157aa2 feat: improve tower manager 2025-08-29 13:51:07 +02:00
10 changed files with 28 additions and 129 deletions

View file

@ -59,6 +59,10 @@ signal money_spent(_value : int)
#Subscriber : cube.gd
signal player_has_won()
#Emitter : spawner.gd
#Subscriber : cube.gd
signal player_defeated()
#Emitter : PlayerManager.gd
#Subscriber : game_menu.gd
signal open_shop()

View file

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="Level" load_steps=19 format=3 uid="uid://ob41fnhkjr3o"]
[gd_resource type="Resource" script_class="Level" load_steps=15 format=3 uid="uid://ob41fnhkjr3o"]
[ext_resource type="Script" uid="uid://cuhq6u67cbbqm" path="res://Scripts/Level.gd" id="1_ftl6b"]
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Wave.gd" id="2_457yt"]
@ -8,14 +8,14 @@
[sub_resource type="Resource" id="Resource_5q243"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 3
number_to_spawn = 1
spawn_delay = 0.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
[sub_resource type="Resource" id="Resource_ps5n4"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 3
number_to_spawn = 1
spawn_delay = 3.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
@ -23,36 +23,12 @@ metadata/_custom_type_script = "uid://blxx3vs2wnfet"
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 1
spawn_delay = 3.4
spawn_delay = 3.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
[sub_resource type="Resource" id="Resource_r0qgc"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 1
spawn_delay = 1.0
[sub_resource type="Resource" id="Resource_qeljc"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 1
spawn_delay = 0.0
[sub_resource type="Resource" id="Resource_1p7sg"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 1
spawn_delay = 1.0
[sub_resource type="Resource" id="Resource_53y8p"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 1
spawn_delay = 0.0
[sub_resource type="Resource" id="Resource_m6gub"]
script = ExtResource("2_457yt")
troops = Array[ExtResource("3_ub8wd")]([SubResource("Resource_5q243"), SubResource("Resource_ps5n4"), SubResource("Resource_qfjse"), SubResource("Resource_r0qgc"), SubResource("Resource_qeljc"), SubResource("Resource_1p7sg"), SubResource("Resource_53y8p")])
troops = Array[ExtResource("3_ub8wd")]([SubResource("Resource_5q243"), SubResource("Resource_ps5n4"), SubResource("Resource_qfjse")])
wait_time_before_launch_wave = 4.0
wait_for_enemy_kills = true
metadata/_custom_type_script = "uid://chu8s12rtdeqx"
@ -67,7 +43,7 @@ metadata/_custom_type_script = "uid://blxx3vs2wnfet"
[sub_resource type="Resource" id="Resource_87wss"]
script = ExtResource("3_ub8wd")
enemy = ExtResource("4_ujs1b")
number_to_spawn = 3
number_to_spawn = 1
spawn_delay = 3.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"

View file

@ -258,6 +258,3 @@ transform = Transform3D(-0.0471892, 0, 1.99944, 0, 2, 0, -1.99944, 0, -0.0471892
transform = Transform3D(1.08365, 0, 1.68098, 0, 2, 0, -1.68098, 0, 1.08365, 1.44235, 0, 4.63481)
[node name="Towers" type="Node3D" parent="."]
[connection signal="timeout" from="WaveManager/WaveTimer" to="WaveManager" method="_on_wave_timer_timeout"]
[connection signal="timeout" from="WaveManager/TroopTimer" to="WaveManager" method="_on_troop_timer_timeout"]

View file

@ -86,7 +86,6 @@ func place_tower() -> void:
return
selected_tower = towerBlueprint.instantiate()
selected_tower.tower_type = selected_tower_type
towers.set(selected_tower_type, selected_tower)
add_child(selected_tower)
selected_tower.can_shoot = false
@ -106,8 +105,6 @@ func build_tower() -> void:
print("Too costly")
return
prints(selected_tower.is_rest, selected_tower.builded)
if selected_tower.is_rest:
if not selected_tower.builded:
#Build Tower

View file

@ -8,6 +8,14 @@ var current_troop : Troop
var enemies_to_spawn : int = 0
var wave_on_going : bool = false
@onready var waveTimer := $WaveTimer
@onready var troopTimer := $TroopTimer
func _ready() -> void:
troopTimer.timeout.connect(spawn_troop)
EventBus.player_defeated.connect(clearLevel)
func _process(delta: float) -> void:
if GameManager.wave > 0 || level.auto_start:
@ -21,19 +29,18 @@ func spawn_next_wave() -> void:
current_wave = level.waves.pop_front()
GameManager.wave += 1
$WaveTimer.start(current_wave.wait_time_before_launch_wave)
waveTimer.start(current_wave.wait_time_before_launch_wave)
func spawn_troop() -> void:
for n in current_troop.number_to_spawn:
var tempEnemy = current_troop.enemy.instantiate()
add_child(tempEnemy)
add_child(current_troop.enemy.instantiate())
GameManager.enemies_alive += 1
func spawn_manager() -> void:
#Send next troop
if !$WaveTimer.is_stopped() || !$TroopTimer.is_stopped():
if !waveTimer.is_stopped() || !troopTimer.is_stopped():
return
if !current_wave:
@ -45,8 +52,7 @@ func spawn_manager() -> void:
if (current_troop.spawn_delay == 0):
spawn_troop()
else:
$TroopTimer.wait_time = current_troop.spawn_delay
$TroopTimer.start()
troopTimer.start(current_troop.spawn_delay)
wave_on_going = true
if GameManager.enemies_alive == 0 && current_wave.troops.is_empty():
@ -56,8 +62,5 @@ func spawn_manager() -> void:
spawn_next_wave()
func _on_wave_timer_timeout() -> void:
pass
func _on_troop_timer_timeout() -> void:
spawn_troop()
func clearLevel() -> void:
queue_free()

View file

@ -37,6 +37,7 @@ func win():
func death():
EventBus.player_defeated.emit()
Transition.goto("res://UI/defeat_screen.tscn")
func _on_EventBus_money_received(money_received : int):

View file

@ -1,13 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://ck1qryleu80s"]
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_gvvig"]
[ext_resource type="Script" path="res://Towers/aline.gd" id="2_6sjqq"]
[ext_resource type="Script" uid="uid://16hafh01iv" path="res://Towers/aline.gd" id="2_6sjqq"]
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_p2nb1"]
[node name="Aline" instance=ExtResource("1_gvvig")]
script = ExtResource("2_6sjqq")
tower_name = "Aline"
tower_type = 1
tower_type = 2
icone = null
bio = ""
price = 150

View file

@ -6,6 +6,7 @@
[node name="Pierre" instance=ExtResource("1_7f7qx")]
script = ExtResource("1_v16mf")
tower_type = 1
icone = null
bio = ""
bullet_damage = 1

View file

@ -1,47 +0,0 @@
[gd_scene load_steps=5 format=3 uid="uid://dp846r4jscm5p"]
[ext_resource type="Script" uid="uid://8kpvuurr5h5n" path="res://Towers/tower.gd" id="1_pb6ru"]
[ext_resource type="Texture2D" uid="uid://315k07rsgf6t" path="res://Assets/Characters/Female1.png" id="2_pb6ru"]
[sub_resource type="BoxShape3D" id="BoxShape3D_egfuc"]
size = Vector3(1, 0.1, 1)
[sub_resource type="SphereShape3D" id="SphereShape3D_pajr1"]
radius = 3.0
[node name="Tower" type="StaticBody3D"]
collision_layer = 4
collision_mask = 4
script = ExtResource("1_pb6ru")
tower_name = "Aline"
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00914001, 0)
shape = SubResource("BoxShape3D_egfuc")
[node name="Range" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.923584, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Range"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.475708, 0)
shape = SubResource("SphereShape3D_pajr1")
[node name="Aim" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.02026, 0)
[node name="BulletContainer" type="Node" parent="."]
[node name="Cooldown" type="Timer" parent="."]
wait_time = 1.5
[node name="Sprite3D" type="Sprite3D" parent="."]
transform = Transform3D(3.5, 0, 0, 0, 3.5, 0, 0, 0, 3.5, 0, 0.515442, 0)
billboard = 2
texture = ExtResource("2_pb6ru")
hframes = 8
vframes = 12
frame = 75
[connection signal="body_entered" from="Range" to="." method="_on_range_body_entered"]
[connection signal="body_exited" from="Range" to="." method="_on_range_body_exited"]
[connection signal="timeout" from="Cooldown" to="." method="_on_cooldown_timeout"]

View file

@ -1,33 +0,0 @@
[gd_resource type="Resource" script_class="Wave" load_steps=7 format=3 uid="uid://dkbuy7fetnihs"]
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Wave.gd" id="1_bubg8"]
[ext_resource type="Script" uid="uid://blxx3vs2wnfet" path="res://Scripts/Troop.gd" id="2_mn2od"]
[ext_resource type="PackedScene" uid="uid://dknt1oiyei5e5" path="res://enemies/enemy-a.tscn" id="3_40llc"]
[sub_resource type="Resource" id="Resource_1mf3x"]
script = ExtResource("2_mn2od")
enemy = ExtResource("3_40llc")
number_to_spawn = 2
spawn_delay = 1.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
[sub_resource type="Resource" id="Resource_3i3vq"]
script = ExtResource("2_mn2od")
enemy = ExtResource("3_40llc")
number_to_spawn = 1
spawn_delay = 3.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
[sub_resource type="Resource" id="Resource_qdqr3"]
script = ExtResource("2_mn2od")
enemy = ExtResource("3_40llc")
number_to_spawn = 1
spawn_delay = 1.0
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
[resource]
script = ExtResource("1_bubg8")
troops = Array[ExtResource("2_mn2od")]([SubResource("Resource_1mf3x"), SubResource("Resource_3i3vq"), SubResource("Resource_qdqr3")])
wait_time_before_launch_wave = 5
wait_for_enemy_kills = true
metadata/_custom_type_script = "uid://chu8s12rtdeqx"