clean + refactor: change file organization + remove useless things
This commit is contained in:
parent
0b32dc7c3c
commit
1accc24fdb
81 changed files with 686 additions and 755 deletions
|
|
@ -10,25 +10,6 @@ func arrayValueChanged(value : Array[Variant], resourceToCreate : Callable) -> A
|
|||
return value
|
||||
|
||||
|
||||
static func getFileFromDir(path : String, regexPattern : String, pathRegexPattern : String = "") -> Array[String]:
|
||||
var files : Array[String]
|
||||
var regex : RegEx = RegEx.create_from_string(regexPattern)
|
||||
var pathRegex : RegEx = RegEx.create_from_string(pathRegexPattern)
|
||||
var dir : DirAccess = DirAccess.open(path)
|
||||
|
||||
if pathRegexPattern:
|
||||
for subDir in dir.get_directories():
|
||||
subDir = path + subDir + "/"
|
||||
if pathRegex.search(subDir):
|
||||
files.append_array(getFileFromDir(subDir, regexPattern, pathRegexPattern))
|
||||
|
||||
for file in dir.get_files():
|
||||
if regex.search(file) && pathRegex.search(path):
|
||||
files.append(path + file)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
static func getPackedSceneProperty(scene : PackedScene, propertyName : String) -> Variant:
|
||||
var idx : int = scene._bundled.names.find(propertyName)
|
||||
if idx != -1:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
extends Node
|
||||
|
||||
|
||||
## [b]Emitter[/b] : [method TowerButton._ready][br]
|
||||
## [b]Emitter[/b] : [method GuiButton._ready][br]
|
||||
## [b]Subscriber[/b] : [method TowerManager._init]
|
||||
signal tower_selected(towerType : Tower.TYPE)
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ signal open_shop()
|
|||
signal close_shop()
|
||||
|
||||
## [b]Emitter[/b] : [Tower][br]
|
||||
## [b]Subscriber[/b] : [TowerButton]
|
||||
## [b]Subscriber[/b] : [GuiButton]
|
||||
signal energy_has_changed(tower : Tower)
|
||||
|
||||
## [b]Emitter[/b] : [WorldManager], [Level][br]
|
||||
|
|
|
|||
69
Globals/Game.gd
Normal file
69
Globals/Game.gd
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
class_name Game
|
||||
|
||||
|
||||
## COLORS ##
|
||||
|
||||
|
||||
enum COLOR { HEALTH, ENERGY, SELECTED, SECONDARY }
|
||||
|
||||
|
||||
const COLOR_HEALTH : Color = Color(0.921569, 0.419608, 0.415686, 1)
|
||||
const COLOR_ENERGY : Color = Color(0.921569, 0.890196, 0.415686, 1)
|
||||
const COLOR_SELECTED : Color = Color(0.721569, 0.600196, 0.355686, 1)
|
||||
const COLOR_SECONDARY : Color = Color(0.341, 0.082, 0.094, 0.0)
|
||||
const COLOR_FALLBACK : Color = Color(0.341176, 0.0823529, 0.0941176, 0)
|
||||
|
||||
|
||||
static func getColor(color : COLOR) -> Color :
|
||||
match color:
|
||||
COLOR.HEALTH : return COLOR_HEALTH
|
||||
COLOR.ENERGY : return COLOR_ENERGY
|
||||
COLOR.SELECTED : return COLOR_SELECTED
|
||||
COLOR.SECONDARY : return COLOR_SECONDARY
|
||||
_: return COLOR_FALLBACK
|
||||
|
||||
|
||||
## END COLORS ##
|
||||
|
||||
const SCENE_DIR_PATTERN : String = "res://\\w+/Scenes/$"
|
||||
const SCENE_FILE_PATTERN : String = "([^/]*)\\.tscn$"
|
||||
|
||||
const TOWER_DIR : String = "res://Towers/Scenes/"
|
||||
const ENEMY_DIR : String = "res://Enemies/Scenes/"
|
||||
|
||||
static var towers : Dictionary
|
||||
static var enmies : Dictionary
|
||||
|
||||
static func _static_init() -> void:
|
||||
preloadSceneInGlobal(towers, TOWER_DIR)
|
||||
#preloadSceneInGlobal(enemies, ENEMY_DIR)
|
||||
|
||||
|
||||
static func preloadSceneInGlobal(property: Dictionary, path : String):
|
||||
var files : Array[String] = getFileFromDir(path, SCENE_FILE_PATTERN, SCENE_DIR_PATTERN)
|
||||
|
||||
for file in files:
|
||||
var scene = load(file)
|
||||
if scene:
|
||||
property.set(EnhancedResource.getPackedSceneProperty(scene, "tower_type"), scene)
|
||||
|
||||
property.sort()
|
||||
|
||||
|
||||
static func getFileFromDir(path : String, regexPattern : String, pathRegexPattern : String = "") -> Array[String]:
|
||||
var files : Array[String]
|
||||
var regex : RegEx = RegEx.create_from_string(regexPattern)
|
||||
var pathRegex : RegEx = RegEx.create_from_string(pathRegexPattern)
|
||||
var dir : DirAccess = DirAccess.open(path)
|
||||
|
||||
if pathRegexPattern:
|
||||
for subDir in dir.get_directories():
|
||||
subDir = path + subDir + "/"
|
||||
if pathRegex.search(subDir):
|
||||
files.append_array(getFileFromDir(subDir, regexPattern, pathRegexPattern))
|
||||
|
||||
for file in dir.get_files():
|
||||
if regex.search(file) && pathRegex.search(path):
|
||||
files.append(path + file)
|
||||
|
||||
return files
|
||||
1
Globals/Game.gd.uid
Normal file
1
Globals/Game.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0nrg71j5ffiq
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
[sub_resource type="Resource" id="Resource_87wss"]
|
||||
script = ExtResource("3_ub8wd")
|
||||
enemy = "res://enemies/enemy-a.tscn"
|
||||
enemy = "res://Enemies/Scenes/enemy-a.tscn"
|
||||
number_to_spawn = 1
|
||||
lane_to_spawn = 0
|
||||
spawn_delay = 5.0
|
||||
|
|
@ -19,14 +19,14 @@ metadata/_custom_type_script = "uid://chu8s12rtdeqx"
|
|||
|
||||
[sub_resource type="Resource" id="Resource_qfjse"]
|
||||
script = ExtResource("3_ub8wd")
|
||||
enemy = "res://enemies/enemy-a.tscn"
|
||||
enemy = "res://Enemies/Scenes/enemy-a.tscn"
|
||||
number_to_spawn = 3
|
||||
lane_to_spawn = 0
|
||||
spawn_delay = 5.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ftl6b"]
|
||||
script = ExtResource("3_ub8wd")
|
||||
enemy = "res://enemies/enemy-a.tscn"
|
||||
enemy = "res://Enemies/Scenes/enemy-a.tscn"
|
||||
number_to_spawn = 6
|
||||
lane_to_spawn = 0
|
||||
spawn_delay = 1.0
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
[sub_resource type="Curve3D" id="Curve3D_okc5w"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 9.5, 0.5, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 9.5, 0.5, 0.5),
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 9.5, 0, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 9, 0, 0.5),
|
||||
"tilts": PackedFloat32Array(0, 0, 0, 0)
|
||||
}
|
||||
point_count = 4
|
||||
|
|
@ -279,6 +279,7 @@ transform = Transform3D(-1.31134e-07, 0, -3, 0, 3, 0, 3, 0, -1.31134e-07, 3.9764
|
|||
transform = Transform3D(-2, 0, -1.74846e-07, 0, 2, 0, 1.74846e-07, 0, -2, 9.6873, 0, -5.90881)
|
||||
|
||||
[node name="Paths" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.15, 0)
|
||||
|
||||
[node name="Path 1" type="Path3D" parent="Paths"]
|
||||
curve = SubResource("Curve3D_okc5w")
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@
|
|||
|
||||
[sub_resource type="Curve3D" id="Curve3D_fb3ox"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 9.5, 0.5, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 9.5, 0.5, 0.5),
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 9.5, 0, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 9, 0, 0.5),
|
||||
"tilts": PackedFloat32Array(0, 0, 0, 0)
|
||||
}
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="Curve3D" id="Curve3D_6idm4"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 4.5, 0.5, 8, 0, 0, 0, 0, 0, 0, 4.5, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 9.5, 0.5, 0.5),
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 4.5, 0, 8, 0, 0, 0, 0, 0, 0, 4.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 9, 0, 0.5),
|
||||
"tilts": PackedFloat32Array(0, 0, 0)
|
||||
}
|
||||
point_count = 3
|
||||
|
|
@ -350,6 +350,7 @@ transform = Transform3D(-2, 0, -1.74846e-07, 0, 2, 0, 1.74846e-07, 0, -2, 9.6873
|
|||
transform = Transform3D(-8.74228e-08, 0, -2, 0, 2, 0, 2, 0, -8.74228e-08, 5.30379, 0, 8.44393)
|
||||
|
||||
[node name="Paths" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.15, 0)
|
||||
|
||||
[node name="Path 1" type="Path3D" parent="Paths"]
|
||||
curve = SubResource("Curve3D_fb3ox")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://bnruh81ego1j6"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://bnruh81ego1j6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://baa0j457hhoeh" path="res://Levels/Scripts/Map.gd" id="1_1xj3e"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpjfo15otkfru" path="res://Tiles/cube.tscn" id="1_7jwkb"]
|
||||
|
|
@ -15,14 +15,21 @@
|
|||
|
||||
[sub_resource type="Curve3D" id="Curve3D_yagk8"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 9.5, 0.5, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 9.5, 0.5, 0.5),
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 9.5, 0, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0, -5.5, 0, 0, 0, 0, 0, 0, 0.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 9, 0, 0.5),
|
||||
"tilts": PackedFloat32Array(0, 0, 0, 0)
|
||||
}
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="Curve3D" id="Curve3D_1xj3e"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 4.5, 0, 8, 0, 0, 0, 0, 0, 0, 4.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 9, 0, 0.5),
|
||||
"tilts": PackedFloat32Array(0, 0, 0)
|
||||
}
|
||||
point_count = 3
|
||||
|
||||
[sub_resource type="Curve3D" id="Curve3D_7jwkb"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 15, 0.5, -6.5, 0, 0, 0, 0, 0, 0, 16.5, 0.5, -6.5, 0, 0, 0, 0, 0, 0, 16.5, 0.5, -2.5, 0, 0, 0, 0, 0, 0, 14.5, 0.5, -2.5, 0, 0, 0, 0, 0, 0, 14.5, 0.5, 0.5, 0, 0, 0, 0, 0, 0, 11, 0.5, 0.5),
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 15, 0, -6.5, 0, 0, 0, 0, 0, 0, 16.5, 0, -6.5, 0, 0, 0, 0, 0, 0, 16.5, 0, -2.5, 0, 0, 0, 0, 0, 0, 14.5, 0, -2.5, 0, 0, 0, 0, 0, 0, 14.5, 0, 0.5, 0, 0, 0, 0, 0, 0, 11, 0, 0.5),
|
||||
"tilts": PackedFloat32Array(0, 0, 0, 0, 0, 0)
|
||||
}
|
||||
point_count = 6
|
||||
|
|
@ -438,12 +445,13 @@ transform = Transform3D(-8.74228e-08, 0, -2, 0, 2, 0, 2, 0, -8.74228e-08, 5.3037
|
|||
transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, 13.7719, 0, -7)
|
||||
|
||||
[node name="Paths" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.15, 0)
|
||||
|
||||
[node name="Path 1" type="Path3D" parent="Paths"]
|
||||
curve = SubResource("Curve3D_yagk8")
|
||||
|
||||
[node name="Path 2" type="Path3D" parent="Paths"]
|
||||
curve = SubResource("Curve3D_7jwkb")
|
||||
curve = SubResource("Curve3D_1xj3e")
|
||||
|
||||
[node name="Path 3" type="Path3D" parent="Paths"]
|
||||
curve = SubResource("Curve3D_7jwkb")
|
||||
|
|
|
|||
|
|
@ -45,29 +45,32 @@ func spawn_next_wave() -> void:
|
|||
|
||||
|
||||
func spawn_troop() -> void:
|
||||
var enemyScene : PackedScene = load(current_troop.enemy)
|
||||
for n in current_troop.number_to_spawn:
|
||||
spawnEnemy(n * PACK_DELAY)
|
||||
spawnEnemy(enemyScene, n * PACK_DELAY)
|
||||
|
||||
|
||||
func spawnEnemy(delay : float) -> void:
|
||||
var enemy : PathFollow3D = createEnemy()
|
||||
func spawnEnemy(enemyScene : PackedScene, delay : float) -> void:
|
||||
var enemy : PathFollow3D = createEnemy(enemyScene)
|
||||
# DANGER this var is needed for timer callback
|
||||
var laneToSpawn : int = current_troop.lane_to_spawn
|
||||
|
||||
if delay > 0:
|
||||
var enemyTimer : Timer = createTimer(delay)
|
||||
enemyTimer.timeout.connect(
|
||||
func():
|
||||
paths[current_troop.lane_to_spawn].add_child(enemy)
|
||||
paths[laneToSpawn].add_child(enemy)
|
||||
enemyTimer.queue_free()
|
||||
)
|
||||
paths[current_troop.lane_to_spawn].add_child(enemyTimer)
|
||||
add_child(enemyTimer)
|
||||
else:
|
||||
paths[current_troop.lane_to_spawn].add_child(enemy)
|
||||
paths[laneToSpawn].add_child(enemy)
|
||||
|
||||
enemies_alive += 1
|
||||
|
||||
|
||||
func createEnemy() -> PathFollow3D :
|
||||
var PF3D : PathFollow3D = load(current_troop.enemy).instantiate()
|
||||
func createEnemy(enemyScene : PackedScene) -> PathFollow3D :
|
||||
var PF3D : PathFollow3D = enemyScene.instantiate()
|
||||
var enemy : Enemy = PF3D.find_children("*", "Enemy")[0]
|
||||
enemy.died.connect(func(): enemies_alive -= 1)
|
||||
|
||||
|
|
@ -108,4 +111,4 @@ func addMap(mapScene : PackedScene) -> void:
|
|||
level = map.level
|
||||
paths = map.paths.get_children()
|
||||
EventBus.allowedTowerHasChange.emit.call_deferred(level.allowedTowers)
|
||||
spawn_next_wave()
|
||||
spawn_next_wave.call_deferred()
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
extends CharacterBody3D
|
||||
class_name Projectile
|
||||
|
||||
const TARGET_ENEMY : int = 1 ## Flag to target enemy
|
||||
const TARGET_ALLY : int = 2 ## Flag to target ally
|
||||
|
||||
const MINIMUN_AREA : float = .1
|
||||
|
||||
var speed : int = 20
|
||||
var isAOE : bool = false
|
||||
var allowedTargets : int = TARGET_ENEMY
|
||||
var target : PhysicsBody3D
|
||||
var damage : int = 1
|
||||
var enemiesInRange : Array[Enemy]
|
||||
var allyInRange : Array[Tower]
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_instance_valid(target):
|
||||
velocity = global_position.direction_to(target.global_position) * speed
|
||||
look_at(target.global_position)
|
||||
|
||||
move_and_slide()
|
||||
else:
|
||||
queue_free()
|
||||
|
||||
|
||||
func onBodyEnteredDamageArea(body: Node3D) -> void:
|
||||
if isAOE && targetable(body):
|
||||
if body is Enemy:
|
||||
enemiesInRange.append(body)
|
||||
if body is Tower:
|
||||
allyInRange.append(body)
|
||||
|
||||
|
||||
func onBodyExitedDamageArea(body: Node3D) -> void:
|
||||
if body is Enemy:
|
||||
enemiesInRange.erase(body)
|
||||
if body is Tower:
|
||||
allyInRange.erase(body)
|
||||
|
||||
|
||||
func onBodyCollideWithProjectile(body: Node3D) -> void:
|
||||
if body == target:
|
||||
resolveDamages()
|
||||
|
||||
|
||||
func targetable(body: Node3D) -> bool:
|
||||
if body is Enemy:
|
||||
return TARGET_ENEMY & allowedTargets
|
||||
if body is Tower:
|
||||
return TARGET_ALLY & allowedTargets
|
||||
|
||||
return false
|
||||
|
||||
|
||||
func resolveDamages() -> void:
|
||||
for enemy in enemiesInRange:
|
||||
enemy.take_damage(damage)
|
||||
queue_free()
|
||||
|
||||
|
||||
func loadProjectile(resource : ProjectileResource, startPosition: Vector3, _target: PhysicsBody3D) -> void:
|
||||
target = _target
|
||||
enemiesInRange.append(target)
|
||||
global_position = startPosition
|
||||
speed = resource.speed
|
||||
isAOE = resource.isAOE
|
||||
allowedTargets = resource.allowedTargets
|
||||
$Sprite3D.texture = resource.sprite
|
||||
if isAOE && resource.damageArea:
|
||||
$DamageArea/ProjectileArea.shape = resource.damageArea
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
extends Resource
|
||||
class_name ProjectileResource
|
||||
|
||||
|
||||
@export var speed : int = 20
|
||||
@export var damage : int = 1
|
||||
@export var isAOE : bool = false
|
||||
@export_flags("Enemies", "Alliés") var allowedTargets : int = 1
|
||||
@export var damageArea : Shape3D
|
||||
@export var sprite : Texture2D
|
||||
|
|
@ -1 +0,0 @@
|
|||
extends Node3D
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dcssahwfr5irf
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://ukt2r8vmpj00"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dcssahwfr5irf" path="res://Tests/test_enviroment.gd" id="1_37o1p"]
|
||||
|
||||
[node name="TestEnviroment" type="Node3D"]
|
||||
script = ExtResource("1_37o1p")
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://c6ceaa6x357bb" path="res://Assets/Meshes/SM_Cube.glb" id="2_lacym"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_ppsqf"]
|
||||
size = Vector3(1.2, 1, 1.2)
|
||||
|
||||
[node name="TheCube" type="StaticBody3D"]
|
||||
collision_layer = 8
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Alex
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bwwj3ih4l1iyp
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Aline
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://16hafh01iv
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Evan
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://cyxxauybvvfyj
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://c4ta0aynybpis"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_yctfx"]
|
||||
[ext_resource type="Script" uid="uid://cyxxauybvvfyj" path="res://Towers/Evan/evan.gd" id="2_fuecn"]
|
||||
[ext_resource type="Texture2D" uid="uid://dwwgho6f8f4kj" path="res://Assets/Icones/penguin.svg" id="3_nvfjk"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Projectiles/ProjectileResource.gd" id="4_el20i"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_v32j5"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqyhhvxpwtpsy" path="res://Assets/Emotes/emote_star.png" id="5_el20i"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ykufo"]
|
||||
script = ExtResource("4_el20i")
|
||||
speed = 20
|
||||
damage = 1
|
||||
isAOE = false
|
||||
allowedTargets = 1
|
||||
sprite = ExtResource("5_el20i")
|
||||
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||
|
||||
[node name="Evan" instance=ExtResource("1_yctfx")]
|
||||
script = ExtResource("2_fuecn")
|
||||
tower_name = "Evan"
|
||||
tower_type = 5
|
||||
icone = ExtResource("3_nvfjk")
|
||||
bio = ""
|
||||
projectileRessource = SubResource("Resource_ykufo")
|
||||
tower_shop = Array[ExtResource("4_v32j5")]([])
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Geraldine
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://buay224tvuqx
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Maxence
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dw70mfu1a60bo
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://b1pg1hgysx3am"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_laam8"]
|
||||
[ext_resource type="Script" uid="uid://dw70mfu1a60bo" path="res://Towers/Maxence/maxence.gd" id="2_vs45d"]
|
||||
[ext_resource type="Texture2D" uid="uid://boxdrq4nrq7hv" path="res://Assets/Icones/flamingo.svg" id="3_rq8mm"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_l8w4i"]
|
||||
|
||||
[node name="Maxence" instance=ExtResource("1_laam8")]
|
||||
script = ExtResource("2_vs45d")
|
||||
tower_name = "Maxence"
|
||||
tower_type = 3
|
||||
icone = ExtResource("3_rq8mm")
|
||||
bio = ""
|
||||
price = 200
|
||||
bullet_damage = 1
|
||||
tower_shop = Array[ExtResource("4_l8w4i")]([])
|
||||
|
||||
[node name="Sprite3D" parent="." index="6"]
|
||||
frame = 8
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Pierre
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://q4o384wv3ijj
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bj6srer7ghf7p"]
|
||||
|
||||
[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/pierre.gd" id="1_v16mf"]
|
||||
[ext_resource type="Texture2D" uid="uid://bb4wihq1n1wm7" path="res://Assets/Icones/labrador-head.svg" id="3_odfqx"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Projectiles/ProjectileResource.gd" id="4_3juah"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqyhhvxpwtpsy" path="res://Assets/Emotes/emote_star.png" id="5_p33h4"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3ht5a"]
|
||||
script = ExtResource("4_3juah")
|
||||
speed = 20
|
||||
damage = 5
|
||||
isAOE = false
|
||||
allowedTargets = 1
|
||||
sprite = ExtResource("5_p33h4")
|
||||
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||
|
||||
[node name="Pierre" instance=ExtResource("1_7f7qx")]
|
||||
script = ExtResource("1_v16mf")
|
||||
tower_name = "Pierre"
|
||||
tower_type = 1
|
||||
icone = ExtResource("3_odfqx")
|
||||
bio = null
|
||||
projectileRessource = SubResource("Resource_3ht5a")
|
||||
action_cooldown = 1.0
|
||||
max_energy = 50.0
|
||||
energy_regen = 5.0
|
||||
energy_cost = 2.0
|
||||
buttonTooltip = null
|
||||
tower_shop = null
|
||||
97
Towers/Projectiles/Projectile.gd
Normal file
97
Towers/Projectiles/Projectile.gd
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
extends CharacterBody3D
|
||||
class_name Projectile
|
||||
|
||||
const TARGET_ENEMY : int = 1 ## Flag to target enemy
|
||||
const TARGET_ALLY : int = 2 ## Flag to target ally
|
||||
|
||||
const MINIMUN_AREA : float = .1
|
||||
|
||||
enum TYPE { ## Types of projectiles
|
||||
AOE, ## One target
|
||||
BASIC, ## Multiple targets[br]work with [member ProjectileResource.damageArea]
|
||||
PIERCING ## Piercing through many enemy[br]work with [member ProjectileResource.maxTarets]
|
||||
}
|
||||
|
||||
var type : TYPE = TYPE.BASIC
|
||||
var speed : int = 20
|
||||
var allowedTargets : int = TARGET_ENEMY
|
||||
var target : PhysicsBody3D
|
||||
var vectorTarget : Vector3
|
||||
var maxTargets : int = 1
|
||||
var damage : int = 1
|
||||
var enemiesInRange : Array[Enemy]
|
||||
var affectedTarget : Array[Enemy]
|
||||
var allyInRange : Array[Tower]
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
prints(vectorTarget, is_instance_valid(target), vectorTarget == Vector3.ZERO)
|
||||
if !is_instance_valid(target) && vectorTarget == Vector3.ZERO:
|
||||
queue_free()
|
||||
return
|
||||
|
||||
var globalPos : Vector3 = vectorTarget if vectorTarget else target.global_position
|
||||
velocity = global_position.direction_to(globalPos) * speed
|
||||
look_at(globalPos)
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func onBodyEnteredDamageArea(body: Node3D) -> void:
|
||||
if type == TYPE.AOE && targetable(body):
|
||||
addTarget(body)
|
||||
|
||||
|
||||
func onBodyCollideWithProjectile(body: Node3D) -> void:
|
||||
if not affectedTarget.has(body) && (body == target || type == TYPE.PIERCING && targetable(body)):
|
||||
addTarget(body)
|
||||
resolveDamages()
|
||||
|
||||
|
||||
func targetable(body: Node3D) -> bool:
|
||||
if body is Enemy:
|
||||
return TARGET_ENEMY & allowedTargets
|
||||
if body is Tower:
|
||||
return TARGET_ALLY & allowedTargets
|
||||
|
||||
return false
|
||||
|
||||
|
||||
func resolveDamages() -> void:
|
||||
for enemy in enemiesInRange:
|
||||
if is_instance_valid(enemy):
|
||||
maxTargets -= 1
|
||||
enemy.take_damage(damage)
|
||||
affectedTarget.append(enemy)
|
||||
|
||||
if maxTargets < 1:
|
||||
queue_free()
|
||||
|
||||
|
||||
func loadProjectile(resource: ProjectileResource, startPosition: Vector3, _target: PhysicsBody3D) -> void:
|
||||
target = _target
|
||||
global_position = startPosition
|
||||
type = resource.type
|
||||
if type == TYPE.PIERCING:
|
||||
vectorTarget = target.global_position
|
||||
# NOTE removing colision layer for pierce effect
|
||||
$HitBox.collision_layer = 0
|
||||
speed = resource.speed
|
||||
maxTargets = resource.maxTargets
|
||||
damage = resource.damage
|
||||
allowedTargets = resource.allowedTargets
|
||||
$Sprite3D.texture = resource.sprite
|
||||
if type == TYPE.AOE && resource.damageArea:
|
||||
$DamageArea/ProjectileArea.shape = resource.damageArea
|
||||
|
||||
|
||||
func addTarget(body: Node3D) -> void:
|
||||
if body is Enemy:
|
||||
enemiesInRange.append(body)
|
||||
if body is Tower:
|
||||
allyInRange.append(body)
|
||||
|
||||
|
||||
func removeTarget(body: Node3D) -> void:
|
||||
if body is Enemy:
|
||||
enemiesInRange.erase(body)
|
||||
if body is Tower:
|
||||
allyInRange.erase(body)
|
||||
11
Towers/Projectiles/ProjectileResource.gd
Normal file
11
Towers/Projectiles/ProjectileResource.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
extends Resource
|
||||
class_name ProjectileResource
|
||||
|
||||
|
||||
@export var speed : int = 20
|
||||
@export var damage : int = 1
|
||||
@export var maxTargets : int = 1 ## Only usefull if [enum Projectile.TYPE] is [param PIERCING]
|
||||
@export var type : Projectile.TYPE = Projectile.TYPE.BASIC
|
||||
@export_flags("Enemies", "Alliés") var allowedTargets : int = 1
|
||||
@export var damageArea : Shape3D ## Only usefull if [enum Projectile.TYPE] is [param AOE]
|
||||
@export var sprite : Texture2D = load("res://Assets/Emotes/emote_star.png")
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://oykrff3g74eo"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b788twwo1o6l2" path="res://Projectiles/Projectile.gd" id="1_ggq0q"]
|
||||
[ext_resource type="Script" uid="uid://b788twwo1o6l2" path="res://Towers/Projectiles/Projectile.gd" id="1_ggq0q"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqyhhvxpwtpsy" path="res://Assets/Emotes/emote_star.png" id="2_08w86"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_r5o86"]
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://cwcar1t7n15fn"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cwcar1t7n15fn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_lr28p"]
|
||||
[ext_resource type="Script" uid="uid://bwwj3ih4l1iyp" path="res://Towers/Alex/alex.gd" id="2_4yx0u"]
|
||||
[ext_resource type="Texture2D" uid="uid://c4ir6y45pchpl" path="res://Assets/Icones/seahorse.svg" id="3_4yx0u"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_4yx0u"]
|
||||
|
||||
[node name="Alex" instance=ExtResource("1_lr28p")]
|
||||
script = ExtResource("2_4yx0u")
|
||||
tower_name = "Alex"
|
||||
tower_type = 6
|
||||
icone = ExtResource("3_4yx0u")
|
||||
bio = ""
|
||||
bullet_damage = 1
|
||||
tower_shop = Array[ExtResource("4_4yx0u")]([])
|
||||
|
||||
[node name="Sprite3D" parent="." index="6"]
|
||||
[node name="Sprite3D" parent="." index="5"]
|
||||
frame = 30
|
||||
|
|
@ -1,34 +1,37 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://ck1qryleu80s"]
|
||||
|
||||
[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/aline.gd" id="2_6sjqq"]
|
||||
[ext_resource type="Texture2D" uid="uid://cob1lydkirn20" path="res://Assets/Icones/raccoon-head.svg" id="3_6h033"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="3_p2nb1"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Projectiles/ProjectileResource.gd" id="4_ck6a3"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Towers/Projectiles/ProjectileResource.gd" id="4_ck6a3"]
|
||||
[ext_resource type="Texture2D" uid="uid://315k07rsgf6t" path="res://Assets/Characters/Female1.png" id="5_l514g"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqyhhvxpwtpsy" path="res://Assets/Emotes/emote_star.png" id="5_lhd8w"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_lhd8w"]
|
||||
radius = 0.6
|
||||
radius = 1.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lhd8w"]
|
||||
script = ExtResource("4_ck6a3")
|
||||
speed = 20
|
||||
speed = 5
|
||||
damage = 10
|
||||
isAOE = true
|
||||
maxTargets = 1
|
||||
type = 0
|
||||
allowedTargets = 1
|
||||
damageArea = SubResource("SphereShape3D_lhd8w")
|
||||
sprite = ExtResource("5_lhd8w")
|
||||
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_6bcjo"]
|
||||
radius = 3.0
|
||||
|
||||
[node name="Aline" instance=ExtResource("1_gvvig")]
|
||||
script = ExtResource("2_6sjqq")
|
||||
tower_name = "Aline"
|
||||
tower_type = 2
|
||||
icone = ExtResource("3_6h033")
|
||||
bio = ""
|
||||
price = 150
|
||||
projectileRessource = SubResource("Resource_lhd8w")
|
||||
towerRange = SubResource("SphereShape3D_6bcjo")
|
||||
action_cooldown = 2.5
|
||||
energy_cost = 25.0
|
||||
tower_shop = Array[ExtResource("3_p2nb1")]([])
|
||||
27
Towers/Scenes/evan.tscn
Normal file
27
Towers/Scenes/evan.tscn
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://c4ta0aynybpis"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_yctfx"]
|
||||
[ext_resource type="Texture2D" uid="uid://dwwgho6f8f4kj" path="res://Assets/Icones/penguin.svg" id="2_5uh04"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Towers/Projectiles/ProjectileResource.gd" id="3_gr7yf"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_v32j5"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_mf185"]
|
||||
script = ExtResource("3_gr7yf")
|
||||
speed = 20
|
||||
damage = 1
|
||||
maxTargets = 1
|
||||
type = 1
|
||||
allowedTargets = 1
|
||||
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_y05yr"]
|
||||
radius = 4.0
|
||||
|
||||
[node name="Evan" instance=ExtResource("1_yctfx")]
|
||||
tower_name = "Evan"
|
||||
tower_type = 5
|
||||
icone = ExtResource("2_5uh04")
|
||||
bio = ""
|
||||
projectileRessource = SubResource("Resource_mf185")
|
||||
towerRange = SubResource("SphereShape3D_y05yr")
|
||||
tower_shop = Array[ExtResource("4_v32j5")]([])
|
||||
|
|
@ -1,20 +1,17 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://clwn21pkvah0"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://clwn21pkvah0"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_bw8ui"]
|
||||
[ext_resource type="Script" uid="uid://buay224tvuqx" path="res://Towers/Geraldine/geraldine.gd" id="2_nlkm7"]
|
||||
[ext_resource type="Texture2D" uid="uid://d4pdmbhhlphc" path="res://Assets/Icones/seated-mouse.svg" id="3_nxn76"]
|
||||
[ext_resource type="Texture2D" uid="uid://d4pdmbhhlphc" path="res://Assets/Icones/seated-mouse.svg" id="2_1pop4"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_nxn76"]
|
||||
[ext_resource type="Texture2D" uid="uid://315k07rsgf6t" path="res://Assets/Characters/Female1.png" id="5_kbhva"]
|
||||
|
||||
[node name="Geraldine" instance=ExtResource("1_bw8ui")]
|
||||
script = ExtResource("2_nlkm7")
|
||||
tower_name = "Geraldine"
|
||||
tower_type = 7
|
||||
icone = ExtResource("3_nxn76")
|
||||
icone = ExtResource("2_1pop4")
|
||||
bio = ""
|
||||
bullet_damage = 1
|
||||
tower_shop = Array[ExtResource("4_nxn76")]([])
|
||||
|
||||
[node name="Sprite3D" parent="." index="6"]
|
||||
[node name="Sprite3D" parent="." index="5"]
|
||||
texture = ExtResource("5_kbhva")
|
||||
frame = 35
|
||||
33
Towers/Scenes/maxence.tscn
Normal file
33
Towers/Scenes/maxence.tscn
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://b1pg1hgysx3am"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_laam8"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Towers/Projectiles/ProjectileResource.gd" id="2_7fox5"]
|
||||
[ext_resource type="Texture2D" uid="uid://boxdrq4nrq7hv" path="res://Assets/Icones/flamingo.svg" id="2_sciv6"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_l8w4i"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_sciv6"]
|
||||
script = ExtResource("2_7fox5")
|
||||
speed = 40
|
||||
damage = 10
|
||||
maxTargets = 5
|
||||
type = 1
|
||||
allowedTargets = 1
|
||||
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_pw4mj"]
|
||||
radius = 10.0
|
||||
|
||||
[node name="Maxence" instance=ExtResource("1_laam8")]
|
||||
tower_name = "Maxence"
|
||||
tower_type = 3
|
||||
icone = ExtResource("2_sciv6")
|
||||
bio = ""
|
||||
price = 200
|
||||
projectileRessource = SubResource("Resource_sciv6")
|
||||
towerRange = SubResource("SphereShape3D_pw4mj")
|
||||
action_cooldown = 3.0
|
||||
energy_regen = 20.0
|
||||
tower_shop = Array[ExtResource("4_l8w4i")]([])
|
||||
|
||||
[node name="Sprite3D" parent="." index="5"]
|
||||
frame = 8
|
||||
30
Towers/Scenes/pierre.tscn
Normal file
30
Towers/Scenes/pierre.tscn
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bj6srer7ghf7p"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_s6dfo"]
|
||||
[ext_resource type="Texture2D" uid="uid://bb4wihq1n1wm7" path="res://Assets/Icones/labrador-head.svg" id="2_lcjqw"]
|
||||
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://Towers/Projectiles/ProjectileResource.gd" id="3_5tgsk"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqyhhvxpwtpsy" path="res://Assets/Emotes/emote_star.png" id="4_r52mr"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_r52mr"]
|
||||
script = ExtResource("3_5tgsk")
|
||||
speed = 20
|
||||
damage = 5
|
||||
maxTargets = 1
|
||||
type = 1
|
||||
allowedTargets = 1
|
||||
sprite = ExtResource("4_r52mr")
|
||||
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_c55ds"]
|
||||
radius = 5.0
|
||||
|
||||
[node name="Pierre" instance=ExtResource("1_s6dfo")]
|
||||
tower_name = "Pierre"
|
||||
tower_type = 1
|
||||
icone = ExtResource("2_lcjqw")
|
||||
projectileRessource = SubResource("Resource_r52mr")
|
||||
towerRange = SubResource("SphereShape3D_c55ds")
|
||||
action_cooldown = 1.0
|
||||
max_energy = 50.0
|
||||
energy_regen = 5.0
|
||||
energy_cost = 2.0
|
||||
|
|
@ -1,16 +1,14 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://db6aq2wdrcjtp"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://db6aq2wdrcjtp"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://trg7ag3dqr2l" path="res://Towers/tower.tscn" id="1_ki73m"]
|
||||
[ext_resource type="Script" uid="uid://bdhjn2ku4daln" path="res://Towers/Victoria/victoria.gd" id="2_vl5h5"]
|
||||
[ext_resource type="Texture2D" uid="uid://m6jwakrus50v" path="res://Assets/Icones/sea-star.svg" id="3_tmg5m"]
|
||||
[ext_resource type="Texture2D" uid="uid://m6jwakrus50v" path="res://Assets/Icones/sea-star.svg" id="2_n34tq"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="4_uso5g"]
|
||||
[ext_resource type="Texture2D" uid="uid://315k07rsgf6t" path="res://Assets/Characters/Female1.png" id="5_2rqsg"]
|
||||
|
||||
[node name="Victoria" instance=ExtResource("1_ki73m")]
|
||||
script = ExtResource("2_vl5h5")
|
||||
tower_name = "Victoria"
|
||||
tower_type = 4
|
||||
icone = ExtResource("3_tmg5m")
|
||||
icone = ExtResource("2_n34tq")
|
||||
bio = ""
|
||||
tower_shop = Array[ExtResource("4_uso5g")]([])
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
@tool
|
||||
extends StaticBody3D
|
||||
class_name Tower
|
||||
|
||||
|
|
@ -5,20 +6,21 @@ class_name Tower
|
|||
# DANGER "NONE" Should always be first
|
||||
enum TYPE { NONE, PIERRE, ALINE, MAXENCE, VICTORIA, EVAN, ALEX, GERALDINE }
|
||||
|
||||
var projectileScene : PackedScene = preload("res://Projectiles/projectile.tscn")
|
||||
var projectileScene : PackedScene = preload("res://Towers/Projectiles/projectile.tscn")
|
||||
|
||||
@export var tower_name : String = "None"
|
||||
@export var tower_type : TYPE
|
||||
@export_group("Base data")
|
||||
@export var icone : Texture2D
|
||||
@export var bio : String
|
||||
@export var price : int = 100
|
||||
|
||||
@export_group("Attack")
|
||||
@export var projectileRessource : ProjectileResource
|
||||
@export var towerRange : Shape3D
|
||||
@export var action_cooldown : float = 1.5:
|
||||
set(value):
|
||||
action_cooldown = clamp(value, 0.3, 999)
|
||||
$Cooldown.wait_time = action_cooldown
|
||||
|
||||
@export_group("Energy")
|
||||
@export var max_energy : float = 100.0
|
||||
|
|
@ -29,19 +31,19 @@ var projectileScene : PackedScene = preload("res://Projectiles/projectile.tscn")
|
|||
@export var buttonTooltip : String
|
||||
|
||||
|
||||
@onready var energy_bar : EnergyBar3D = $EnergyBar3D
|
||||
@onready var energy_bar : ProgressBar = $EnergyBar3D/SubViewport/EnergyBar2D
|
||||
@onready var sprite : Sprite3D = $Sprite3D
|
||||
|
||||
var energy : float = max_energy:
|
||||
var energy : float = 0:
|
||||
set(value):
|
||||
energy_bar.value = value
|
||||
energy = clampf(value, 0.0, max_energy)
|
||||
energy_bar.update(value)
|
||||
is_exhausted = energy < energy_cost
|
||||
EventBus.energy_has_changed.emit(self)
|
||||
|
||||
var current_targets : Array = []
|
||||
var current : CharacterBody3D
|
||||
var can_shoot : bool = true
|
||||
var can_shoot : bool = false
|
||||
var is_exhausted : bool = false
|
||||
var builded : bool = false
|
||||
|
||||
|
|
@ -58,6 +60,30 @@ var tower_upgrades : Array[TowerUpgrade]
|
|||
@export var tower_shop : Array[TowerUpgrade]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.tower_upgraded.connect(_on_EventBus_tower_upgraded)
|
||||
EventBus.energy_has_changed.emit(self)
|
||||
# WARNING : Prevent .tscn file to be modified by the load of the scene in editor
|
||||
if not Engine.is_editor_hint():
|
||||
$PriceTag.text = str(price) +" €"
|
||||
energy = max_energy
|
||||
$Range/Range.shape = towerRange
|
||||
energy_bar.value = energy
|
||||
energy_bar.max_value = max_energy
|
||||
$Cooldown.wait_time = action_cooldown
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if is_rest:
|
||||
return
|
||||
|
||||
if is_instance_valid(current):
|
||||
if can_shoot && not is_exhausted:
|
||||
shoot()
|
||||
can_shoot = false
|
||||
$Cooldown.start()
|
||||
|
||||
|
||||
func get_available_upgrades() -> Array[TowerUpgrade]:
|
||||
var available_upgrades : Array[TowerUpgrade]
|
||||
#Check every upgrades in shop
|
||||
|
|
@ -81,23 +107,6 @@ func apply_upgrade(upgrade : TowerUpgrade):
|
|||
else:
|
||||
printerr("Upgrade already bought")
|
||||
|
||||
func _ready() -> void:
|
||||
EventBus.tower_upgraded.connect(_on_EventBus_tower_upgraded)
|
||||
energy_bar.set_up(energy, max_energy)
|
||||
energy_bar.set_max_value(max_energy)
|
||||
$Cooldown.wait_time = action_cooldown
|
||||
EventBus.energy_has_changed.emit(self)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if is_rest:
|
||||
return
|
||||
|
||||
if is_instance_valid(current):
|
||||
if can_shoot && not is_exhausted:
|
||||
shoot()
|
||||
can_shoot = false
|
||||
$Cooldown.start()
|
||||
|
||||
|
||||
func shoot() -> void:
|
||||
energy -= energy_cost
|
||||
|
|
@ -135,13 +144,14 @@ func choose_target(_current_targets : Array) -> void:
|
|||
current = current_target
|
||||
|
||||
|
||||
func show_price_tag()-> void:
|
||||
$PriceTag.text = str(price) +" €"
|
||||
visible = true
|
||||
|
||||
|
||||
func hide_price_tag()-> void:
|
||||
visible = false
|
||||
func build() -> void:
|
||||
EventBus.money_spent.emit(price)
|
||||
can_shoot = true
|
||||
collision_layer = 3
|
||||
sprite.modulate = "ffffffff"
|
||||
builded = true
|
||||
$PriceTag.visible = false
|
||||
EventBus.tower_builded.emit(self)
|
||||
|
||||
|
||||
func _on_range_body_entered(body: Node3D) -> void:
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
@tool
|
||||
extends EnhancedResource
|
||||
class_name TowerListResource
|
||||
|
||||
const TOWER_DIR : String = "res://Towers/"
|
||||
const TOWER_DIR_PATTERN : String = "res://Towers/\\w+/$"
|
||||
const TOWER_NAME_PATTERN : String = "([^/]*)\\.tscn$"
|
||||
|
||||
static var towers : Dictionary
|
||||
|
||||
static func _static_init() -> void:
|
||||
var towerResources : Array[String] = getFileFromDir(TOWER_DIR, TOWER_NAME_PATTERN, TOWER_DIR_PATTERN)
|
||||
|
||||
for towerRes in towerResources:
|
||||
towers.set(getPackedSceneProperty(load(towerRes), "tower_type"), towerRes)
|
||||
|
||||
towers.sort()
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://clm4xbebbeqgj
|
||||
|
|
@ -75,12 +75,10 @@ func handle_player_controls() -> void:
|
|||
func place_tower() -> void:
|
||||
_state = STATE.PLACING
|
||||
|
||||
selected_tower = load(TowerListResource.towers.get(selected_tower_type)).instantiate()
|
||||
selected_tower = Game.towers.get(selected_tower_type).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()
|
||||
add_child(selected_tower)
|
||||
|
||||
func quit_placing() -> void:
|
||||
_state = STATE.IDLE
|
||||
|
|
@ -98,13 +96,7 @@ func build_tower() -> void:
|
|||
if selected_tower.is_rest:
|
||||
if not selected_tower.builded:
|
||||
#Build Tower
|
||||
EventBus.money_spent.emit(selected_tower.price)
|
||||
selected_tower.can_shoot = true
|
||||
selected_tower.collision_layer = 3
|
||||
selected_tower.sprite.modulate = "ffffffff"
|
||||
selected_tower.hide_price_tag()
|
||||
selected_tower.builded = true
|
||||
EventBus.tower_builded.emit(selected_tower)
|
||||
selected_tower.build()
|
||||
remove_child(selected_tower)
|
||||
$"../Towers".add_child(selected_tower)
|
||||
quit_placing()
|
||||
|
|
@ -118,7 +110,7 @@ func selectTower(towerType : Tower.TYPE):
|
|||
if selected_tower && not selected_tower.builded:
|
||||
selected_tower.visible = false
|
||||
|
||||
if towerType == selected_tower_type:
|
||||
if towerType == selected_tower_type || towerType == Tower.TYPE.NONE:
|
||||
selected_tower = null
|
||||
selected_tower_type = Tower.TYPE.NONE
|
||||
_state = STATE.IDLE
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
extends Tower
|
||||
class_name Victoria
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://bdhjn2ku4daln
|
||||
|
|
@ -1,18 +1,30 @@
|
|||
[gd_scene load_steps=10 format=3 uid="uid://trg7ag3dqr2l"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://trg7ag3dqr2l"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://8kpvuurr5h5n" path="res://Towers/Scripts/Tower.gd" id="1_egfuc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bn6ikwol6x8r0" path="res://Assets/Characters/Male1.png" id="2_egfuc"]
|
||||
[ext_resource type="Texture2D" uid="uid://uptdcefxlv4c" path="res://Assets/Icones/ppdf_bio_image_placeholder_2.png" id="2_mnaic"]
|
||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Towers/Scripts/Upgrades/TowerUpgrade.gd" id="3_5dr1v"]
|
||||
[ext_resource type="Resource" uid="uid://c6844q5o2gjhd" path="res://Upgrades/Tower/TowerUpgradeMaxEnergy1.tres" id="3_jv31o"]
|
||||
[ext_resource type="PackedScene" uid="uid://bm303ot1ck82l" path="res://UI/energy_bar_3d.tscn" id="3_pajr1"]
|
||||
[ext_resource type="Resource" uid="uid://bus11qw5jg8yo" path="res://Upgrades/Tower/TowerUpgradeMaxEnergy2.tres" id="4_5dr1v"]
|
||||
[ext_resource type="Script" uid="uid://blnmjxmusrsa7" path="res://UI/GameStyleBoxFlat.gd" id="8_5dr1v"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_egfuc"]
|
||||
size = Vector3(1, 0.1, 1)
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_pajr1"]
|
||||
radius = 3.0
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_jv31o"]
|
||||
viewport_path = NodePath("EnergyBar3D/SubViewport")
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jv31o"]
|
||||
bg_color = Color(0.341, 0.082, 0.094, 0)
|
||||
script = ExtResource("8_5dr1v")
|
||||
color = 3
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5dr1v"]
|
||||
bg_color = Color(0.921569, 0.890196, 0.415686, 1)
|
||||
script = ExtResource("8_5dr1v")
|
||||
color = 1
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[node name="Tower" type="StaticBody3D"]
|
||||
collision_layer = 4
|
||||
|
|
@ -27,13 +39,12 @@ 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)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Range"]
|
||||
[node name="Range" 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, 0.572046, 0)
|
||||
|
|
@ -52,11 +63,35 @@ hframes = 8
|
|||
vframes = 12
|
||||
frame = 75
|
||||
|
||||
[node name="EnergyBar3D" parent="." instance=ExtResource("3_pajr1")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.44473, 0)
|
||||
[node name="EnergyBar3D" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
billboard = 2
|
||||
texture = SubResource("ViewportTexture_jv31o")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="EnergyBar3D"]
|
||||
size = Vector2i(72, 10)
|
||||
size_2d_override_stretch = true
|
||||
|
||||
[node name="EnergyBar2D" type="ProgressBar" parent="EnergyBar3D/SubViewport"]
|
||||
custom_minimum_size = Vector2(68, 6)
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -34.0
|
||||
offset_top = -3.0
|
||||
offset_right = 34.0
|
||||
offset_bottom = 3.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_jv31o")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_5dr1v")
|
||||
show_percentage = false
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[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.2, 0)
|
||||
billboard = 2
|
||||
|
||||
[connection signal="input_event" from="." to="." method="_on_input_event"]
|
||||
|
|
|
|||
9
UI/GameStyleBoxFlat.gd
Normal file
9
UI/GameStyleBoxFlat.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
@tool
|
||||
extends StyleBoxFlat
|
||||
class_name GameStyleBoxFlat
|
||||
|
||||
|
||||
@export var color : Game.COLOR :
|
||||
set(value):
|
||||
color = value
|
||||
bg_color = Game.getColor(color)
|
||||
1
UI/GameStyleBoxFlat.gd.uid
Normal file
1
UI/GameStyleBoxFlat.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://blnmjxmusrsa7
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
extends ProgressBar
|
||||
|
||||
func setup_bar(amount : int, max_amount : int) -> void:
|
||||
max_value = max_amount
|
||||
value = amount
|
||||
|
||||
|
||||
func update_bar(amount : int) -> void:
|
||||
value = amount
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://ckd6msqvmhtos
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://xlhufcqxk113"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ckd6msqvmhtos" path="res://UI/energy_bar_2d.gd" id="1_4beyc"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qpj2g"]
|
||||
bg_color = Color(0.341176, 0.0823529, 0.0941176, 0)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
expand_margin_left = 4.0
|
||||
expand_margin_top = 4.0
|
||||
expand_margin_right = 4.0
|
||||
expand_margin_bottom = 4.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xcn5x"]
|
||||
bg_color = Color(0.921569, 0.890196, 0.415686, 1)
|
||||
|
||||
[node name="HealthBar2D" type="ProgressBar"]
|
||||
custom_minimum_size = Vector2(100, 10)
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 104.0
|
||||
offset_bottom = 14.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_qpj2g")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_xcn5x")
|
||||
value = 50.0
|
||||
show_percentage = false
|
||||
script = ExtResource("1_4beyc")
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
extends Sprite3D
|
||||
class_name EnergyBar3D
|
||||
|
||||
@onready var bar : ProgressBar = $SubViewport/EnergyBar2D
|
||||
|
||||
func _ready() -> void:
|
||||
texture = $SubViewport.get_texture()
|
||||
|
||||
|
||||
func set_max_value(max_value : int) -> void:
|
||||
bar.max_value = max_value
|
||||
|
||||
|
||||
func set_up(value : int, max_amount : int) -> void:
|
||||
bar.setup_bar(value, max_amount)
|
||||
|
||||
|
||||
func update(value : int) -> void:
|
||||
bar.update_bar(value)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://d0hr28ug7324
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bm303ot1ck82l"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bd7ed8dvc7m0v" path="res://icon.svg" id="1_d48o1"]
|
||||
[ext_resource type="Script" uid="uid://d0hr28ug7324" path="res://UI/energy_bar_3d.gd" id="2_d48o1"]
|
||||
[ext_resource type="PackedScene" uid="uid://xlhufcqxk113" path="res://UI/energy_bar_2d.tscn" id="3_8lue3"]
|
||||
|
||||
[node name="EnergyBar3D" type="Sprite3D"]
|
||||
billboard = 2
|
||||
texture = ExtResource("1_d48o1")
|
||||
script = ExtResource("2_d48o1")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
size = Vector2i(108, 18)
|
||||
size_2d_override_stretch = true
|
||||
|
||||
[node name="EnergyBar2D" parent="SubViewport" instance=ExtResource("3_8lue3")]
|
||||
16
UI/gui.gd
16
UI/gui.gd
|
|
@ -3,9 +3,9 @@ extends Control
|
|||
|
||||
const BUTTON_QTY = 12
|
||||
|
||||
const towerButton : PackedScene = preload("res://UI/tower_button.tscn")
|
||||
const guiButton : PackedScene = preload("res://UI/gui_button.tscn")
|
||||
|
||||
@onready var buttonContainer = $HBoxContainer/ControlPanelBase/MarginContainer/GridContainer
|
||||
@onready var buttonContainer = %ButtonContainer
|
||||
|
||||
var allowedTowers : Array[Tower.TYPE]
|
||||
|
||||
|
|
@ -39,13 +39,13 @@ func addTowerButtonNodes() -> void:
|
|||
node.queue_free()
|
||||
|
||||
var additionalPlaceholder : int = 0
|
||||
for towerType in TowerListResource.towers:
|
||||
for towerType in Game.towers:
|
||||
if not Engine.is_editor_hint() && not allowedTowers.has(towerType):
|
||||
additionalPlaceholder += 1
|
||||
else:
|
||||
createTowerButton(towerType)
|
||||
|
||||
for i in BUTTON_QTY - TowerListResource.towers.size() + additionalPlaceholder:
|
||||
for i in BUTTON_QTY - Game.towers.size() + additionalPlaceholder:
|
||||
var placeholderBtn : Button = Button.new()
|
||||
placeholderBtn.set_meta("dynamicButton", true)
|
||||
placeholderBtn.custom_minimum_size = Vector2(80, 80)
|
||||
|
|
@ -53,10 +53,12 @@ func addTowerButtonNodes() -> void:
|
|||
|
||||
|
||||
func createTowerButton(towerType : Tower.TYPE) -> void:
|
||||
var towerBtn : TowerButton = towerButton.instantiate()
|
||||
var tower : PackedScene = load(TowerListResource.towers.get(towerType))
|
||||
var towerBtn : GuiButton = guiButton.instantiate()
|
||||
var tower : PackedScene = Game.towers.get(towerType)
|
||||
towerBtn.towerType = towerType
|
||||
towerBtn.hasEnergyBar = true
|
||||
towerBtn.toggle_mode = true
|
||||
towerBtn.tooltip_text = str(EnhancedResource.getPackedSceneProperty(tower, "name"))
|
||||
towerBtn.setButtonTexture(EnhancedResource.getPackedSceneProperty(tower, "icone"))
|
||||
towerBtn.texture = EnhancedResource.getPackedSceneProperty(tower, "icone")
|
||||
towerBtn.set_meta("dynamicButton", true)
|
||||
buttonContainer.add_child(towerBtn)
|
||||
|
|
|
|||
72
UI/gui.tscn
72
UI/gui.tscn
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=15 format=3 uid="uid://p6a6rb7sgeqd"]
|
||||
[gd_scene load_steps=16 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"]
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
[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="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="Texture2D" uid="uid://dfnf26suc8yb6" path="res://Assets/Icones/sideswipe.svg" id="8_ay13l"]
|
||||
[ext_resource type="Texture2D" uid="uid://dootdihg7gkoj" path="res://Assets/Icones/exit-door.svg" id="8_decjp"]
|
||||
[ext_resource type="Texture2D" uid="uid://b4m5ejfdrm8s0" path="res://Assets/Icones/power-button.svg" id="9_reygo"]
|
||||
|
|
@ -131,74 +132,31 @@ theme_override_constants/margin_top = 10
|
|||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="HBoxContainer/ControlPanelBase/MarginContainer"]
|
||||
[node name="ButtonContainer" type="GridContainer" parent="HBoxContainer/ControlPanelBase/MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
columns = 4
|
||||
|
||||
[node name="ButtonCube" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
[node name="CubeBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Sélectionner le cube"
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonCube"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
hasEnergyBar = false
|
||||
texture = ExtResource("7_fffne")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="ButtonQuitLevel" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
[node name="QuitLevelBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Quitter le niveau"
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonQuitLevel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
hasEnergyBar = false
|
||||
texture = ExtResource("8_decjp")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="ButtonQuitGame" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
[node name="QuitGameBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Quitter le jeu"
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonQuitGame"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
hasEnergyBar = false
|
||||
texture = ExtResource("9_reygo")
|
||||
expand_mode = 1
|
||||
|
||||
[node name="ButtonReturn" type="Button" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer"]
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
[node name="ReturnBtn" parent="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer" instance=ExtResource("7_parkk")]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Revenir en arrière"
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ControlPanelBase/MarginContainer/GridContainer/ButtonReturn"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
hasEnergyBar = false
|
||||
texture = ExtResource("8_ay13l")
|
||||
expand_mode = 1
|
||||
|
||||
[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/ButtonQuitGame" to="." method="_on_button_quit_game_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer/CubeBtn" to="." method="_on_button_cube_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer/QuitLevelBtn" to="." method="_on_button_quit_level_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainer/ControlPanelBase/MarginContainer/ButtonContainer/QuitGameBtn" to="." method="_on_button_quit_game_pressed"]
|
||||
|
|
|
|||
36
UI/gui_button.gd
Normal file
36
UI/gui_button.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
@tool
|
||||
extends Button
|
||||
class_name GuiButton
|
||||
|
||||
|
||||
var towerType : Tower.TYPE :
|
||||
set(value):
|
||||
towerType = value
|
||||
if towerType != Tower.TYPE.NONE:
|
||||
EventBus.energy_has_changed.connect(changeEnergy)
|
||||
EventBus.tower_builded.connect(towerChanged)
|
||||
|
||||
|
||||
@export var hasEnergyBar : bool = false :
|
||||
set(value):
|
||||
hasEnergyBar = value
|
||||
$EnergyBar.visible = hasEnergyBar
|
||||
@export var texture : Texture2D :
|
||||
set(value):
|
||||
texture = value
|
||||
$TextureRect.texture = texture
|
||||
|
||||
|
||||
func buttonToggled(state : bool) -> void:
|
||||
if towerType != 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 :
|
||||
if tower.tower_type == towerType:
|
||||
$EnergyBar.max_value = tower.max_energy
|
||||
42
UI/gui_button.tscn
Normal file
42
UI/gui_button.tscn
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dqb5o8w7u50hc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dyhtr6g7kd1g2" path="res://UI/gui_button.gd" id="1_snobr"]
|
||||
[ext_resource type="Script" uid="uid://blnmjxmusrsa7" path="res://UI/GameStyleBoxFlat.gd" id="2_enkiu"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_i47ne"]
|
||||
bg_color = Color(0.921569, 0.890196, 0.415686, 1)
|
||||
script = ExtResource("2_enkiu")
|
||||
color = 1
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[node name="TowerButton" type="Button"]
|
||||
custom_minimum_size = Vector2(80, 80)
|
||||
offset_right = 80.0
|
||||
offset_bottom = 80.0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
tooltip_text = "Sélectionner Pierre"
|
||||
mouse_default_cursor_shape = 2
|
||||
script = ExtResource("1_snobr")
|
||||
hasEnergyBar = null
|
||||
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="EnergyBar" type="ProgressBar" parent="."]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
offset_top = 70.0
|
||||
offset_right = 80.0
|
||||
offset_bottom = 80.0
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_i47ne")
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="toggled" from="." to="." method="buttonToggled"]
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
extends ProgressBar
|
||||
|
||||
func setup_bar(amount : int, max_amount : int) -> void:
|
||||
max_value = max_amount
|
||||
value = amount
|
||||
|
||||
|
||||
func update_bar(amount : int) -> void:
|
||||
value = amount
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://c4037f8r3bomr
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cwl31nkib7ixp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c4037f8r3bomr" path="res://UI/health_bar_2d.gd" id="1_qpj2g"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qpj2g"]
|
||||
bg_color = Color(0.341176, 0.0823529, 0.0941176, 0)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
expand_margin_left = 4.0
|
||||
expand_margin_top = 4.0
|
||||
expand_margin_right = 4.0
|
||||
expand_margin_bottom = 4.0
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xcn5x"]
|
||||
bg_color = Color(0.921569, 0.419608, 0.415686, 1)
|
||||
|
||||
[node name="HealthBar2D" type="ProgressBar"]
|
||||
custom_minimum_size = Vector2(100, 10)
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 104.0
|
||||
offset_bottom = 14.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_qpj2g")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_xcn5x")
|
||||
value = 50.0
|
||||
show_percentage = false
|
||||
script = ExtResource("1_qpj2g")
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
extends Sprite3D
|
||||
|
||||
@onready var bar : ProgressBar = $SubViewport/HealthBar2D
|
||||
|
||||
func _ready() -> void:
|
||||
texture = $SubViewport.get_texture()
|
||||
|
||||
|
||||
func set_up(value : int, max_amount : int) -> void:
|
||||
bar.setup_bar(value, max_amount)
|
||||
|
||||
|
||||
func update(value : int) -> void:
|
||||
bar.update_bar(value)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://be8jd1w1bsfyt
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://daiqb0q373002"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bd7ed8dvc7m0v" path="res://icon.svg" id="1_dna40"]
|
||||
[ext_resource type="Script" uid="uid://be8jd1w1bsfyt" path="res://UI/health_bar_3d.gd" id="1_l5e25"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwl31nkib7ixp" path="res://UI/health_bar_2d.tscn" id="2_l5e25"]
|
||||
|
||||
[node name="HealthBar3D" type="Sprite3D"]
|
||||
billboard = 2
|
||||
texture = ExtResource("1_dna40")
|
||||
script = ExtResource("1_l5e25")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
size = Vector2i(108, 18)
|
||||
size_2d_override_stretch = true
|
||||
|
||||
[node name="HealthBar2D" parent="SubViewport" instance=ExtResource("2_l5e25")]
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
@tool
|
||||
extends Button
|
||||
class_name TowerButton
|
||||
|
||||
var towerType : Tower.TYPE
|
||||
|
||||
func _ready() -> void:
|
||||
#font_outline_color = Color.YELLOW
|
||||
if not Engine.is_editor_hint():
|
||||
pressed.connect(EventBus.tower_selected.emit.bind(towerType))
|
||||
EventBus.energy_has_changed.connect(changeEnergy)
|
||||
EventBus.tower_builded.connect(towerBuilded)
|
||||
|
||||
|
||||
func changeEnergy(tower : Tower) -> void:
|
||||
if tower.tower_type == towerType:
|
||||
$ProgressBar.value = tower.energy
|
||||
|
||||
|
||||
func towerBuilded(tower : Tower) -> void :
|
||||
if tower.tower_type == towerType:
|
||||
$ProgressBar.max_value = tower.max_energy
|
||||
|
||||
|
||||
func setButtonTexture(texture : Texture2D) -> void:
|
||||
$TextureRect.texture = texture
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
[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
|
||||
|
|
@ -8,7 +8,7 @@ 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/"
|
||||
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")
|
||||
|
|
@ -145,6 +145,7 @@ func cleanAndBuildMenu() -> void:
|
|||
|
||||
func resetApp() -> void:
|
||||
enemies = getOptionsFromFile(ENEMY_PATH, ENEMY_REGEX_PATERN)
|
||||
print(enemies)
|
||||
levelSelect.setOptions(getOptionsFromFile(LEVEL_PATH, LEVEL_REGEX_PATERN, LEVEL_PATH_REGEX_PATERN))
|
||||
cleanAndBuildMenu()
|
||||
|
||||
|
|
@ -214,7 +215,7 @@ func onSelectedTowerChange(index: int, selected: int) -> void:
|
|||
|
||||
func getOptionsFromFile(path : String, regexPattern : String, pathRegexPattern : String = "") -> Dictionary :
|
||||
var files : Dictionary
|
||||
var filePaths : Array[String] = EnhancedResource.getFileFromDir(path, regexPattern, pathRegexPattern)
|
||||
var filePaths : Array[String] = Game.getFileFromDir(path, regexPattern, pathRegexPattern)
|
||||
var regex : RegEx = RegEx.create_from_string(regexPattern)
|
||||
|
||||
for file in filePaths:
|
||||
|
|
|
|||
|
|
@ -4,26 +4,20 @@
|
|||
[ext_resource type="Script" uid="uid://b47p2u458hsn0" path="res://addons/LevelEditor/UI/CustomOptionButton.gd" id="2_xjxpq"]
|
||||
[ext_resource type="Script" uid="uid://bpv75ucqoy446" path="res://addons/LevelEditor/UI/CustomLineEdit.gd" id="3_qw7ts"]
|
||||
|
||||
[node name="Menu" type="HBoxContainer"]
|
||||
[node name="Menu" type="MarginContainer"]
|
||||
offset_right = 885.0
|
||||
offset_bottom = 574.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
script = ExtResource("1_usfft")
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="."]
|
||||
custom_minimum_size = Vector2(20, 0)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBC" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="VBC"]
|
||||
custom_minimum_size = Vector2(0, 20)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBC" type="HBoxContainer" parent="VBC"]
|
||||
layout_mode = 2
|
||||
|
||||
|
|
@ -77,6 +71,7 @@ layout_mode = 2
|
|||
|
||||
[node name="SpawnQty" type="LineEdit" parent="VBC/HBC4"]
|
||||
layout_mode = 2
|
||||
text = "1"
|
||||
script = ExtResource("3_qw7ts")
|
||||
metadata/_custom_type_script = "uid://bpv75ucqoy446"
|
||||
|
||||
|
|
@ -116,6 +111,7 @@ size_flags_vertical = 3
|
|||
[node name="WaveContainer" type="TabContainer" parent="VBC/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
current_tab = 0
|
||||
clip_tabs = false
|
||||
drag_to_rearrange_enabled = true
|
||||
|
||||
|
|
|
|||
11
enemies/Scenes/enemy-a.tscn
Normal file
11
enemies/Scenes/enemy-a.tscn
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://1kwye5yjf40d"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dg8bjkjuddnhg" path="res://Enemies/enemy.tscn" id="1_etkvv"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_iay87"]
|
||||
viewport_path = NodePath("Enemy/HealthBar3D/SubViewport")
|
||||
|
||||
[node name="PathFollow3D" instance=ExtResource("1_etkvv")]
|
||||
|
||||
[node name="HealthBar3D" parent="Enemy" index="2"]
|
||||
texture = SubResource("ViewportTexture_iay87")
|
||||
19
enemies/Scenes/enemy-b.tscn
Normal file
19
enemies/Scenes/enemy-b.tscn
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://r6tj7jprdqib"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dg8bjkjuddnhg" path="res://Enemies/enemy.tscn" id="1_f3rau"]
|
||||
[ext_resource type="Texture2D" uid="uid://drbtkux8n3h8w" path="res://Assets/Characters/72 Character Free/Char 2/Character 5.png" id="2_1clf0"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_4jfoj"]
|
||||
viewport_path = NodePath("Enemy/HealthBar3D/SubViewport")
|
||||
|
||||
[node name="PathFollow3D" instance=ExtResource("1_f3rau")]
|
||||
|
||||
[node name="Enemy" parent="." index="0"]
|
||||
max_life = 20
|
||||
money = 10
|
||||
|
||||
[node name="Sprite3D" parent="Enemy" index="1"]
|
||||
texture = ExtResource("2_1clf0")
|
||||
|
||||
[node name="HealthBar3D" parent="Enemy" index="2"]
|
||||
texture = SubResource("ViewportTexture_4jfoj")
|
||||
22
enemies/Scenes/enemy-c.tscn
Normal file
22
enemies/Scenes/enemy-c.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://koikfh03qv7"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dg8bjkjuddnhg" path="res://Enemies/enemy.tscn" id="1_bh28l"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqxsaoeb5kcxp" path="res://Assets/Characters/72 Character Free/Char 3/Character 9.png" id="2_qtaxa"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_qtaxa"]
|
||||
viewport_path = NodePath("Enemy/HealthBar3D/SubViewport")
|
||||
|
||||
[node name="PathFollow3D" instance=ExtResource("1_bh28l")]
|
||||
|
||||
[node name="Enemy" parent="." index="0"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0)
|
||||
base_attack_damage = 5
|
||||
max_life = 20
|
||||
money = 50
|
||||
|
||||
[node name="Sprite3D" parent="Enemy" index="1"]
|
||||
transform = Transform3D(1.8, 0, 0, 0, 1.8, 0, 0, 0, 1.8, 0, 0, 0)
|
||||
texture = ExtResource("2_qtaxa")
|
||||
|
||||
[node name="HealthBar3D" parent="Enemy" index="2"]
|
||||
texture = SubResource("ViewportTexture_qtaxa")
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dknt1oiyei5e5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dg6f6na1nn2c6" path="res://enemies/enemy.gd" id="1_l7e03"]
|
||||
[ext_resource type="Texture2D" uid="uid://db2efj41fwjee" path="res://Assets/Characters/72 Character Free/Char 1/Character 1.png" id="2_cmo2f"]
|
||||
[ext_resource type="PackedScene" uid="uid://daiqb0q373002" path="res://UI/health_bar_3d.tscn" id="3_cmo2f"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_7frlh"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_cmo2f"]
|
||||
radius = 1.0
|
||||
|
||||
[node name="PathFollow3D" type="PathFollow3D"]
|
||||
|
||||
[node name="EnemyA" type="CharacterBody3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
script = ExtResource("1_l7e03")
|
||||
speed = 1
|
||||
max_life = 5
|
||||
money = 5
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyA"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0491967, 0)
|
||||
shape = SubResource("SphereShape3D_7frlh")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="EnemyA"]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, -0.0436401, 0)
|
||||
billboard = 2
|
||||
texture = ExtResource("2_cmo2f")
|
||||
hframes = 12
|
||||
vframes = 22
|
||||
|
||||
[node name="HealthBar3D" parent="EnemyA" instance=ExtResource("3_cmo2f")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
|
||||
visible = false
|
||||
|
||||
[node name="AttackRange" type="Area3D" parent="EnemyA"]
|
||||
collision_layer = 8
|
||||
collision_mask = 8
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyA/AttackRange"]
|
||||
shape = SubResource("SphereShape3D_cmo2f")
|
||||
debug_color = Color(0.994297, 0, 0.224345, 0.42)
|
||||
|
||||
[node name="AttackCooldown" type="Timer" parent="EnemyA"]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="body_entered" from="EnemyA/AttackRange" to="EnemyA" method="_on_attack_range_body_entered"]
|
||||
[connection signal="body_exited" from="EnemyA/AttackRange" to="EnemyA" method="_on_attack_range_body_exited"]
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://cyvhv1ih2s762"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dg6f6na1nn2c6" path="res://enemies/enemy.gd" id="1_s3rvm"]
|
||||
[ext_resource type="Texture2D" uid="uid://drbtkux8n3h8w" path="res://Assets/Characters/72 Character Free/Char 2/Character 5.png" id="2_s3rvm"]
|
||||
[ext_resource type="PackedScene" uid="uid://daiqb0q373002" path="res://UI/health_bar_3d.tscn" id="3_jdhd0"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_7frlh"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_cmo2f"]
|
||||
radius = 1.0
|
||||
|
||||
[node name="PathFollow3D" type="PathFollow3D"]
|
||||
|
||||
[node name="EnemyB" type="CharacterBody3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
script = ExtResource("1_s3rvm")
|
||||
speed = 1
|
||||
max_life = 20
|
||||
money = 10
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyB"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0491967, 0)
|
||||
shape = SubResource("SphereShape3D_7frlh")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="EnemyB"]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, -0.0436401, 0)
|
||||
billboard = 2
|
||||
texture = ExtResource("2_s3rvm")
|
||||
hframes = 12
|
||||
vframes = 22
|
||||
|
||||
[node name="HealthBar3D" parent="EnemyB" instance=ExtResource("3_jdhd0")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
|
||||
visible = false
|
||||
|
||||
[node name="AttackRange" type="Area3D" parent="EnemyB"]
|
||||
collision_layer = 8
|
||||
collision_mask = 8
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyB/AttackRange"]
|
||||
shape = SubResource("SphereShape3D_cmo2f")
|
||||
debug_color = Color(0.994297, 0, 0.224345, 0.42)
|
||||
|
||||
[node name="AttackCooldown" type="Timer" parent="EnemyB"]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="body_entered" from="EnemyB/AttackRange" to="EnemyB" method="_on_attack_range_body_entered"]
|
||||
[connection signal="body_exited" from="EnemyB/AttackRange" to="EnemyB" method="_on_attack_range_body_exited"]
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://bou5xlp2ob68c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dg6f6na1nn2c6" path="res://enemies/enemy.gd" id="1_156y0"]
|
||||
[ext_resource type="Texture2D" uid="uid://dqxsaoeb5kcxp" path="res://Assets/Characters/72 Character Free/Char 3/Character 9.png" id="2_156y0"]
|
||||
[ext_resource type="PackedScene" uid="uid://daiqb0q373002" path="res://UI/health_bar_3d.tscn" id="3_4pr72"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_7frlh"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_cmo2f"]
|
||||
radius = 1.0
|
||||
|
||||
[node name="PathFollow3D" type="PathFollow3D"]
|
||||
|
||||
[node name="EnemyC" type="CharacterBody3D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
script = ExtResource("1_156y0")
|
||||
speed = 1
|
||||
base_attack_damage = 5
|
||||
max_life = 20
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyC"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0491967, 0)
|
||||
shape = SubResource("SphereShape3D_7frlh")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="EnemyC"]
|
||||
transform = Transform3D(1.8, 0, 0, 0, 1.8, 0, 0, 0, 1.8, 0, -0.0141975, 0)
|
||||
billboard = 2
|
||||
texture = ExtResource("2_156y0")
|
||||
hframes = 12
|
||||
vframes = 22
|
||||
|
||||
[node name="HealthBar3D" parent="EnemyC" instance=ExtResource("3_4pr72")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
|
||||
visible = false
|
||||
|
||||
[node name="AttackRange" type="Area3D" parent="EnemyC"]
|
||||
collision_layer = 8
|
||||
collision_mask = 8
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="EnemyC/AttackRange"]
|
||||
shape = SubResource("SphereShape3D_cmo2f")
|
||||
debug_color = Color(0.994297, 0, 0.224345, 0.42)
|
||||
|
||||
[node name="AttackCooldown" type="Timer" parent="EnemyC"]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="body_entered" from="EnemyC/AttackRange" to="EnemyC" method="_on_attack_range_body_entered"]
|
||||
[connection signal="body_exited" from="EnemyC/AttackRange" to="EnemyC" method="_on_attack_range_body_exited"]
|
||||
|
|
@ -6,10 +6,10 @@ signal died
|
|||
@onready var death_vfx_packed : PackedScene = preload("res://VFX/death_particles.tscn")
|
||||
@onready var sad_vfx_packed : PackedScene = preload("res://VFX/sad_particles.tscn")
|
||||
|
||||
@export var speed : int = 2
|
||||
@export var speed : int = 1
|
||||
@export var base_attack_damage : int = 1
|
||||
@export var max_life : int = 10
|
||||
@export var money : int = 50
|
||||
@export var max_life : int = 5
|
||||
@export var money : int = 5
|
||||
|
||||
var health : int = 0 :
|
||||
set(value):
|
||||
|
|
@ -18,6 +18,7 @@ var health : int = 0 :
|
|||
death()
|
||||
|
||||
@onready var Path : PathFollow3D = get_parent()
|
||||
@onready var healthBar : ProgressBar = $HealthBar3D/SubViewport/HealthBar2D
|
||||
|
||||
var attack_target : Node3D :
|
||||
set(value):
|
||||
|
|
@ -31,7 +32,8 @@ var is_alive : bool = true
|
|||
var movement_stop : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
$HealthBar3D.set_up(health, max_life)
|
||||
healthBar.value = health
|
||||
healthBar.max_value = max_life
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
|
@ -46,7 +48,8 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
func take_damage(damage : int) -> void:
|
||||
health += damage
|
||||
$HealthBar3D.update(health)
|
||||
healthBar.visible = true
|
||||
healthBar.value = health
|
||||
|
||||
func attack():
|
||||
if $AttackCooldown.is_stopped():
|
||||
|
|
|
|||
84
enemies/enemy.tscn
Normal file
84
enemies/enemy.tscn
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://dg8bjkjuddnhg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dg6f6na1nn2c6" path="res://Enemies/Enemy.gd" id="1_orwns"]
|
||||
[ext_resource type="Texture2D" uid="uid://db2efj41fwjee" path="res://Assets/Characters/72 Character Free/Char 1/Character 1.png" id="2_a6vjd"]
|
||||
[ext_resource type="Script" uid="uid://blnmjxmusrsa7" path="res://UI/GameStyleBoxFlat.gd" id="3_07tka"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_7frlh"]
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_cmo2f"]
|
||||
viewport_path = NodePath("Enemy/HealthBar3D/SubViewport")
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cmo2f"]
|
||||
bg_color = Color(0.341, 0.082, 0.094, 0)
|
||||
script = ExtResource("3_07tka")
|
||||
color = 3
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d6lpy"]
|
||||
bg_color = Color(0.921569, 0.419608, 0.415686, 1)
|
||||
script = ExtResource("3_07tka")
|
||||
color = 0
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_cmo2f"]
|
||||
radius = 1.0
|
||||
|
||||
[node name="PathFollow3D" type="PathFollow3D"]
|
||||
|
||||
[node name="Enemy" type="CharacterBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0)
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
script = ExtResource("1_orwns")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Enemy"]
|
||||
shape = SubResource("SphereShape3D_7frlh")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="Enemy"]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1.5, 0, 0, 0, 1.5, 0, 0, 0)
|
||||
billboard = 2
|
||||
texture = ExtResource("2_a6vjd")
|
||||
hframes = 12
|
||||
vframes = 22
|
||||
|
||||
[node name="HealthBar3D" type="Sprite3D" parent="Enemy"]
|
||||
transform = Transform3D(0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 0, 0.33, 0)
|
||||
visible = false
|
||||
billboard = 2
|
||||
texture = SubResource("ViewportTexture_cmo2f")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="Enemy/HealthBar3D"]
|
||||
size = Vector2i(100, 12)
|
||||
size_2d_override_stretch = true
|
||||
|
||||
[node name="HealthBar2D" type="ProgressBar" parent="Enemy/HealthBar3D/SubViewport"]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -48.0
|
||||
offset_top = -4.0
|
||||
offset_right = 48.0
|
||||
offset_bottom = 4.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_cmo2f")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_d6lpy")
|
||||
show_percentage = false
|
||||
metadata/_custom_type_script = "uid://blnmjxmusrsa7"
|
||||
|
||||
[node name="AttackRange" type="Area3D" parent="Enemy"]
|
||||
collision_layer = 8
|
||||
collision_mask = 8
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Enemy/AttackRange"]
|
||||
shape = SubResource("SphereShape3D_cmo2f")
|
||||
debug_color = Color(0.994297, 0, 0.224345, 0.42)
|
||||
|
||||
[node name="AttackCooldown" type="Timer" parent="Enemy"]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="body_entered" from="Enemy/AttackRange" to="Enemy" method="_on_attack_range_body_entered"]
|
||||
[connection signal="body_exited" from="Enemy/AttackRange" to="Enemy" method="_on_attack_range_body_exited"]
|
||||
|
|
@ -34,11 +34,19 @@ enabled=PackedStringArray("res://addons/LevelEditor/plugin.cfg", "res://addons/s
|
|||
|
||||
folder_colors={
|
||||
"res://Assets/": "green",
|
||||
"res://Enemies/": "red",
|
||||
"res://Enemies/Scenes/": "pink",
|
||||
"res://Globals/": "blue",
|
||||
"res://Projectiles/": "orange",
|
||||
"res://Tiles/": "orange",
|
||||
"res://Levels/": "yellow",
|
||||
"res://Levels/Scripts/": "blue",
|
||||
"res://Tiles/": "yellow",
|
||||
"res://Towers/": "orange",
|
||||
"res://Upgrades/": "pink",
|
||||
"res://Towers/Projectiles/": "orange",
|
||||
"res://Towers/Scenes": "pink",
|
||||
"res://Towers/Scenes/": "pink",
|
||||
"res://Towers/Scripts/": "blue",
|
||||
"res://UI/": "green",
|
||||
"res://Upgrades/": "purple",
|
||||
"res://Waves/": "pink",
|
||||
"res://enemies/": "orange"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue