feat: add autoloader for menu level buttons
fix: wave not restartable when winned clean: remove useless files + warnings
This commit is contained in:
parent
927486d456
commit
23e0c03fc0
29 changed files with 152 additions and 183 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
@tool
|
@tool
|
||||||
extends Node
|
extends Node
|
||||||
|
@warning_ignore_start("unused_signal")
|
||||||
|
|
||||||
## [b]Emitter[/b] : [method GuiButton._ready][br]
|
## [b]Emitter[/b] : [method GuiButton._ready][br]
|
||||||
## [b]Subscriber[/b] : [method TowerManager._init]
|
## [b]Subscriber[/b] : [method TowerManager._init]
|
||||||
|
|
@ -23,8 +23,8 @@ signal cube_integrity_changed(_value : int, _max_value : int)
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [TheCube][br]
|
## [b]Emitter[/b] : [TheCube][br]
|
||||||
## [b]Subscriber[/b] : label_money.gd
|
## [b]Subscriber[/b] : gui.gd
|
||||||
signal money_changed(_value : int)
|
signal money_changed(newAmount : int)
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [TheCube][br]
|
## [b]Emitter[/b] : [TheCube][br]
|
||||||
|
|
@ -33,33 +33,33 @@ signal cube_ready(theCube : TheCube)
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [TowerManager][br]
|
## [b]Emitter[/b] : [TowerManager][br]
|
||||||
## [b]Subscriber[/b] : label_team.gd
|
## [b]Subscriber[/b] : gui.gd
|
||||||
signal tower_count_changed(_value : int)
|
signal tower_count_changed(count : int)
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [TowerManager][br]
|
## [b]Emitter[/b] : [TowerManager][br]
|
||||||
## [b]Subscriber[/b] : label_team.gd, label_tower_on_terrain.gd
|
## [b]Subscriber[/b] : gui.gd
|
||||||
signal team_in_action_changed(_value : int)
|
signal team_in_action_changed(count : int)
|
||||||
|
|
||||||
## [b]Emitter[/b] : [TowerManager][br]
|
## [b]Emitter[/b] : [TowerManager][br]
|
||||||
## [b]Subscriber[/b] : label_tower_in_cube[TheCube]
|
## [b]Subscriber[/b] : gui.gd, [TheCube]
|
||||||
signal team_in_rest_changed(_value : int)
|
signal team_in_rest_changed(count : int)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [Projectile][br]
|
## [b]Emitter[/b] : [Projectile][br]
|
||||||
## [b]Subscriber[/b] : [code]null[/code]
|
## [b]Subscriber[/b] : [code]null[/code]
|
||||||
signal projectile_shooted(_value : Projectile)
|
signal projectile_shooted(projectile: Projectile, startPosition: Vector3)
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [Enemy][br]
|
## [b]Emitter[/b] : [Enemy][br]
|
||||||
## [b]Subscriber[/b] : [TheCube]
|
## [b]Subscriber[/b] : [TheCube]
|
||||||
signal money_received(_value : int)
|
signal money_received(amount : int)
|
||||||
|
|
||||||
|
|
||||||
## [b]Emitter[/b] : [TowerManager][br]
|
## [b]Emitter[/b] : [TowerManager][br]
|
||||||
## [b]Subscriber[/b] : [TheCube]
|
## [b]Subscriber[/b] : [TheCube]
|
||||||
signal money_spent(_value : int)
|
signal money_spent(amount : int)
|
||||||
|
|
||||||
## [b]Emitter[/b] : [WorldManager][br]
|
## [b]Emitter[/b] : [WorldManager][br]
|
||||||
## [b]Subscriber[/b] : [TheCube]
|
## [b]Subscriber[/b] : [TheCube]
|
||||||
|
|
@ -88,3 +88,5 @@ signal allowedTowerHasChange(allowedTowers : Array[Tower.TYPE])
|
||||||
## [b]Emitter[/b] : [WorldManager][br]
|
## [b]Emitter[/b] : [WorldManager][br]
|
||||||
## [b]Subscriber[/b] : [code]null[/code]
|
## [b]Subscriber[/b] : [code]null[/code]
|
||||||
signal waveHasChange(waveNumber : int)
|
signal waveHasChange(waveNumber : int)
|
||||||
|
|
||||||
|
@warning_ignore_restore("unused_signal")
|
||||||
|
|
|
||||||
|
|
@ -25,22 +25,29 @@ static func getColor(color : COLOR) -> Color :
|
||||||
|
|
||||||
## END COLORS ##
|
## END COLORS ##
|
||||||
|
|
||||||
const SCENE_DIR_PATTERN : String = "res://\\w+/Scenes/$"
|
const SCENE_DIR_PATTERN : String = "res://\\w+/(Scenes|Map \\d+)/$"
|
||||||
const SCENE_FILE_PATTERN : String = "([^/]*)\\.tscn$"
|
const SCENE_FILE_PATTERN : String = "([^/]*)\\.tscn$"
|
||||||
|
const RESOURCE_FILE_PATTERN : String = "([^/]*)\\.tres$"
|
||||||
|
|
||||||
const TOWER_DIR : String = "res://Towers/Scenes/"
|
const TOWER_DIR : String = "res://Towers/Scenes/"
|
||||||
const ENEMY_DIR : String = "res://Enemies/Scenes/"
|
const ENEMY_DIR : String = "res://Enemies/Scenes/"
|
||||||
|
const LEVEL_DIR : String = "res://Levels/"
|
||||||
|
|
||||||
static var towers : Dictionary
|
static var towers : Dictionary
|
||||||
static var enmies : Dictionary
|
static var enmies : Dictionary
|
||||||
|
|
||||||
|
enum RESOURCE_TYPE { TOWER, ENEMY, LEVEL }
|
||||||
|
|
||||||
static func _static_init() -> void:
|
static func _static_init() -> void:
|
||||||
preloadSceneInGlobal(towers, TOWER_DIR)
|
preloadSceneInGlobal(towers, RESOURCE_TYPE.TOWER)
|
||||||
#preloadSceneInGlobal(enemies, ENEMY_DIR)
|
#preloadSceneInGlobal(enemies, ENEMY_DIR)
|
||||||
|
|
||||||
|
|
||||||
static func preloadSceneInGlobal(property: Dictionary, path : String):
|
static func preloadSceneInGlobal(property: Dictionary, type: RESOURCE_TYPE):
|
||||||
var files : Array[String] = getFileFromDir(path, SCENE_FILE_PATTERN, SCENE_DIR_PATTERN)
|
var files : Array[String] = getPackedScenesPaths(type)
|
||||||
|
|
||||||
|
if type != RESOURCE_TYPE.TOWER:
|
||||||
|
return
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
var scene = load(file)
|
var scene = load(file)
|
||||||
|
|
@ -50,6 +57,24 @@ static func preloadSceneInGlobal(property: Dictionary, path : String):
|
||||||
property.sort()
|
property.sort()
|
||||||
|
|
||||||
|
|
||||||
|
static func getPackedScenesPaths(type: RESOURCE_TYPE) -> Array[String]:
|
||||||
|
return getFileFromDir(getDirFromType(type), SCENE_FILE_PATTERN, SCENE_DIR_PATTERN)
|
||||||
|
|
||||||
|
|
||||||
|
static func getResourcesPaths(type: RESOURCE_TYPE) -> Array[String]:
|
||||||
|
if type == RESOURCE_TYPE.LEVEL:
|
||||||
|
return getFileFromDir(getDirFromType(type), RESOURCE_FILE_PATTERN, LEVEL_DIR)
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
static func getDirFromType(type: RESOURCE_TYPE) -> String:
|
||||||
|
match type:
|
||||||
|
RESOURCE_TYPE.TOWER: return TOWER_DIR
|
||||||
|
RESOURCE_TYPE.ENEMY: return ENEMY_DIR
|
||||||
|
RESOURCE_TYPE.LEVEL: return LEVEL_DIR
|
||||||
|
_: return ""
|
||||||
|
|
||||||
|
|
||||||
static func getFileFromDir(path : String, regexPattern : String, pathRegexPattern : String = "") -> Array[String]:
|
static func getFileFromDir(path : String, regexPattern : String, pathRegexPattern : String = "") -> Array[String]:
|
||||||
var files : Array[String]
|
var files : Array[String]
|
||||||
var regex : RegEx = RegEx.create_from_string(regexPattern)
|
var regex : RegEx = RegEx.create_from_string(regexPattern)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ metadata/_custom_type_script = "uid://chu8s12rtdeqx"
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_qfjse"]
|
[sub_resource type="Resource" id="Resource_qfjse"]
|
||||||
script = ExtResource("3_ub8wd")
|
script = ExtResource("3_ub8wd")
|
||||||
enemy = "uid://1kwye5yjf40d"
|
enemy = "res://Enemies/Scenes/enemy-a.tscn"
|
||||||
number_to_spawn = 3
|
number_to_spawn = 3
|
||||||
lane_to_spawn = 0
|
lane_to_spawn = 0
|
||||||
spawn_delay = 5.0
|
spawn_delay = 5.0
|
||||||
|
|
|
||||||
|
|
@ -5,55 +5,54 @@ const PACK_DELAY : float = .15
|
||||||
|
|
||||||
var level : Level
|
var level : Level
|
||||||
var paths : Array[Node]
|
var paths : Array[Node]
|
||||||
var current_wave : Wave
|
|
||||||
var current_troop : Troop
|
|
||||||
|
|
||||||
var enemies_to_spawn : int = 0
|
|
||||||
var wave : int = 0
|
var wave : int = 0
|
||||||
var enemies_alive : int = 0
|
var currentTroopIdx : int = 0
|
||||||
|
var currentTroop : Troop :
|
||||||
var selected_collider : CollisionObject3D
|
get():
|
||||||
var troopTimer : Timer = Timer.new()
|
return level.waves[wave - 1].troops[currentTroopIdx]
|
||||||
|
var enemiesAlive : int = 0
|
||||||
|
@onready var troopTimer : Timer = $TroopTimer
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
EventBus.projectile_shooted.connect(onProjectileShooted)
|
EventBus.projectile_shooted.connect(onProjectileShooted)
|
||||||
troopTimer.one_shot = true
|
|
||||||
troopTimer.timeout.connect(spawn_troop)
|
|
||||||
add_child(troopTimer)
|
|
||||||
EventBus.player_defeated.connect(queue_free)
|
EventBus.player_defeated.connect(queue_free)
|
||||||
|
|
||||||
|
|
||||||
func onProjectileShooted(projectile : Projectile) -> void:
|
func onProjectileShooted(projectile: Projectile, startPosition: Vector3) -> void:
|
||||||
add_child(projectile)
|
add_child(projectile)
|
||||||
|
projectile.global_position = startPosition
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if wave > 0 || level && level.auto_start:
|
if wave > 0 || level && level.auto_start:
|
||||||
spawn_manager()
|
spawnManager()
|
||||||
|
|
||||||
|
|
||||||
func spawn_next_wave() -> void:
|
func spawnNextWave() -> void:
|
||||||
if level.waves.is_empty():
|
if wave == level.waves.size() && currentTroopIdx == level.waves[wave - 1].troops.size():
|
||||||
EventBus.player_has_won.emit()
|
EventBus.player_has_won.emit()
|
||||||
queue_free.call_deferred()
|
queue_free.call_deferred()
|
||||||
return
|
return
|
||||||
|
|
||||||
current_wave = level.waves.pop_front()
|
currentTroopIdx = 0
|
||||||
wave += 1
|
wave += 1
|
||||||
EventBus.waveHasChange.emit(wave)
|
EventBus.waveHasChange.emit(wave)
|
||||||
|
|
||||||
|
|
||||||
func spawn_troop() -> void:
|
func spawnTroop() -> void:
|
||||||
var enemyScene : PackedScene = load(current_troop.enemy)
|
var enemyScene : PackedScene = load(currentTroop.enemy)
|
||||||
for n in current_troop.number_to_spawn:
|
var totalDelay : float = 0
|
||||||
spawnEnemy(enemyScene, n * PACK_DELAY)
|
for n in currentTroop.number_to_spawn:
|
||||||
|
spawnEnemy(enemyScene, currentTroop.lane_to_spawn, totalDelay)
|
||||||
|
totalDelay += PACK_DELAY
|
||||||
|
|
||||||
|
currentTroopIdx += 1
|
||||||
|
|
||||||
|
|
||||||
func spawnEnemy(enemyScene : PackedScene, delay : float) -> void:
|
func spawnEnemy(enemyScene: PackedScene, laneToSpawn: int, delay: float) -> void:
|
||||||
var enemy : PathFollow3D = createEnemy(enemyScene)
|
var enemy : PathFollow3D = createEnemy(enemyScene)
|
||||||
# DANGER this var is needed for timer callback
|
|
||||||
var laneToSpawn : int = current_troop.lane_to_spawn
|
|
||||||
|
|
||||||
if delay > 0:
|
if delay > 0:
|
||||||
var enemyTimer : Timer = createTimer(delay)
|
var enemyTimer : Timer = createTimer(delay)
|
||||||
|
|
@ -66,41 +65,38 @@ func spawnEnemy(enemyScene : PackedScene, delay : float) -> void:
|
||||||
else:
|
else:
|
||||||
paths[laneToSpawn].add_child(enemy)
|
paths[laneToSpawn].add_child(enemy)
|
||||||
|
|
||||||
enemies_alive += 1
|
enemiesAlive += 1
|
||||||
|
|
||||||
|
|
||||||
func createEnemy(enemyScene : PackedScene) -> PathFollow3D :
|
func createEnemy(enemyScene: PackedScene) -> PathFollow3D :
|
||||||
var PF3D : PathFollow3D = enemyScene.instantiate()
|
var PF3D : PathFollow3D = enemyScene.instantiate()
|
||||||
var enemy : Enemy = PF3D.find_children("*", "Enemy")[0]
|
var enemy : Enemy = PF3D.find_children("*", "Enemy")[0]
|
||||||
enemy.died.connect(func(): enemies_alive -= 1)
|
enemy.died.connect(func(): enemiesAlive -= 1)
|
||||||
|
|
||||||
return PF3D
|
return PF3D
|
||||||
|
|
||||||
|
|
||||||
func spawn_manager() -> void:
|
func spawnManager() -> void:
|
||||||
if not troopTimer.is_stopped():
|
if not troopTimer.is_stopped():
|
||||||
return
|
return
|
||||||
|
|
||||||
if not current_wave || enemies_alive == 0 && current_wave.troops.is_empty():
|
var current_wave : Wave = level.waves[wave - 1]
|
||||||
spawn_next_wave()
|
if current_wave.troops.size() < currentTroopIdx + 1:
|
||||||
|
if enemiesAlive == 0:
|
||||||
|
spawnNextWave()
|
||||||
return
|
return
|
||||||
|
|
||||||
current_troop = current_wave.troops.pop_front()
|
if currentTroop.spawn_delay == 0:
|
||||||
|
spawnTroop()
|
||||||
if not current_troop:
|
|
||||||
return
|
|
||||||
|
|
||||||
if current_troop.spawn_delay == 0:
|
|
||||||
spawn_troop()
|
|
||||||
else:
|
else:
|
||||||
troopTimer.start(current_troop.spawn_delay)
|
troopTimer.start(currentTroop.spawn_delay)
|
||||||
|
|
||||||
|
|
||||||
func createTimer(delay : float, oneShot = true, autoStart = true) -> Timer :
|
func createTimer(delay: float) -> Timer :
|
||||||
var timer : Timer = Timer.new()
|
var timer : Timer = Timer.new()
|
||||||
timer.wait_time = delay
|
timer.wait_time = delay
|
||||||
timer.one_shot = oneShot
|
timer.one_shot = true
|
||||||
timer.autostart = autoStart
|
timer.autostart = true
|
||||||
|
|
||||||
return timer
|
return timer
|
||||||
|
|
||||||
|
|
@ -110,5 +106,5 @@ func addMap(mapScene : PackedScene) -> void:
|
||||||
add_child(map)
|
add_child(map)
|
||||||
level = map.level
|
level = map.level
|
||||||
paths = map.paths.get_children()
|
paths = map.paths.get_children()
|
||||||
EventBus.allowedTowerHasChange.emit.call_deferred(level.allowedTowers)
|
EventBus.allowedTowerHasChange.emit(level.allowedTowers)
|
||||||
spawn_next_wave.call_deferred()
|
spawnNextWave()
|
||||||
|
|
|
||||||
|
|
@ -95,3 +95,8 @@ light_energy = 0.0
|
||||||
[node name="GUI" parent="CanvasLayer" instance=ExtResource("6_ebgat")]
|
[node name="GUI" parent="CanvasLayer" instance=ExtResource("6_ebgat")]
|
||||||
|
|
||||||
[node name="Towers" type="Node3D" parent="."]
|
[node name="Towers" type="Node3D" parent="."]
|
||||||
|
|
||||||
|
[node name="TroopTimer" type="Timer" parent="."]
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[connection signal="timeout" from="TroopTimer" to="." method="spawnTroop"]
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ var affectedTarget : Array[Enemy]
|
||||||
var allyInRange : Array[Tower]
|
var allyInRange : Array[Tower]
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
if !is_instance_valid(target) && type != TYPE.PIERCING || vectorTarget.distance_squared_to(global_position) < .4:
|
if !is_instance_valid(target) && type != TYPE.PIERCING || vectorTarget.distance_squared_to(global_position) < .4:
|
||||||
queue_free()
|
queue_free()
|
||||||
return
|
return
|
||||||
|
|
@ -57,11 +57,8 @@ func onBodyCollideWithProjectile(body: Node3D) -> void:
|
||||||
|
|
||||||
|
|
||||||
func targetable(body: Node3D) -> bool:
|
func targetable(body: Node3D) -> bool:
|
||||||
if affectedTarget.has(body):
|
|
||||||
return false
|
|
||||||
|
|
||||||
if body is Enemy:
|
if body is Enemy:
|
||||||
return TARGET_ENEMY & allowedTargets
|
return TARGET_ENEMY & allowedTargets && not affectedTarget.has(body)
|
||||||
if body is Tower:
|
if body is Tower:
|
||||||
return TARGET_ALLY & allowedTargets
|
return TARGET_ALLY & allowedTargets
|
||||||
|
|
||||||
|
|
@ -83,7 +80,6 @@ func resolveDamages(body: Node3D) -> void:
|
||||||
enemiesInRange.erase(body)
|
enemiesInRange.erase(body)
|
||||||
if enemiesInRange.size():
|
if enemiesInRange.size():
|
||||||
target = enemiesInRange.pop_front()
|
target = enemiesInRange.pop_front()
|
||||||
vectorTarget = target.global_position
|
|
||||||
else:
|
else:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
@ -96,9 +92,8 @@ func damageEnemy(enemy: Enemy) -> void:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func loadProjectile(resource: ProjectileResource, startPosition: Vector3, _target: PhysicsBody3D) -> void:
|
func loadProjectile(resource: ProjectileResource, _target: PhysicsBody3D) -> void:
|
||||||
target = _target
|
target = _target
|
||||||
global_position = startPosition
|
|
||||||
type = resource.type
|
type = resource.type
|
||||||
if type == TYPE.PIERCING:
|
if type == TYPE.PIERCING:
|
||||||
vectorTarget = target.global_position
|
vectorTarget = target.global_position
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func _ready() -> void:
|
||||||
$Cooldown.wait_time = action_cooldown
|
$Cooldown.wait_time = action_cooldown
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if is_rest:
|
if is_rest:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -112,8 +112,8 @@ func shoot() -> void:
|
||||||
energy -= energy_cost
|
energy -= energy_cost
|
||||||
|
|
||||||
var projectile : Projectile = projectileScene.instantiate()
|
var projectile : Projectile = projectileScene.instantiate()
|
||||||
projectile.loadProjectile(projectileRessource, $Aim.global_position, current)
|
projectile.loadProjectile(projectileRessource, current)
|
||||||
EventBus.projectile_shooted.emit(projectile)
|
EventBus.projectile_shooted.emit(projectile, $Aim.global_position)
|
||||||
|
|
||||||
|
|
||||||
func resting() -> void:
|
func resting() -> void:
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ func _ready() -> void:
|
||||||
EventBus.cube_ready.connect(func(value): the_cube = value)
|
EventBus.cube_ready.connect(func(value): the_cube = value)
|
||||||
#$AnimationPlayer.play("arrow_bobbing")
|
#$AnimationPlayer.play("arrow_bobbing")
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
handle_player_controls()
|
handle_player_controls()
|
||||||
if Input.is_action_just_pressed("build"):
|
if Input.is_action_just_pressed("build"):
|
||||||
if not selected_collider:
|
if not selected_collider:
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ const BUTTON_QTY = 12
|
||||||
const guiButton : PackedScene = preload("res://UI/gui_button.tscn")
|
const guiButton : PackedScene = preload("res://UI/gui_button.tscn")
|
||||||
|
|
||||||
@onready var buttonContainer = %ButtonContainer
|
@onready var buttonContainer = %ButtonContainer
|
||||||
|
@onready var moneyLabel = %LabelMoney
|
||||||
|
@onready var towerInCubeLabel = %LabelTowerInCube
|
||||||
|
@onready var towerOnTerrainLabel = %LabelTowerOnTerrain
|
||||||
|
|
||||||
var allowedTowers : Array[Tower.TYPE]
|
var allowedTowers : Array[Tower.TYPE]
|
||||||
|
|
||||||
|
|
@ -13,6 +16,9 @@ var allowedTowers : Array[Tower.TYPE]
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
addTowerButtonNodes()
|
addTowerButtonNodes()
|
||||||
EventBus.allowedTowerHasChange.connect(allowedTowerHasChange)
|
EventBus.allowedTowerHasChange.connect(allowedTowerHasChange)
|
||||||
|
EventBus.money_changed.connect(func(amount): moneyLabel.text = str(amount) + " €")
|
||||||
|
EventBus.team_in_rest_changed.connect(func(count): towerInCubeLabel.text = str(count) + " x Zzz")
|
||||||
|
EventBus.team_in_action_changed.connect(func(count): towerOnTerrainLabel.text = str(count) + " in action")
|
||||||
|
|
||||||
|
|
||||||
func _on_button_cube_pressed() -> void:
|
func _on_button_cube_pressed() -> void:
|
||||||
|
|
|
||||||
15
UI/gui.tscn
15
UI/gui.tscn
|
|
@ -1,10 +1,7 @@
|
||||||
[gd_scene load_steps=16 format=3 uid="uid://p6a6rb7sgeqd"]
|
[gd_scene load_steps=13 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://c350dletl5pde" path="res://UI/label_tower_in_cube.gd" id="2_6ujs1"]
|
|
||||||
[ext_resource type="Script" uid="uid://bhylcok1l6eke" path="res://UI/gui.gd" id="2_sac4j"]
|
[ext_resource type="Script" uid="uid://bhylcok1l6eke" path="res://UI/gui.gd" id="2_sac4j"]
|
||||||
[ext_resource type="Script" uid="uid://dmcgoepvytnn" path="res://UI/cube_integrity.gd" id="2_sj6ny"]
|
[ext_resource type="Script" uid="uid://dmcgoepvytnn" path="res://UI/cube_integrity.gd" id="2_sj6ny"]
|
||||||
[ext_resource type="Script" uid="uid://kngsgirej7lx" path="res://UI/label_tower_on_terrain.gd" id="3_wg577"]
|
|
||||||
[ext_resource type="Theme" uid="uid://bbp4qcbwkeg7x" path="res://default_theme.tres" id="5_wpcnu"]
|
[ext_resource type="Theme" uid="uid://bbp4qcbwkeg7x" path="res://default_theme.tres" id="5_wpcnu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://csl43eb7qjhe4" path="res://Assets/Icones/dog-house.svg" id="7_fffne"]
|
[ext_resource type="Texture2D" uid="uid://csl43eb7qjhe4" path="res://Assets/Icones/dog-house.svg" id="7_fffne"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dqb5o8w7u50hc" path="res://UI/gui_button.tscn" id="7_parkk"]
|
[ext_resource type="PackedScene" uid="uid://dqb5o8w7u50hc" path="res://UI/gui_button.tscn" id="7_parkk"]
|
||||||
|
|
@ -70,6 +67,7 @@ theme_override_constants/margin_bottom = 10
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="LabelMoney" type="Label" parent="HBoxContainer/InfoPanel/MarginContainer/VBoxContainer"]
|
[node name="LabelMoney" type="Label" parent="HBoxContainer/InfoPanel/MarginContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
tooltip_text = "La thune."
|
tooltip_text = "La thune."
|
||||||
|
|
@ -78,25 +76,24 @@ theme_override_colors/font_color = Color(0.2, 0.2, 0.2, 1)
|
||||||
text = "1'000'000 €"
|
text = "1'000'000 €"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
vertical_alignment = 2
|
vertical_alignment = 2
|
||||||
script = ExtResource("1_cwd3r")
|
|
||||||
|
|
||||||
[node name="LabelTowerInCube" type="Label" parent="HBoxContainer/InfoPanel/MarginContainer/VBoxContainer"]
|
[node name="LabelTowerInCube" type="Label" parent="HBoxContainer/InfoPanel/MarginContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Le nombre de héros disponible dans le cube !"
|
tooltip_text = "Le nombre de héros disponible dans le cube !"
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
theme_override_colors/font_color = Color(0.2, 0.2, 0.2, 1)
|
theme_override_colors/font_color = Color(0.2, 0.2, 0.2, 1)
|
||||||
text = "0"
|
text = "0"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
script = ExtResource("2_6ujs1")
|
|
||||||
|
|
||||||
[node name="LabelTowerOnTerrain" type="Label" parent="HBoxContainer/InfoPanel/MarginContainer/VBoxContainer"]
|
[node name="LabelTowerOnTerrain" type="Label" parent="HBoxContainer/InfoPanel/MarginContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
tooltip_text = "Le nombre de héros en action sur le terrain !"
|
tooltip_text = "Le nombre de héros en action sur le terrain !"
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
theme_override_colors/font_color = Color(0.2, 0.2, 0.2, 1)
|
theme_override_colors/font_color = Color(0.2, 0.2, 0.2, 1)
|
||||||
text = "0"
|
text = "0"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
script = ExtResource("3_wg577")
|
|
||||||
|
|
||||||
[node name="CubeIntegrity" type="ProgressBar" parent="HBoxContainer"]
|
[node name="CubeIntegrity" type="ProgressBar" parent="HBoxContainer"]
|
||||||
custom_minimum_size = Vector2(10, 5)
|
custom_minimum_size = Vector2(10, 5)
|
||||||
|
|
@ -139,22 +136,18 @@ columns = 4
|
||||||
|
|
||||||
[node name="CubeBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
[node name="CubeBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
hasEnergyBar = false
|
|
||||||
texture = ExtResource("7_fffne")
|
texture = ExtResource("7_fffne")
|
||||||
|
|
||||||
[node name="QuitLevelBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
[node name="QuitLevelBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
hasEnergyBar = false
|
|
||||||
texture = ExtResource("8_decjp")
|
texture = ExtResource("8_decjp")
|
||||||
|
|
||||||
[node name="QuitGameBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
[node name="QuitGameBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
hasEnergyBar = false
|
|
||||||
texture = ExtResource("9_reygo")
|
texture = ExtResource("9_reygo")
|
||||||
|
|
||||||
[node name="ReturnBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
[node name="ReturnBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
hasEnergyBar = false
|
|
||||||
texture = ExtResource("8_ay13l")
|
texture = ExtResource("8_ay13l")
|
||||||
|
|
||||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer/CubeBtn" to="." method="_on_button_cube_pressed"]
|
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer/CubeBtn" to="." method="_on_button_cube_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,9 @@ var towerType : Tower.TYPE :
|
||||||
set(value):
|
set(value):
|
||||||
towerType = value
|
towerType = value
|
||||||
if towerType != Tower.TYPE.NONE:
|
if towerType != Tower.TYPE.NONE:
|
||||||
EventBus.energy_has_changed.connect(changeEnergy)
|
EventBus.energy_has_changed.connect(towerChanged)
|
||||||
EventBus.tower_builded.connect(towerChanged)
|
EventBus.tower_builded.connect(towerChanged)
|
||||||
|
EventBus.tower_selected.connect(func(type): set_pressed_no_signal(type == towerType))
|
||||||
|
|
||||||
|
|
||||||
@export var hasEnergyBar : bool = false :
|
@export var hasEnergyBar : bool = false :
|
||||||
|
|
@ -26,11 +27,7 @@ func buttonToggled(state : bool) -> void:
|
||||||
EventBus.tower_selected.emit(towerType if state else Tower.TYPE.NONE)
|
EventBus.tower_selected.emit(towerType if state else Tower.TYPE.NONE)
|
||||||
|
|
||||||
|
|
||||||
func changeEnergy(tower : Tower) -> void:
|
|
||||||
if tower.tower_type == towerType:
|
|
||||||
$EnergyBar.value = tower.energy
|
|
||||||
|
|
||||||
|
|
||||||
func towerChanged(tower : Tower) -> void :
|
func towerChanged(tower : Tower) -> void :
|
||||||
if tower.tower_type == towerType:
|
if tower.tower_type == towerType:
|
||||||
|
$EnergyBar.value = tower.energy
|
||||||
$EnergyBar.max_value = tower.max_energy
|
$EnergyBar.max_value = tower.max_energy
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ size_flags_vertical = 4
|
||||||
tooltip_text = "Sélectionner Pierre"
|
tooltip_text = "Sélectionner Pierre"
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
script = ExtResource("1_snobr")
|
script = ExtResource("1_snobr")
|
||||||
hasEnergyBar = null
|
|
||||||
metadata/_custom_type_script = "uid://dyhtr6g7kd1g2"
|
metadata/_custom_type_script = "uid://dyhtr6g7kd1g2"
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="."]
|
[node name="TextureRect" type="TextureRect" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
extends Label
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
EventBus.money_changed.connect(_on_EventBus_money_changed)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_EventBus_money_changed(_value) -> void:
|
|
||||||
set_text(str(_value) + " €")
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://d2x8oy4os7ysn
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
extends Label
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
EventBus.tower_count_changed.connect(_on_EventBus_tower_count_changed)
|
|
||||||
EventBus.team_in_action_changed.connect(_on_EventBus_team_in_action_changed)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_EventBus_tower_count_changed(_value : int) -> void:
|
|
||||||
var _text = text.rsplit("/")
|
|
||||||
_text[1] = str(_value)
|
|
||||||
text = _text[0] + "/" + _text[1]
|
|
||||||
|
|
||||||
func _on_EventBus_team_in_action_changed(_value : int) -> void:
|
|
||||||
var _text = text.rsplit("/")
|
|
||||||
_text[0] = str(_value)
|
|
||||||
text = _text[0] + "/" + _text[1]
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://bigr38rqr01sb
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
extends Label
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
EventBus.team_in_rest_changed.connect(_on_EventBus_team_in_rest_changed)
|
|
||||||
|
|
||||||
func _on_EventBus_team_in_rest_changed(_value : int) -> void:
|
|
||||||
text = str(_value)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://c350dletl5pde
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
extends Label
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
EventBus.team_in_action_changed.connect(_on_EventBus_team_in_action_changed)
|
|
||||||
|
|
||||||
func _on_EventBus_team_in_action_changed(_value : int) -> void:
|
|
||||||
text = str(_value)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://kngsgirej7lx
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
extends Button
|
|
||||||
class_name LevelButton
|
|
||||||
|
|
||||||
@export_file("*.tscn") var level : String
|
|
||||||
|
|
||||||
func _on_pressed() -> void:
|
|
||||||
Transition.gotoLevel(level)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://cudalakmyqm04
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://88elnilxithv"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cudalakmyqm04" path="res://UI/level_button.gd" id="1_k6cd2"]
|
|
||||||
[ext_resource type="Theme" uid="uid://bbp4qcbwkeg7x" path="res://default_theme.tres" id="1_rdmfi"]
|
|
||||||
|
|
||||||
[node name="Level1Button" type="Button"]
|
|
||||||
theme = ExtResource("1_rdmfi")
|
|
||||||
text = "Level 1"
|
|
||||||
script = ExtResource("1_k6cd2")
|
|
||||||
|
|
||||||
[connection signal="pressed" from="." to="." method="_on_pressed"]
|
|
||||||
|
|
@ -1,5 +1,20 @@
|
||||||
|
@tool
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
var levels : Array[String]
|
||||||
|
|
||||||
|
|
||||||
func _on_quit_button_pressed() -> void:
|
func _on_quit_button_pressed() -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
%LevelContainer.get_children().map(%LevelContainer.remove_child)
|
||||||
|
levels = Game.getPackedScenesPaths(Game.RESOURCE_TYPE.LEVEL)
|
||||||
|
for i in levels.size():
|
||||||
|
var levelButton : Button = Button.new()
|
||||||
|
levelButton.text = "Level " + str(i + 1)
|
||||||
|
%LevelContainer.add_child(levelButton)
|
||||||
|
if not Engine.is_editor_hint():
|
||||||
|
levelButton.pressed.connect(Transition.gotoLevel.bind(levels[i]))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
[gd_scene load_steps=11 format=3 uid="uid://2xw1yn1tmlcy"]
|
[gd_scene load_steps=10 format=3 uid="uid://2xw1yn1tmlcy"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://88elnilxithv" path="res://UI/level_button.tscn" id="1_dl586"]
|
|
||||||
[ext_resource type="Script" uid="uid://dqtxbncmls4tu" path="res://UI/start_menu.gd" id="1_neu3s"]
|
[ext_resource type="Script" uid="uid://dqtxbncmls4tu" path="res://UI/start_menu.gd" id="1_neu3s"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c6hg12tui8344" path="res://VFX/pixel_rain.tscn" id="1_q5qyg"]
|
[ext_resource type="PackedScene" uid="uid://c6hg12tui8344" path="res://VFX/pixel_rain.tscn" id="1_q5qyg"]
|
||||||
[ext_resource type="Shader" uid="uid://c31b4mkeyaqhy" path="res://Assets/Shaders/transition.gdshader" id="1_yqwmv"]
|
[ext_resource type="Shader" uid="uid://c31b4mkeyaqhy" path="res://Assets/Shaders/transition.gdshader" id="1_yqwmv"]
|
||||||
|
|
@ -48,6 +47,7 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
theme = ExtResource("6_rcgl7")
|
||||||
script = ExtResource("1_neu3s")
|
script = ExtResource("1_neu3s")
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D" parent="."]
|
[node name="Node2D" type="Node2D" parent="."]
|
||||||
|
|
@ -206,19 +206,10 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme_override_constants/separation = 20
|
theme_override_constants/separation = 20
|
||||||
|
|
||||||
[node name="Level1Button" parent="Middleground/VBoxContainer" instance=ExtResource("1_dl586")]
|
[node name="LevelContainer" type="GridContainer" parent="Middleground/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
level = "uid://gp46cl8euhyf"
|
columns = 6
|
||||||
|
|
||||||
[node name="Level2Button" parent="Middleground/VBoxContainer" instance=ExtResource("1_dl586")]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Level 2"
|
|
||||||
level = "uid://cb56hwohi3ay8"
|
|
||||||
|
|
||||||
[node name="Level3Button" parent="Middleground/VBoxContainer" instance=ExtResource("1_dl586")]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Level 3"
|
|
||||||
level = "uid://bnruh81ego1j6"
|
|
||||||
|
|
||||||
[node name="QuitButton" type="Button" parent="Middleground/VBoxContainer"]
|
[node name="QuitButton" type="Button" parent="Middleground/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ func _ready() -> void:
|
||||||
$Timer.start()
|
$Timer.start()
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
velocity.y = speed
|
velocity.y = speed
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@
|
||||||
extends OptionButton
|
extends OptionButton
|
||||||
class_name CustomOptionButton
|
class_name CustomOptionButton
|
||||||
|
|
||||||
|
|
||||||
signal onValueChanged(value : String)
|
signal onValueChanged(value : String)
|
||||||
|
|
||||||
|
|
||||||
var selectedValue : String
|
var selectedValue : String
|
||||||
var options : Dictionary
|
var options : Dictionary
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,17 @@
|
||||||
extends Control
|
extends Control
|
||||||
class_name WaveMaker
|
class_name WaveMaker
|
||||||
|
|
||||||
|
|
||||||
signal spawnQtyChanged(newQty : int)
|
signal spawnQtyChanged(newQty : int)
|
||||||
|
|
||||||
const LEVEL_PATH : String = "res://Levels/"
|
|
||||||
const LEVEL_REGEX_PATERN : String = "(level_.*)\\.tres$"
|
|
||||||
const LEVEL_PATH_REGEX_PATERN : String = "res://Levels/[^/]*/$"
|
|
||||||
|
|
||||||
const ENEMY_PATH : String = "res://Enemies/Scenes/"
|
|
||||||
const ENEMY_REGEX_PATERN : String = "(enemy.*)\\.tscn$"
|
|
||||||
|
|
||||||
const TROOP_SCENE = preload("res://addons/LevelEditor/UI/Troop/Troop.tscn")
|
const TROOP_SCENE = preload("res://addons/LevelEditor/UI/Troop/Troop.tscn")
|
||||||
|
|
||||||
const space_multiplicator : int = 10
|
|
||||||
enum DIRECTION { UP, DOWN, TOP, LEFT, VERTICAL, HORIZONTAL}
|
|
||||||
|
|
||||||
|
var level : Level
|
||||||
var enemies : Dictionary
|
var enemies : Dictionary
|
||||||
|
var currentWave : int = -1
|
||||||
|
|
||||||
|
|
||||||
@onready var autoLaunchLevel : CheckButton = $VBC/HBC3/AutoLaunchLevel
|
@onready var autoLaunchLevel : CheckButton = $VBC/HBC3/AutoLaunchLevel
|
||||||
@onready var levelSelect : CustomOptionButton = $VBC/HBC/LevelSelect
|
@onready var levelSelect : CustomOptionButton = $VBC/HBC/LevelSelect
|
||||||
|
|
@ -24,9 +20,6 @@ var enemies : Dictionary
|
||||||
@onready var waveTabContainer : TabContainer = $VBC/ScrollContainer/WaveContainer
|
@onready var waveTabContainer : TabContainer = $VBC/ScrollContainer/WaveContainer
|
||||||
@onready var towerSelector : ItemList = $VBC/HBC5/TowerSelector
|
@onready var towerSelector : ItemList = $VBC/HBC5/TowerSelector
|
||||||
|
|
||||||
var level : Level
|
|
||||||
var currentWave : int = -1
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
resetApp()
|
resetApp()
|
||||||
|
|
@ -144,9 +137,8 @@ func cleanAndBuildMenu() -> void:
|
||||||
|
|
||||||
|
|
||||||
func resetApp() -> void:
|
func resetApp() -> void:
|
||||||
enemies = getOptionsFromFile(ENEMY_PATH, ENEMY_REGEX_PATERN)
|
enemies = getOptionsFromFile(Game.RESOURCE_TYPE.ENEMY)
|
||||||
print(enemies)
|
levelSelect.setOptions(getOptionsFromFile(Game.RESOURCE_TYPE.LEVEL))
|
||||||
levelSelect.setOptions(getOptionsFromFile(LEVEL_PATH, LEVEL_REGEX_PATERN, LEVEL_PATH_REGEX_PATERN))
|
|
||||||
cleanAndBuildMenu()
|
cleanAndBuildMenu()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -193,10 +185,14 @@ func _on_auto_launch_wave_toggled(toggled_on: bool) -> void:
|
||||||
level.auto_start = toggled_on
|
level.auto_start = toggled_on
|
||||||
|
|
||||||
|
|
||||||
|
## [color=red][b]DANGER :[/b] NOT READY WITH THE NEW PATH SYSTEM[/color][br]
|
||||||
|
## If you want to use the level maker create manually a [code].tres[/code] file in Level folder
|
||||||
|
## and click on the resfresh button
|
||||||
func _on_new_level_pressed() -> void:
|
func _on_new_level_pressed() -> void:
|
||||||
|
return
|
||||||
level = Level.new()
|
level = Level.new()
|
||||||
var levelName = "level_" + str(levelSelect.item_count + 1)
|
var levelName = "level_" + str(levelSelect.item_count + 1)
|
||||||
levelSelect.addOption(LEVEL_PATH + "/" + levelName + ".tres", levelName, true)
|
levelSelect.addOption(Game.LEVEL_DIR + levelName + ".tres", levelName, true)
|
||||||
_on_save_pressed()
|
_on_save_pressed()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -213,11 +209,18 @@ func onSelectedTowerChange(index: int, selected: int) -> void:
|
||||||
level.allowedTowers.erase(index)
|
level.allowedTowers.erase(index)
|
||||||
|
|
||||||
|
|
||||||
func getOptionsFromFile(path : String, regexPattern : String, pathRegexPattern : String = "") -> Dictionary :
|
func getOptionsFromFile(type: Game.RESOURCE_TYPE) -> Dictionary :
|
||||||
var files : Dictionary
|
var files : Dictionary
|
||||||
var filePaths : Array[String] = Game.getFileFromDir(path, regexPattern, pathRegexPattern)
|
var filePaths : Array[String]
|
||||||
var regex : RegEx = RegEx.create_from_string(regexPattern)
|
var pattern : String
|
||||||
|
if type == Game.RESOURCE_TYPE.LEVEL:
|
||||||
|
filePaths = Game.getResourcesPaths(type)
|
||||||
|
pattern = Game.RESOURCE_FILE_PATTERN
|
||||||
|
else:
|
||||||
|
filePaths = Game.getPackedScenesPaths(type)
|
||||||
|
pattern = Game.SCENE_FILE_PATTERN
|
||||||
|
|
||||||
|
var regex : RegEx = RegEx.create_from_string(pattern)
|
||||||
for file in filePaths:
|
for file in filePaths:
|
||||||
var fileMatch : RegExMatch = regex.search(file)
|
var fileMatch : RegExMatch = regex.search(file)
|
||||||
files.set(fileMatch.strings[1], file)
|
files.set(fileMatch.strings[1], file)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ script = ExtResource("2_xjxpq")
|
||||||
metadata/_custom_type_script = "uid://b47p2u458hsn0"
|
metadata/_custom_type_script = "uid://b47p2u458hsn0"
|
||||||
|
|
||||||
[node name="NewLevel" type="Button" parent="VBC/HBC"]
|
[node name="NewLevel" type="Button" parent="VBC/HBC"]
|
||||||
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Nouveau Niveau"
|
text = "Nouveau Niveau"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue