feat: improve tower manager
This commit is contained in:
parent
d7aab627f6
commit
325fa49b55
26 changed files with 370 additions and 381 deletions
|
|
@ -10,9 +10,6 @@ signal tower_selected(tower : PackedScene)
|
||||||
#Subscriber :
|
#Subscriber :
|
||||||
signal tower_builded(tower : Tower)
|
signal tower_builded(tower : Tower)
|
||||||
|
|
||||||
#Emitter : gui.gd
|
|
||||||
#Subscriber : PlayerManager.gd
|
|
||||||
signal tower_to_build(packed_tower : PackedScene)
|
|
||||||
|
|
||||||
#Emitter : UpgradeButton.gd
|
#Emitter : UpgradeButton.gd
|
||||||
#Subscriber : tower.gd
|
#Subscriber : tower.gd
|
||||||
|
|
@ -62,6 +59,10 @@ signal money_spent(_value : int)
|
||||||
#Subscriber : cube.gd
|
#Subscriber : cube.gd
|
||||||
signal player_has_won()
|
signal player_has_won()
|
||||||
|
|
||||||
|
#Emitter : spawner.gd
|
||||||
|
#Subscriber : cube.gd
|
||||||
|
signal player_defeated()
|
||||||
|
|
||||||
#Emitter : PlayerManager.gd
|
#Emitter : PlayerManager.gd
|
||||||
#Subscriber : game_menu.gd
|
#Subscriber : game_menu.gd
|
||||||
signal open_shop()
|
signal open_shop()
|
||||||
|
|
|
||||||
82
Levels/level_1.tres
Normal file
82
Levels/level_1.tres
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
[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"]
|
||||||
|
[ext_resource type="Script" uid="uid://blxx3vs2wnfet" path="res://Scripts/Troop.gd" id="3_ub8wd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dknt1oiyei5e5" path="res://enemies/enemy-a.tscn" id="4_ujs1b"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_5q243"]
|
||||||
|
script = ExtResource("3_ub8wd")
|
||||||
|
enemy = ExtResource("4_ujs1b")
|
||||||
|
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 = 1
|
||||||
|
spawn_delay = 3.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_qfjse"]
|
||||||
|
script = ExtResource("3_ub8wd")
|
||||||
|
enemy = ExtResource("4_ujs1b")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 3.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[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")])
|
||||||
|
wait_time_before_launch_wave = 4.0
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
metadata/_custom_type_script = "uid://chu8s12rtdeqx"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_1mxdl"]
|
||||||
|
script = ExtResource("3_ub8wd")
|
||||||
|
enemy = ExtResource("4_ujs1b")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 0.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_87wss"]
|
||||||
|
script = ExtResource("3_ub8wd")
|
||||||
|
enemy = ExtResource("4_ujs1b")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 3.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_457yt"]
|
||||||
|
script = ExtResource("2_457yt")
|
||||||
|
troops = Array[ExtResource("3_ub8wd")]([SubResource("Resource_1mxdl"), SubResource("Resource_87wss")])
|
||||||
|
wait_time_before_launch_wave = 5.0
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
metadata/_custom_type_script = "uid://chu8s12rtdeqx"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ftl6b"]
|
||||||
|
script = ExtResource("3_ub8wd")
|
||||||
|
enemy = ExtResource("4_ujs1b")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ub8wd"]
|
||||||
|
script = ExtResource("3_ub8wd")
|
||||||
|
enemy = ExtResource("4_ujs1b")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ujs1b"]
|
||||||
|
script = ExtResource("2_457yt")
|
||||||
|
troops = Array[ExtResource("3_ub8wd")]([SubResource("Resource_ftl6b"), SubResource("Resource_ub8wd")])
|
||||||
|
wait_time_before_launch_wave = 3.0
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
metadata/_custom_type_script = "uid://chu8s12rtdeqx"
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_ftl6b")
|
||||||
|
waves = Array[ExtResource("2_457yt")]([SubResource("Resource_m6gub"), SubResource("Resource_457yt"), SubResource("Resource_ujs1b")])
|
||||||
|
auto_start = false
|
||||||
|
metadata/_custom_type_script = "uid://cuhq6u67cbbqm"
|
||||||
82
Levels/level_2.tres
Normal file
82
Levels/level_2.tres
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
[gd_resource type="Resource" script_class="Level" load_steps=17 format=3 uid="uid://cbgaiaaleyf6j"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cuhq6u67cbbqm" path="res://Scripts/Level.gd" id="1_c4t4w"]
|
||||||
|
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Wave.gd" id="2_2ji0m"]
|
||||||
|
[ext_resource type="Script" uid="uid://blxx3vs2wnfet" path="res://Scripts/Troop.gd" id="3_y8rub"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dknt1oiyei5e5" path="res://enemies/enemy-a.tscn" id="4_nj0jn"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_cm6sg"]
|
||||||
|
script = ExtResource("2_2ji0m")
|
||||||
|
troops = Array[ExtResource("3_y8rub")]([])
|
||||||
|
wait_time_before_launch_wave = 3.0
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ps5n4"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
enemy = ExtResource("4_nj0jn")
|
||||||
|
number_to_spawn = 7
|
||||||
|
spawn_delay = 3.0
|
||||||
|
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_qeljc"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
enemy = ExtResource("4_nj0jn")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_1p7sg"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
enemy = ExtResource("4_nj0jn")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_y8rub"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
enemy = ExtResource("4_nj0jn")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_w0brl"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_c4t4w"]
|
||||||
|
script = ExtResource("2_2ji0m")
|
||||||
|
troops = Array[ExtResource("3_y8rub")]([SubResource("Resource_ps5n4"), SubResource("Resource_qeljc"), SubResource("Resource_1p7sg"), SubResource("Resource_y8rub"), SubResource("Resource_w0brl")])
|
||||||
|
wait_time_before_launch_wave = 3.8
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
metadata/_custom_type_script = "uid://chu8s12rtdeqx"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_2ji0m"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_nj0jn"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_s83h5"]
|
||||||
|
script = ExtResource("2_2ji0m")
|
||||||
|
troops = Array[ExtResource("3_y8rub")]([SubResource("Resource_2ji0m"), SubResource("Resource_nj0jn")])
|
||||||
|
wait_time_before_launch_wave = 3.6
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_833nr"]
|
||||||
|
script = ExtResource("3_y8rub")
|
||||||
|
number_to_spawn = 1
|
||||||
|
spawn_delay = 1.0
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_xgtww"]
|
||||||
|
script = ExtResource("2_2ji0m")
|
||||||
|
troops = Array[ExtResource("3_y8rub")]([SubResource("Resource_833nr")])
|
||||||
|
wait_time_before_launch_wave = 7.0
|
||||||
|
wait_for_enemy_kills = true
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_c4t4w")
|
||||||
|
waves = Array[ExtResource("2_2ji0m")]([SubResource("Resource_cm6sg"), SubResource("Resource_c4t4w"), SubResource("Resource_s83h5"), SubResource("Resource_xgtww")])
|
||||||
|
auto_start = false
|
||||||
|
metadata/_custom_type_script = "uid://cuhq6u67cbbqm"
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=28 format=3 uid="uid://ky0uewndeuwv"]
|
[gd_scene load_steps=21 format=3 uid="uid://ky0uewndeuwv"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://Levels/world.gd" id="1_fj7yv"]
|
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://Levels/world.gd" id="1_fj7yv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d1f6m15niwgt" path="res://Tiles/tile.tscn" id="3_aqk2v"]
|
[ext_resource type="PackedScene" uid="uid://d1f6m15niwgt" path="res://Tiles/tile.tscn" id="3_aqk2v"]
|
||||||
|
|
@ -7,10 +7,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://do7gm1gjhu1t5" path="res://Tiles/road.tscn" id="4_036b0"]
|
[ext_resource type="PackedScene" uid="uid://do7gm1gjhu1t5" path="res://Tiles/road.tscn" id="4_036b0"]
|
||||||
[ext_resource type="Script" uid="uid://tpon511km4al" path="res://Scripts/WaveManager.gd" id="5_036b0"]
|
[ext_resource type="Script" uid="uid://tpon511km4al" path="res://Scripts/WaveManager.gd" id="5_036b0"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dpjfo15otkfru" path="res://Tiles/cube.tscn" id="5_wse8f"]
|
[ext_resource type="PackedScene" uid="uid://dpjfo15otkfru" path="res://Tiles/cube.tscn" id="5_wse8f"]
|
||||||
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Wave.gd" id="6_gbfbk"]
|
[ext_resource type="Resource" uid="uid://ob41fnhkjr3o" path="res://Levels/level_1.tres" id="8_44brb"]
|
||||||
[ext_resource type="Resource" uid="uid://dkbuy7fetnihs" path="res://Waves/wave_1.tres" id="7_ioo17"]
|
|
||||||
[ext_resource type="Script" uid="uid://blxx3vs2wnfet" path="res://Scripts/Troop.gd" id="10_oyb16"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dknt1oiyei5e5" path="res://enemies/enemy-a.tscn" id="11_43wwi"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c54881eookjth" path="res://Assets/Meshes/SM_B26.glb" id="12_44brb"]
|
[ext_resource type="PackedScene" uid="uid://c54881eookjth" path="res://Assets/Meshes/SM_B26.glb" id="12_44brb"]
|
||||||
[ext_resource type="PackedScene" uid="uid://p6a6rb7sgeqd" path="res://UI/gui.tscn" id="12_ikoig"]
|
[ext_resource type="PackedScene" uid="uid://p6a6rb7sgeqd" path="res://UI/gui.tscn" id="12_ikoig"]
|
||||||
[ext_resource type="Script" uid="uid://xkk2pxkrwsq8" path="res://bullet_container.gd" id="12_k3n1d"]
|
[ext_resource type="Script" uid="uid://xkk2pxkrwsq8" path="res://bullet_container.gd" id="12_k3n1d"]
|
||||||
|
|
@ -65,34 +62,6 @@ _data = {
|
||||||
}
|
}
|
||||||
point_count = 2
|
point_count = 2
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_1mf3x"]
|
|
||||||
script = ExtResource("10_oyb16")
|
|
||||||
enemy = ExtResource("11_43wwi")
|
|
||||||
number_to_spawn = 2
|
|
||||||
spawn_delay = 0.0
|
|
||||||
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_3i3vq"]
|
|
||||||
script = ExtResource("10_oyb16")
|
|
||||||
enemy = ExtResource("11_43wwi")
|
|
||||||
number_to_spawn = 1
|
|
||||||
spawn_delay = 1.0
|
|
||||||
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_qdqr3"]
|
|
||||||
script = ExtResource("10_oyb16")
|
|
||||||
enemy = ExtResource("11_43wwi")
|
|
||||||
number_to_spawn = 1
|
|
||||||
spawn_delay = 1.0
|
|
||||||
metadata/_custom_type_script = "uid://blxx3vs2wnfet"
|
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_gtojq"]
|
|
||||||
script = ExtResource("6_gbfbk")
|
|
||||||
troops = Array[ExtResource("10_oyb16")]([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"
|
|
||||||
|
|
||||||
[sub_resource type="Environment" id="Environment_036b0"]
|
[sub_resource type="Environment" id="Environment_036b0"]
|
||||||
background_mode = 1
|
background_mode = 1
|
||||||
background_color = Color(0.924338, 0.849272, 0.847318, 1)
|
background_color = Color(0.924338, 0.849272, 0.847318, 1)
|
||||||
|
|
@ -249,7 +218,7 @@ transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 10.1496, 0.209118, 0.49
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
curve = SubResource("Curve3D_aqk2v")
|
curve = SubResource("Curve3D_aqk2v")
|
||||||
script = ExtResource("5_036b0")
|
script = ExtResource("5_036b0")
|
||||||
waves = Array[ExtResource("6_gbfbk")]([ExtResource("7_ioo17"), SubResource("Resource_gtojq")])
|
level = ExtResource("8_44brb")
|
||||||
|
|
||||||
[node name="WaveTimer" type="Timer" parent="WaveManager"]
|
[node name="WaveTimer" type="Timer" parent="WaveManager"]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
@ -289,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)
|
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="."]
|
[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"]
|
|
||||||
|
|
|
||||||
5
Scripts/Level.gd
Normal file
5
Scripts/Level.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Resource
|
||||||
|
class_name Level
|
||||||
|
|
||||||
|
@export var waves : Array[Wave]
|
||||||
|
@export var auto_start : bool = false
|
||||||
1
Scripts/Level.gd.uid
Normal file
1
Scripts/Level.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cuhq6u67cbbqm
|
||||||
|
|
@ -1,44 +1,28 @@
|
||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
class_name PlayerManager
|
class_name PlayerManager
|
||||||
enum STATE {IDLE,PLACING}
|
|
||||||
var _state = STATE.IDLE
|
|
||||||
|
|
||||||
#TODO Get rid of tower_blueprint
|
enum STATE { IDLE, PLACING }
|
||||||
@onready var tower_blueprint : PackedScene
|
var _state := STATE.IDLE
|
||||||
|
|
||||||
@onready var selected_tower : Tower = null
|
@onready var selected_tower : Tower = null
|
||||||
|
var selected_tower_type : Tower.TYPES = Tower.TYPES.NONE
|
||||||
|
|
||||||
@onready var cam : Camera3D = $"../Camera3D"
|
@onready var cam : Camera3D = $"../Camera3D"
|
||||||
@onready var the_cube : TheCube = %TheCube
|
@onready var the_cube : TheCube = %TheCube
|
||||||
@onready var selection_icon : Sprite3D = $Sprite3DSelection
|
@onready var selection_icon : Sprite3D = $Sprite3DSelection
|
||||||
|
|
||||||
@onready var towers : Array[Tower]
|
var towers : Dictionary
|
||||||
|
|
||||||
var tower_count : int = 0:
|
|
||||||
set(value):
|
|
||||||
tower_count = value
|
|
||||||
EventBus.tower_count_changed.emit(tower_count)
|
|
||||||
|
|
||||||
|
|
||||||
var team_in_action : Array[Tower]:
|
|
||||||
set(value):
|
|
||||||
team_in_action = value
|
|
||||||
EventBus.team_in_action_changed.emit(team_in_action)
|
|
||||||
|
|
||||||
|
|
||||||
var team_in_rest : Array[Tower]:
|
|
||||||
set(value):
|
|
||||||
team_in_rest = value
|
|
||||||
EventBus.team_in_rest_changed.emit(team_in_rest)
|
|
||||||
|
|
||||||
var target_tower : Tower
|
|
||||||
|
|
||||||
var selected_collider : CollisionObject3D
|
var selected_collider : CollisionObject3D
|
||||||
|
|
||||||
|
static func getResourceTowerByType(towerId : Tower.TYPES) -> PackedScene:
|
||||||
|
match towerId:
|
||||||
|
Tower.TYPES.PIERRE: return load("res://Towers/pierre.tscn")
|
||||||
|
Tower.TYPES.ALINE: return load("res://Towers/aline.tscn")
|
||||||
|
_: return null
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
EventBus.tower_selected.connect(_on_EventBus_tower_selected)
|
EventBus.tower_selected.connect(selectTower)
|
||||||
EventBus.tower_to_build.connect(_on_EventBus_tower_to_build)
|
|
||||||
#$AnimationPlayer.play("arrow_bobbing")
|
#$AnimationPlayer.play("arrow_bobbing")
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
|
|
@ -59,8 +43,9 @@ func _process(delta: float) -> void:
|
||||||
quit_placing()
|
quit_placing()
|
||||||
|
|
||||||
EventBus.close_shop.emit()
|
EventBus.close_shop.emit()
|
||||||
if target_tower:
|
if selected_collider is Tower:
|
||||||
send_to_rest()
|
selected_collider.is_rest = true
|
||||||
|
emitTeamChanges()
|
||||||
|
|
||||||
func handle_player_controls() -> void:
|
func handle_player_controls() -> void:
|
||||||
var space_state : PhysicsDirectSpaceState3D = get_world_3d().direct_space_state
|
var space_state : PhysicsDirectSpaceState3D = get_world_3d().direct_space_state
|
||||||
|
|
@ -78,112 +63,104 @@ func handle_player_controls() -> void:
|
||||||
selected_collider = null
|
selected_collider = null
|
||||||
return
|
return
|
||||||
|
|
||||||
var collider : CollisionObject3D = ray_result.get("collider")
|
selected_collider = ray_result.get("collider")
|
||||||
selected_collider = collider
|
|
||||||
visible = true
|
visible = true
|
||||||
selection_icon.visible = false
|
selection_icon.visible = false
|
||||||
global_position = collider.global_position
|
global_position = selected_collider.global_position
|
||||||
global_position += Vector3(0.0,0.02,0.0)
|
global_position += Vector3(0.0,0.02,0.0)
|
||||||
|
|
||||||
if selected_collider is Tower:
|
|
||||||
target_tower = collider
|
|
||||||
else:
|
|
||||||
target_tower = null
|
|
||||||
|
|
||||||
if _state == STATE.PLACING:
|
if _state == STATE.PLACING:
|
||||||
tower_to_place.sprite.modulate = "ff4545c8" #If the tower can't be placed he is red
|
selected_tower.sprite.modulate = "ff4545c8" #If the tower can't be placed he is red
|
||||||
selection_icon.visible = false
|
selection_icon.visible = false
|
||||||
if selected_collider is BuildTile: #if we are placing a tower, hide the selector model
|
if selected_collider is BuildTile: #if we are placing a tower, hide the selector model
|
||||||
tower_to_place.sprite.modulate = "61ff45c8" #If the tower can be placed he is green
|
selected_tower.sprite.modulate = "61ff45c8" #If the tower can be placed he is green
|
||||||
|
|
||||||
|
|
||||||
var tower_to_place : Tower #It is freed in the build_tower()
|
|
||||||
func place_tower() -> void:
|
func place_tower() -> void:
|
||||||
_state = STATE.PLACING
|
_state = STATE.PLACING
|
||||||
tower_to_place = tower_blueprint.instantiate()
|
|
||||||
add_child(tower_to_place)
|
var towerBlueprint = getResourceTowerByType(selected_tower_type)
|
||||||
tower_to_place.can_shoot = false
|
if !towerBlueprint:
|
||||||
tower_to_place.collision_layer = 0
|
selected_tower = null
|
||||||
tower_to_place.sprite.modulate = "ffffffc8"
|
selected_tower_type = Tower.TYPES.NONE
|
||||||
tower_to_place.show_price_tag()
|
return
|
||||||
|
|
||||||
|
selected_tower = towerBlueprint.instantiate()
|
||||||
|
towers.set(selected_tower_type, selected_tower)
|
||||||
|
add_child(selected_tower)
|
||||||
|
selected_tower.can_shoot = false
|
||||||
|
selected_tower.collision_layer = 0
|
||||||
|
selected_tower.show_price_tag()
|
||||||
|
|
||||||
func quit_placing() -> void:
|
func quit_placing() -> void:
|
||||||
_state = STATE.IDLE
|
_state = STATE.IDLE
|
||||||
tower_to_place.queue_free()
|
|
||||||
|
|
||||||
# Refactoriser ce code
|
# Refactoriser ce code
|
||||||
func build_tower() -> void:
|
func build_tower() -> void:
|
||||||
if tower_blueprint == null:
|
if !visible || !selected_tower:
|
||||||
return
|
return
|
||||||
|
|
||||||
if !visible:
|
if not selected_tower.builded && selected_tower.price > the_cube.money:
|
||||||
return
|
|
||||||
|
|
||||||
var temp_tower : Tower = tower_blueprint.instantiate()
|
|
||||||
|
|
||||||
|
|
||||||
#Move existing tower
|
|
||||||
for tower : Tower in team_in_action:
|
|
||||||
if tower.tower_name == temp_tower.tower_name:
|
|
||||||
move_tower()
|
|
||||||
return
|
|
||||||
|
|
||||||
#Send to action a resting tower
|
|
||||||
for tower : Tower in team_in_rest:
|
|
||||||
if tower.tower_name == temp_tower.tower_name:
|
|
||||||
move_tower()
|
|
||||||
send_to_action()
|
|
||||||
return
|
|
||||||
|
|
||||||
#Build Tower
|
|
||||||
if temp_tower.price < the_cube.money:
|
|
||||||
#Can't build
|
#Can't build
|
||||||
print("Too costly")
|
print("Too costly")
|
||||||
return
|
return
|
||||||
else :
|
|
||||||
#Can build
|
|
||||||
quit_placing() #Destroy the tower placeholder
|
|
||||||
|
|
||||||
EventBus.money_spent.emit(temp_tower.price)
|
if selected_tower.is_rest:
|
||||||
tower_count += 1
|
if not selected_tower.builded:
|
||||||
$"../Towers".add_child(temp_tower)
|
#Build Tower
|
||||||
EventBus.tower_builded.emit(temp_tower)
|
EventBus.money_spent.emit(selected_tower.price)
|
||||||
towers.append(temp_tower)
|
selected_tower.can_shoot = true
|
||||||
tower_blueprint == null
|
selected_tower.collision_layer = 3
|
||||||
selected_tower = temp_tower
|
selected_tower.sprite.modulate = "ffffffff"
|
||||||
send_to_action()
|
selected_tower.hide_price_tag()
|
||||||
move_tower()
|
selected_tower.builded = true
|
||||||
|
EventBus.tower_builded.emit(selected_tower)
|
||||||
|
remove_child(selected_tower)
|
||||||
|
$"../Towers".add_child(selected_tower)
|
||||||
|
quit_placing()
|
||||||
|
selected_tower.is_rest = false
|
||||||
|
|
||||||
|
print(selected_tower.tower_type)
|
||||||
|
move_tower()
|
||||||
|
emitTeamChanges()
|
||||||
|
|
||||||
|
|
||||||
|
func selectTower(towerType : Tower.TYPES):
|
||||||
|
if selected_tower && not selected_tower.builded:
|
||||||
|
selected_tower.visible = false
|
||||||
|
|
||||||
|
if towerType == selected_tower_type:
|
||||||
|
selected_tower = null
|
||||||
|
selected_tower_type = Tower.TYPES.NONE
|
||||||
|
_state = STATE.IDLE
|
||||||
|
return
|
||||||
|
|
||||||
|
selected_tower_type = towerType
|
||||||
|
if towers.has(towerType):
|
||||||
|
_state = STATE.IDLE
|
||||||
|
selected_tower = towers.get(towerType)
|
||||||
|
selected_tower.visible = true
|
||||||
|
else:
|
||||||
|
place_tower()
|
||||||
|
|
||||||
|
|
||||||
func move_tower():
|
func move_tower():
|
||||||
selected_tower.global_position = global_position
|
selected_tower.global_position = global_position
|
||||||
|
|
||||||
|
|
||||||
func send_to_rest():
|
func emitTeamChanges() -> void:
|
||||||
team_in_action.erase(selected_tower)
|
var team_in_action : int = 0
|
||||||
team_in_rest.append(selected_tower)
|
var team_in_rest : int = 0
|
||||||
selected_tower.is_rest = true
|
var tower_count : int = 0
|
||||||
|
for towerType in towers:
|
||||||
|
var tower : Tower = towers[towerType]
|
||||||
|
if tower.builded:
|
||||||
|
tower_count += 1
|
||||||
|
if tower.is_rest:
|
||||||
|
team_in_rest += 1
|
||||||
|
else:
|
||||||
|
team_in_action += 1
|
||||||
|
|
||||||
EventBus.team_in_action_changed.emit(team_in_action)
|
EventBus.team_in_action_changed.emit(team_in_action)
|
||||||
|
EventBus.team_in_rest_changed.emit(team_in_rest)
|
||||||
|
EventBus.tower_count_changed.emit(tower_count)
|
||||||
func send_to_action():
|
|
||||||
team_in_rest.erase(selected_tower)
|
|
||||||
team_in_action.append(selected_tower)
|
|
||||||
selected_tower.is_rest = false
|
|
||||||
EventBus.team_in_action_changed.emit(team_in_action)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_EventBus_tower_selected(tower : PackedScene):
|
|
||||||
# TODO: Remove tower_blueprint
|
|
||||||
print("pouette")
|
|
||||||
# tower_blueprint = tower
|
|
||||||
|
|
||||||
# TODO: Utile ?
|
|
||||||
func _on_cube_icon_pressed() -> void:
|
|
||||||
pass
|
|
||||||
#open_shop()
|
|
||||||
|
|
||||||
func _on_EventBus_tower_to_build(packed_tower : PackedScene) -> void:
|
|
||||||
tower_blueprint = packed_tower
|
|
||||||
place_tower()
|
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@ extends Resource
|
||||||
class_name Wave
|
class_name Wave
|
||||||
|
|
||||||
@export var troops : Array[Troop]
|
@export var troops : Array[Troop]
|
||||||
@export var wait_time_before_launch_wave : int = 3
|
@export var wait_time_before_launch_wave : float = 3
|
||||||
@export var wait_for_enemy_kills : bool = true
|
@export var wait_for_enemy_kills : bool = true
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,50 @@
|
||||||
extends Path3D
|
extends Path3D
|
||||||
class_name WaveManager
|
class_name WaveManager
|
||||||
|
|
||||||
@export var waves : Array[Wave]
|
@export var level : Level
|
||||||
var current_wave : Wave
|
var current_wave : Wave
|
||||||
var current_troop : Troop
|
var current_troop : Troop
|
||||||
|
|
||||||
var enemies_to_spawn : int = 0
|
var enemies_to_spawn : int = 0
|
||||||
var wave_on_going : bool = false
|
var wave_on_going : bool = false
|
||||||
var game_has_start : 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:
|
func _process(delta: float) -> void:
|
||||||
if GameManager.wave > 0:
|
if GameManager.wave > 0 || level.auto_start:
|
||||||
spawn_manager()
|
spawn_manager()
|
||||||
|
|
||||||
|
|
||||||
func spawn_next_wave() -> void:
|
func spawn_next_wave() -> void:
|
||||||
if waves.is_empty():
|
if level.waves.is_empty():
|
||||||
EventBus.player_has_won.emit()
|
EventBus.player_has_won.emit()
|
||||||
return
|
return
|
||||||
|
|
||||||
current_wave = waves.pop_front()
|
current_wave = level.waves.pop_front()
|
||||||
GameManager.wave += 1
|
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:
|
func spawn_troop() -> void:
|
||||||
for n in current_troop.number_to_spawn:
|
for n in current_troop.number_to_spawn:
|
||||||
var tempEnemy = current_troop.enemy.instantiate()
|
add_child(current_troop.enemy.instantiate())
|
||||||
add_child(tempEnemy)
|
|
||||||
GameManager.enemies_alive += 1
|
GameManager.enemies_alive += 1
|
||||||
|
|
||||||
|
|
||||||
func spawn_manager() -> void:
|
func spawn_manager() -> void:
|
||||||
#Send next troop
|
#Send next troop
|
||||||
if !$WaveTimer.is_stopped() || !$TroopTimer.is_stopped():
|
if !waveTimer.is_stopped() || !troopTimer.is_stopped():
|
||||||
|
return
|
||||||
|
|
||||||
|
if !current_wave:
|
||||||
|
spawn_next_wave()
|
||||||
return
|
return
|
||||||
|
|
||||||
if !current_wave.troops.is_empty():
|
if !current_wave.troops.is_empty():
|
||||||
|
|
@ -42,8 +52,7 @@ func spawn_manager() -> void:
|
||||||
if (current_troop.spawn_delay == 0):
|
if (current_troop.spawn_delay == 0):
|
||||||
spawn_troop()
|
spawn_troop()
|
||||||
else:
|
else:
|
||||||
$TroopTimer.wait_time = current_troop.spawn_delay
|
troopTimer.start(current_troop.spawn_delay)
|
||||||
$TroopTimer.start()
|
|
||||||
|
|
||||||
wave_on_going = true
|
wave_on_going = true
|
||||||
if GameManager.enemies_alive == 0 && current_wave.troops.is_empty():
|
if GameManager.enemies_alive == 0 && current_wave.troops.is_empty():
|
||||||
|
|
@ -53,8 +62,5 @@ func spawn_manager() -> void:
|
||||||
spawn_next_wave()
|
spawn_next_wave()
|
||||||
|
|
||||||
|
|
||||||
func _on_wave_timer_timeout() -> void:
|
func clearLevel() -> void:
|
||||||
pass
|
queue_free()
|
||||||
|
|
||||||
func _on_troop_timer_timeout() -> void:
|
|
||||||
spawn_troop()
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ func win():
|
||||||
|
|
||||||
|
|
||||||
func death():
|
func death():
|
||||||
|
EventBus.player_defeated.emit()
|
||||||
Transition.goto("res://UI/defeat_screen.tscn")
|
Transition.goto("res://UI/defeat_screen.tscn")
|
||||||
|
|
||||||
func _on_EventBus_money_received(money_received : int):
|
func _on_EventBus_money_received(money_received : int):
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://btmhe8ah6eexf"]
|
[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="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_gvvig"]
|
||||||
[ext_resource type="Script" uid="uid://16hafh01iv" path="res://Towers/aline.gd" id="2_6sjqq"]
|
[ext_resource type="Script" uid="uid://16hafh01iv" path="res://Towers/Aline/aline.gd" id="2_6sjqq"]
|
||||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_p2nb1"]
|
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_p2nb1"]
|
||||||
|
|
||||||
[node name="Aline" instance=ExtResource("1_gvvig")]
|
[node name="Aline" instance=ExtResource("1_gvvig")]
|
||||||
script = ExtResource("2_6sjqq")
|
script = ExtResource("2_6sjqq")
|
||||||
|
tower_name = "Aline"
|
||||||
|
tower_type = 2
|
||||||
icone = null
|
icone = null
|
||||||
bio = ""
|
bio = ""
|
||||||
|
price = 150
|
||||||
bullet_damage = 1
|
bullet_damage = 1
|
||||||
tower_shop = Array[ExtResource("3_p2nb1")]([])
|
tower_shop = Array[ExtResource("3_p2nb1")]([])
|
||||||
|
|
||||||
|
|
@ -1,15 +1,13 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bj6srer7ghf7p"]
|
[gd_scene load_steps=4 format=3 uid="uid://bj6srer7ghf7p"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_7f7qx"]
|
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_7f7qx"]
|
||||||
[ext_resource type="Script" uid="uid://q4o384wv3ijj" path="res://Towers/pierre.gd" id="1_v16mf"]
|
[ext_resource type="Script" uid="uid://q4o384wv3ijj" path="res://Towers/Pierre/pierre.gd" id="1_v16mf"]
|
||||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_v16mf"]
|
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_v16mf"]
|
||||||
|
|
||||||
[node name="Pierre" instance=ExtResource("1_7f7qx")]
|
[node name="Pierre" instance=ExtResource("1_7f7qx")]
|
||||||
script = ExtResource("1_v16mf")
|
script = ExtResource("1_v16mf")
|
||||||
|
tower_type = 1
|
||||||
icone = null
|
icone = null
|
||||||
bio = ""
|
bio = ""
|
||||||
bullet_damage = 1
|
bullet_damage = 1
|
||||||
tower_shop = Array[ExtResource("3_v16mf")]([])
|
tower_shop = Array[ExtResource("3_v16mf")]([])
|
||||||
|
|
||||||
[node name="EnergyBar3D" parent="." index="7"]
|
|
||||||
visible = true
|
|
||||||
|
|
@ -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"]
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
extends StaticBody3D
|
extends StaticBody3D
|
||||||
class_name Tower
|
class_name Tower
|
||||||
|
|
||||||
|
enum TYPES { NONE, PIERRE, ALINE, MAXENCE, VICTORIA, EVAN, ALEX }
|
||||||
|
|
||||||
var bullet : PackedScene = preload("res://Bullets/bullet.tscn")
|
var bullet : PackedScene = preload("res://Bullets/bullet.tscn")
|
||||||
@export var tower_name : String = "Pierre"
|
@export var tower_name : String = "Pierre"
|
||||||
|
@export var tower_type : TYPES
|
||||||
@export var icone : Texture2D
|
@export var icone : Texture2D
|
||||||
@export var bio : String
|
@export var bio : String
|
||||||
|
|
||||||
|
|
@ -38,8 +41,9 @@ var current_targets : Array = []
|
||||||
var current : CharacterBody3D
|
var current : CharacterBody3D
|
||||||
var can_shoot : bool = true
|
var can_shoot : bool = true
|
||||||
var is_exhausted : bool = false
|
var is_exhausted : bool = false
|
||||||
|
var builded : bool = false
|
||||||
|
|
||||||
var is_rest : bool = false:
|
var is_rest : bool = true:
|
||||||
set(value):
|
set(value):
|
||||||
is_rest = value
|
is_rest = value
|
||||||
if value:
|
if value:
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@ frame = 75
|
||||||
|
|
||||||
[node name="EnergyBar3D" parent="." instance=ExtResource("3_pajr1")]
|
[node name="EnergyBar3D" parent="." instance=ExtResource("3_pajr1")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.44473, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.44473, 0)
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="PriceTag" type="Label3D" parent="."]
|
[node name="PriceTag" type="Label3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.06776, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.06776, 0)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
extends ProgressBar
|
|
||||||
|
|
||||||
func _init() -> void:
|
|
||||||
#font_outline_color = Color.YELLOW
|
|
||||||
EventBus.energy_has_changed.connect(changeEnergy)
|
|
||||||
|
|
||||||
func changeEnergy(tower : Tower) -> void:
|
|
||||||
if tower is Pierre:
|
|
||||||
value = tower.energy
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://igvr34eaqta
|
|
||||||
24
UI/gui.gd
24
UI/gui.gd
|
|
@ -15,27 +15,3 @@ func _on_button_quit_level_pressed() -> void:
|
||||||
|
|
||||||
func _on_button_quit_game_pressed() -> void:
|
func _on_button_quit_game_pressed() -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
func _on_button_pierre_pressed() -> void:
|
|
||||||
var can_build = true
|
|
||||||
for tower in player_manager.towers:
|
|
||||||
if tower is Pierre:
|
|
||||||
can_build = false
|
|
||||||
player_manager.selected_tower = tower #If can't build, tower is selected
|
|
||||||
|
|
||||||
if can_build: #If Pierre is not builded then build it !
|
|
||||||
print("can build !")
|
|
||||||
EventBus.tower_to_build.emit(load("res://Towers/pierre.tscn"))
|
|
||||||
|
|
||||||
|
|
||||||
func _on_button_aline_pressed() -> void:
|
|
||||||
var can_build = true
|
|
||||||
for tower in player_manager.towers:
|
|
||||||
if tower is Pierre:
|
|
||||||
can_build = false
|
|
||||||
player_manager.selected_tower = tower #If can't build, tower is selected
|
|
||||||
|
|
||||||
if can_build: #If Pierre is not builded then build it !
|
|
||||||
print("can build !")
|
|
||||||
EventBus.tower_to_build.emit(load("res://Towers/aline.tscn"))
|
|
||||||
|
|
|
||||||
116
UI/gui.tscn
116
UI/gui.tscn
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=23 format=3 uid="uid://p6a6rb7sgeqd"]
|
[gd_scene load_steps=22 format=3 uid="uid://p6a6rb7sgeqd"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d2x8oy4os7ysn" path="res://UI/label_money.gd" id="1_cwd3r"]
|
[ext_resource type="Script" uid="uid://d2x8oy4os7ysn" path="res://UI/label_money.gd" id="1_cwd3r"]
|
||||||
[ext_resource type="Script" uid="uid://c350dletl5pde" path="res://UI/label_tower_in_cube.gd" id="2_6ujs1"]
|
[ext_resource type="Script" uid="uid://c350dletl5pde" path="res://UI/label_tower_in_cube.gd" id="2_6ujs1"]
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://b4m5ejfdrm8s0" path="res://Assets/Icones/power-button.svg" id="9_reygo"]
|
[ext_resource type="Texture2D" uid="uid://b4m5ejfdrm8s0" path="res://Assets/Icones/power-button.svg" id="9_reygo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cob1lydkirn20" path="res://Assets/Icones/raccoon-head.svg" id="10_reygo"]
|
[ext_resource type="Texture2D" uid="uid://cob1lydkirn20" path="res://Assets/Icones/raccoon-head.svg" id="10_reygo"]
|
||||||
[ext_resource type="Texture2D" uid="uid://boxdrq4nrq7hv" path="res://Assets/Icones/flamingo.svg" id="11_76b7g"]
|
[ext_resource type="Texture2D" uid="uid://boxdrq4nrq7hv" path="res://Assets/Icones/flamingo.svg" id="11_76b7g"]
|
||||||
[ext_resource type="Script" uid="uid://igvr34eaqta" path="res://UI/PierreEnergyMenuProgressBar.gd" id="12_decjp"]
|
[ext_resource type="PackedScene" uid="uid://dqb5o8w7u50hc" path="res://UI/tower_button-v2.tscn" id="11_ay13l"]
|
||||||
[ext_resource type="Texture2D" uid="uid://m6jwakrus50v" path="res://Assets/Icones/sea-star.svg" id="12_ih1k6"]
|
[ext_resource type="Texture2D" uid="uid://m6jwakrus50v" path="res://Assets/Icones/sea-star.svg" id="12_ih1k6"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dwwgho6f8f4kj" path="res://Assets/Icones/penguin.svg" id="13_ryolu"]
|
[ext_resource type="Texture2D" uid="uid://dwwgho6f8f4kj" path="res://Assets/Icones/penguin.svg" id="13_ryolu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://c4ir6y45pchpl" path="res://Assets/Icones/seahorse.svg" id="14_hndjt"]
|
[ext_resource type="Texture2D" uid="uid://c4ir6y45pchpl" path="res://Assets/Icones/seahorse.svg" id="14_hndjt"]
|
||||||
|
|
@ -31,9 +31,6 @@ bg_color = Color(0.727498, 0.222072, 0.249347, 1)
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3lugd"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3lugd"]
|
||||||
bg_color = Color(0.933333, 0.933333, 0.933333, 1)
|
bg_color = Color(0.933333, 0.933333, 0.933333, 1)
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_decjp"]
|
|
||||||
bg_color = Color(1, 0.878431, 0, 1)
|
|
||||||
|
|
||||||
[node name="GUI" type="Control"]
|
[node name="GUI" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
|
|
@ -209,111 +206,47 @@ grow_vertical = 2
|
||||||
texture = ExtResource("8_ay13l")
|
texture = ExtResource("8_ay13l")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
|
|
||||||
[node name="ButtonPierre" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="ButtonPierre" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer" instance=ExtResource("11_ay13l")]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Sélectionner Pierre"
|
towerType = 1
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonPierre"]
|
[node name="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonPierre" index="0"]
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("9_decjp")
|
texture = ExtResource("9_decjp")
|
||||||
expand_mode = 1
|
|
||||||
|
|
||||||
[node name="ProgressBar" type="ProgressBar" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonPierre"]
|
[node name="ButtonAline" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer" instance=ExtResource("11_ay13l")]
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 1.0
|
|
||||||
offset_top = 71.0
|
|
||||||
offset_right = 79.0
|
|
||||||
offset_bottom = 78.0
|
|
||||||
mouse_filter = 1
|
|
||||||
theme_override_styles/fill = SubResource("StyleBoxFlat_decjp")
|
|
||||||
show_percentage = false
|
|
||||||
script = ExtResource("12_decjp")
|
|
||||||
|
|
||||||
[node name="ButtonAline" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
|
||||||
custom_minimum_size = Vector2(80, 80)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Sélectionner Aline"
|
towerType = 2
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAline"]
|
[node name="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAline" index="0"]
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("10_reygo")
|
texture = ExtResource("10_reygo")
|
||||||
expand_mode = 1
|
|
||||||
|
|
||||||
[node name="ButtonMaxence" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="ButtonMaxcence2" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer" instance=ExtResource("11_ay13l")]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Sélectionner Maxence"
|
towerType = 3
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonMaxence"]
|
[node name="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonMaxcence2" index="0"]
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("11_76b7g")
|
texture = ExtResource("11_76b7g")
|
||||||
expand_mode = 1
|
|
||||||
|
|
||||||
[node name="ButtonVictoria" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="ButtonVictoria" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer" instance=ExtResource("11_ay13l")]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Sélectionner Victoria"
|
towerType = 4
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonVictoria"]
|
[node name="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonVictoria" index="0"]
|
||||||
layout_mode = 2
|
|
||||||
offset_right = 80.0
|
|
||||||
offset_bottom = 80.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("12_ih1k6")
|
texture = ExtResource("12_ih1k6")
|
||||||
expand_mode = 1
|
|
||||||
|
|
||||||
[node name="ButtonEvan" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="ButtonEvan" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer" instance=ExtResource("11_ay13l")]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Sélectionner Evan"
|
towerType = 5
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonEvan"]
|
[node name="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonEvan" index="0"]
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("13_ryolu")
|
texture = ExtResource("13_ryolu")
|
||||||
expand_mode = 1
|
|
||||||
|
|
||||||
[node name="ButtonAlex" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="ButtonAlex" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer" instance=ExtResource("11_ay13l")]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Sélectionner Alex"
|
towerType = 6
|
||||||
mouse_default_cursor_shape = 2
|
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAlex"]
|
[node name="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAlex" index="0"]
|
||||||
layout_mode = 1
|
|
||||||
anchors_preset = 15
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
texture = ExtResource("14_hndjt")
|
texture = ExtResource("14_hndjt")
|
||||||
expand_mode = 1
|
|
||||||
|
|
||||||
[node name="Button11" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
[node name="Button11" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
||||||
custom_minimum_size = Vector2(80, 80)
|
custom_minimum_size = Vector2(80, 80)
|
||||||
|
|
@ -348,5 +281,10 @@ mouse_default_cursor_shape = 2
|
||||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonCube" to="." method="_on_button_cube_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonCube" to="." method="_on_button_cube_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonQuitLevel" to="." method="_on_button_quit_level_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonQuitLevel" to="." method="_on_button_quit_level_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonQuitGame" to="." method="_on_button_quit_game_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonQuitGame" to="." method="_on_button_quit_game_pressed"]
|
||||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonPierre" to="." method="_on_button_pierre_pressed"]
|
|
||||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAline" to="." method="_on_button_aline_pressed"]
|
[editable path="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonPierre"]
|
||||||
|
[editable path="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAline"]
|
||||||
|
[editable path="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonMaxcence2"]
|
||||||
|
[editable path="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonVictoria"]
|
||||||
|
[editable path="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonEvan"]
|
||||||
|
[editable path="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonAlex"]
|
||||||
|
|
|
||||||
34
UI/tower_button-v2.tscn
Normal file
34
UI/tower_button-v2.tscn
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://dqb5o8w7u50hc"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dyhtr6g7kd1g2" path="res://UI/tower_button.gd" id="1_3542o"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_decjp"]
|
||||||
|
bg_color = Color(1, 0.878431, 0, 1)
|
||||||
|
|
||||||
|
[node name="TowerButton" type="Button"]
|
||||||
|
custom_minimum_size = Vector2(80, 80)
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
tooltip_text = "Sélectionner Pierre"
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
script = ExtResource("1_3542o")
|
||||||
|
metadata/_custom_type_script = "uid://dyhtr6g7kd1g2"
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
expand_mode = 1
|
||||||
|
|
||||||
|
[node name="ProgressBar" type="ProgressBar" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 1.0
|
||||||
|
offset_top = 71.0
|
||||||
|
offset_right = 79.0
|
||||||
|
offset_bottom = 78.0
|
||||||
|
mouse_filter = 1
|
||||||
|
theme_override_styles/fill = SubResource("StyleBoxFlat_decjp")
|
||||||
|
show_percentage = false
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
extends Button
|
extends Button
|
||||||
class_name TowerButton
|
class_name TowerButton
|
||||||
|
|
||||||
@export var tower : PackedScene
|
@export var towerType : Tower.TYPES
|
||||||
#var tower_in_game : Tower
|
|
||||||
|
|
||||||
func _on_pressed() -> void:
|
func _init() -> void:
|
||||||
EventBus.tower_selected.emit(tower, self)
|
#font_outline_color = Color.YELLOW
|
||||||
|
EventBus.energy_has_changed.connect(changeEnergy)
|
||||||
|
pressed.connect(func(): EventBus.tower_selected.emit(towerType))
|
||||||
|
|
||||||
|
|
||||||
|
func changeEnergy(tower : Tower) -> void:
|
||||||
|
if tower.tower_type == towerType:
|
||||||
|
$ProgressBar.value = tower.energy
|
||||||
|
|
|
||||||
|
|
@ -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"
|
|
||||||
Loading…
Add table
Reference in a new issue