add resource for projectile
This commit is contained in:
parent
26391cd7b2
commit
740d979efa
16 changed files with 98 additions and 82 deletions
|
|
@ -1,30 +1,10 @@
|
||||||
[gd_resource type="Resource" script_class="Level" load_steps=3 format=3 uid="uid://hlv6kd67wipi"]
|
[gd_resource type="Resource" script_class="Level" load_steps=3 format=3 uid="uid://hlv6kd67wipi"]
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_5jnuq"]
|
[ext_resource type="Script" uid="uid://cuhq6u67cbbqm" path="res://Scripts/Level/Level.gd" id="1_e3k30"]
|
||||||
script/source = "@tool
|
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Level/Wave.gd" id="2_8ao5l"]
|
||||||
extends Resource
|
|
||||||
class_name Level
|
|
||||||
|
|
||||||
@export var waves : Array[Wave]
|
|
||||||
@export var auto_start : bool = false
|
|
||||||
@export var allowedTowers : Array[Tower.TYPES] : set = allowedTowersHasChanged
|
|
||||||
|
|
||||||
|
|
||||||
func allowedTowersHasChanged(value) -> void:
|
|
||||||
allowedTowers = value
|
|
||||||
if Engine.is_editor_hint():
|
|
||||||
EventBus.allowedTowerHasChange.emit(allowedTowers)
|
|
||||||
"
|
|
||||||
|
|
||||||
[sub_resource type="GDScript" id="GDScript_h3rs5"]
|
|
||||||
script/source = "extends Resource
|
|
||||||
class_name Wave
|
|
||||||
|
|
||||||
@export var troops : Array[Troop]
|
|
||||||
"
|
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = SubResource("GDScript_5jnuq")
|
script = ExtResource("1_e3k30")
|
||||||
waves = Array[SubResource("GDScript_h3rs5")]([])
|
waves = Array[ExtResource("2_8ao5l")]([])
|
||||||
auto_start = false
|
auto_start = false
|
||||||
allowedTowers = Array[int]([])
|
allowedTowers = Array[int]([])
|
||||||
|
|
|
||||||
|
|
@ -4,3 +4,8 @@ var selected_collider : CollisionObject3D
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$WaveManager.spawn_next_wave()
|
$WaveManager.spawn_next_wave()
|
||||||
|
EventBus.projectile_shooted.connect(onProjectileShooted)
|
||||||
|
|
||||||
|
|
||||||
|
func onProjectileShooted(projectile : Projectile) -> void:
|
||||||
|
add_child(projectile)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=14 format=3 uid="uid://ky0uewndeuwv"]
|
[gd_scene load_steps=13 format=3 uid="uid://ky0uewndeuwv"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://Levels/world.gd" id="1_fj7yv"]
|
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://Levels/world.gd" id="1_fj7yv"]
|
||||||
[ext_resource type="Texture2D" uid="uid://o83munu8dibp" path="res://Assets/Icones/kenney_game_icons_vector.svg" id="3_ikoig"]
|
[ext_resource type="Texture2D" uid="uid://o83munu8dibp" path="res://Assets/Icones/kenney_game_icons_vector.svg" id="3_ikoig"]
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
[ext_resource type="Resource" uid="uid://ob41fnhkjr3o" path="res://Levels/level_1.tres" id="8_44brb"]
|
[ext_resource type="Resource" uid="uid://ob41fnhkjr3o" path="res://Levels/level_1.tres" id="8_44brb"]
|
||||||
[ext_resource type="PackedScene" uid="uid://gp46cl8euhyf" path="res://Levels/map_1.tscn" id="8_rljl1"]
|
[ext_resource type="PackedScene" uid="uid://gp46cl8euhyf" path="res://Levels/map_1.tscn" id="8_rljl1"]
|
||||||
[ext_resource type="PackedScene" uid="uid://p6a6rb7sgeqd" path="res://UI/gui.tscn" id="12_ikoig"]
|
[ext_resource type="PackedScene" uid="uid://p6a6rb7sgeqd" path="res://UI/gui.tscn" id="12_ikoig"]
|
||||||
[ext_resource type="Script" uid="uid://xkk2pxkrwsq8" path="res://bullet_container.gd" id="12_k3n1d"]
|
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_oyb16"]
|
[sub_resource type="Animation" id="Animation_oyb16"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
|
|
@ -114,9 +113,6 @@ light_energy = 0.0
|
||||||
|
|
||||||
[node name="GUI" parent="CanvasLayer" instance=ExtResource("12_ikoig")]
|
[node name="GUI" parent="CanvasLayer" instance=ExtResource("12_ikoig")]
|
||||||
|
|
||||||
[node name="BulletContainer" type="Node3D" parent="."]
|
|
||||||
script = ExtResource("12_k3n1d")
|
|
||||||
|
|
||||||
[node name="Towers" type="Node3D" parent="."]
|
[node name="Towers" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Map1" parent="." instance=ExtResource("8_rljl1")]
|
[node name="Map1" parent="." instance=ExtResource("8_rljl1")]
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,20 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
class_name Projectile
|
class_name Projectile
|
||||||
|
|
||||||
const ENEMY : int = 1
|
const TARGET_ENEMY : int = 1 ## Flag to target enemy
|
||||||
const ALLY : int = 2
|
const TARGET_ALLY : int = 2 ## Flag to target ally
|
||||||
|
|
||||||
const MINIMUN_AREA : float = .1
|
const MINIMUN_AREA : float = .1
|
||||||
|
|
||||||
@export var speed : int = 20
|
var speed : int = 20
|
||||||
@export_range(MINIMUN_AREA, 1000) var radius : float = MINIMUN_AREA
|
var isAOE : bool = false
|
||||||
@export var isAOE := false
|
var allowedTargets : int = TARGET_ENEMY
|
||||||
@export_flags("Enemies", "Alliés") var allowedTargets : int = ENEMY
|
|
||||||
|
|
||||||
|
|
||||||
@onready var projectileArea : CollisionShape3D = $Impact/ProjectileArea
|
|
||||||
@onready var projectileSize : CollisionShape3D = $Impact/ProjectileSize
|
|
||||||
|
|
||||||
|
|
||||||
var target : PhysicsBody3D
|
var target : PhysicsBody3D
|
||||||
var damage : int = 1
|
var damage : int = 1
|
||||||
var bodiesInRange : Array[Node3D]
|
|
||||||
var enemiesInRange : Array[Enemy]
|
var enemiesInRange : Array[Enemy]
|
||||||
var allyInRange : Array[Tower]
|
var allyInRange : Array[Tower]
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
enemiesInRange.append(target)
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
if is_instance_valid(target):
|
if is_instance_valid(target):
|
||||||
velocity = global_position.direction_to(target.global_position) * speed
|
velocity = global_position.direction_to(target.global_position) * speed
|
||||||
|
|
@ -38,7 +26,6 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func onBodyEnteredDamageArea(body: Node3D) -> void:
|
func onBodyEnteredDamageArea(body: Node3D) -> void:
|
||||||
print(body.get_class())
|
|
||||||
if isAOE && targetable(body):
|
if isAOE && targetable(body):
|
||||||
if body is Enemy:
|
if body is Enemy:
|
||||||
enemiesInRange.append(body)
|
enemiesInRange.append(body)
|
||||||
|
|
@ -46,7 +33,7 @@ func onBodyEnteredDamageArea(body: Node3D) -> void:
|
||||||
allyInRange.append(body)
|
allyInRange.append(body)
|
||||||
|
|
||||||
|
|
||||||
func OnBodyExitedDamageArea(body: Node3D) -> void:
|
func onBodyExitedDamageArea(body: Node3D) -> void:
|
||||||
if body is Enemy:
|
if body is Enemy:
|
||||||
enemiesInRange.erase(body)
|
enemiesInRange.erase(body)
|
||||||
if body is Tower:
|
if body is Tower:
|
||||||
|
|
@ -60,15 +47,26 @@ func onBodyCollideWithProjectile(body : Node3D) -> void:
|
||||||
|
|
||||||
func targetable(body: Node3D) -> bool:
|
func targetable(body: Node3D) -> bool:
|
||||||
if body is Enemy:
|
if body is Enemy:
|
||||||
return ENEMY & allowedTargets
|
return TARGET_ENEMY & allowedTargets
|
||||||
if body is Tower:
|
if body is Tower:
|
||||||
return ALLY & allowedTargets
|
return TARGET_ALLY & allowedTargets
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
func resolveDamages() -> void:
|
func resolveDamages() -> void:
|
||||||
print(enemiesInRange)
|
|
||||||
for enemy in enemiesInRange:
|
for enemy in enemiesInRange:
|
||||||
enemy.take_damage(damage)
|
enemy.take_damage(damage)
|
||||||
queue_free()
|
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
|
||||||
|
|
|
||||||
10
Projectiles/ProjectileResource.gd
Normal file
10
Projectiles/ProjectileResource.gd
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
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
Projectiles/ProjectileResource.gd.uid
Normal file
1
Projectiles/ProjectileResource.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://ddgbr0n8kic3y
|
||||||
|
|
@ -7,11 +7,10 @@
|
||||||
radius = 0.1
|
radius = 0.1
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_dsts2"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_dsts2"]
|
||||||
radius = 1.5
|
radius = 0.1
|
||||||
|
|
||||||
[node name="Projectile" type="CharacterBody3D"]
|
[node name="Projectile" type="CharacterBody3D"]
|
||||||
script = ExtResource("1_ggq0q")
|
script = ExtResource("1_ggq0q")
|
||||||
speed = 10
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
shape = SubResource("SphereShape3D_r5o86")
|
shape = SubResource("SphereShape3D_r5o86")
|
||||||
|
|
@ -34,9 +33,8 @@ collision_layer = 4
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
|
|
||||||
[node name="ProjectileArea" type="CollisionShape3D" parent="DamageArea"]
|
[node name="ProjectileArea" type="CollisionShape3D" parent="DamageArea"]
|
||||||
shape = SubResource("SphereShape3D_dsts2")
|
|
||||||
debug_color = Color(0.926858, 0.237749, 0.335021, 0.42)
|
debug_color = Color(0.926858, 0.237749, 0.335021, 0.42)
|
||||||
|
|
||||||
[connection signal="body_entered" from="HitBox" to="." method="onBodyCollideWithProjectile" flags=3]
|
[connection signal="body_entered" from="HitBox" to="." method="onBodyCollideWithProjectile" flags=3]
|
||||||
[connection signal="body_entered" from="DamageArea" to="." method="onBodyEnteredDamageArea"]
|
[connection signal="body_entered" from="DamageArea" to="." method="onBodyEnteredDamageArea"]
|
||||||
[connection signal="body_exited" from="DamageArea" to="." method="OnBodyExitedDamageArea"]
|
[connection signal="body_exited" from="DamageArea" to="." method="onBodyExitedDamageArea"]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ var _state := STATE.IDLE
|
||||||
var selected_tower_type : Tower.TYPE = Tower.TYPE.NONE
|
var selected_tower_type : Tower.TYPE = Tower.TYPE.NONE
|
||||||
|
|
||||||
@onready var cam : Camera3D = $"../Camera3D"
|
@onready var cam : Camera3D = $"../Camera3D"
|
||||||
@onready var the_cube : TheCube = %TheCube
|
@onready var the_cube : TheCube = $"../Map1/TheCube"
|
||||||
@onready var selection_icon : Sprite3D = $Sprite3DSelection
|
@onready var selection_icon : Sprite3D = $Sprite3DSelection
|
||||||
|
|
||||||
var towers : Dictionary
|
var towers : Dictionary
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,25 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://ck1qryleu80s"]
|
[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="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="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="Texture2D" uid="uid://cob1lydkirn20" path="res://Assets/Icones/raccoon-head.svg" id="3_6h033"]
|
||||||
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_p2nb1"]
|
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_p2nb1"]
|
||||||
|
[ext_resource type="Script" uid="uid://ddgbr0n8kic3y" path="res://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://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
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_lhd8w"]
|
||||||
|
script = ExtResource("4_ck6a3")
|
||||||
|
speed = 20
|
||||||
|
damage = 10
|
||||||
|
isAOE = true
|
||||||
|
allowedTargets = 1
|
||||||
|
damageArea = SubResource("SphereShape3D_lhd8w")
|
||||||
|
sprite = ExtResource("5_lhd8w")
|
||||||
|
metadata/_custom_type_script = "uid://ddgbr0n8kic3y"
|
||||||
|
|
||||||
[node name="Aline" instance=ExtResource("1_gvvig")]
|
[node name="Aline" instance=ExtResource("1_gvvig")]
|
||||||
script = ExtResource("2_6sjqq")
|
script = ExtResource("2_6sjqq")
|
||||||
|
|
@ -13,10 +28,11 @@ tower_type = 2
|
||||||
icone = ExtResource("3_6h033")
|
icone = ExtResource("3_6h033")
|
||||||
bio = ""
|
bio = ""
|
||||||
price = 150
|
price = 150
|
||||||
bullet_damage = 10
|
projectileRessource = SubResource("Resource_lhd8w")
|
||||||
|
action_cooldown = 2.5
|
||||||
energy_cost = 25.0
|
energy_cost = 25.0
|
||||||
tower_shop = Array[ExtResource("3_p2nb1")]([])
|
tower_shop = Array[ExtResource("3_p2nb1")]([])
|
||||||
|
|
||||||
[node name="Sprite3D" parent="." index="6"]
|
[node name="Sprite3D" parent="." index="5"]
|
||||||
texture = ExtResource("5_l514g")
|
texture = ExtResource("5_l514g")
|
||||||
frame = 10
|
frame = 10
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,20 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://c4ta0aynybpis"]
|
[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="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="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="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://Scripts/Upgrades/TowerUpgrade.gd" id="4_v32j5"]
|
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://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")]
|
[node name="Evan" instance=ExtResource("1_yctfx")]
|
||||||
script = ExtResource("2_fuecn")
|
script = ExtResource("2_fuecn")
|
||||||
|
|
@ -11,5 +22,5 @@ tower_name = "Evan"
|
||||||
tower_type = 5
|
tower_type = 5
|
||||||
icone = ExtResource("3_nvfjk")
|
icone = ExtResource("3_nvfjk")
|
||||||
bio = ""
|
bio = ""
|
||||||
bullet_damage = 1
|
projectileRessource = SubResource("Resource_ykufo")
|
||||||
tower_shop = Array[ExtResource("4_v32j5")]([])
|
tower_shop = Array[ExtResource("4_v32j5")]([])
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,19 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bj6srer7ghf7p"]
|
[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="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="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="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")]
|
[node name="Pierre" instance=ExtResource("1_7f7qx")]
|
||||||
script = ExtResource("1_v16mf")
|
script = ExtResource("1_v16mf")
|
||||||
|
|
@ -10,6 +21,7 @@ tower_name = "Pierre"
|
||||||
tower_type = 1
|
tower_type = 1
|
||||||
icone = ExtResource("3_odfqx")
|
icone = ExtResource("3_odfqx")
|
||||||
bio = null
|
bio = null
|
||||||
|
projectileRessource = SubResource("Resource_3ht5a")
|
||||||
action_cooldown = 1.0
|
action_cooldown = 1.0
|
||||||
max_energy = 50.0
|
max_energy = 50.0
|
||||||
energy_regen = 5.0
|
energy_regen = 5.0
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,16 @@ class_name Tower
|
||||||
# DANGER "NONE" Should always be first
|
# DANGER "NONE" Should always be first
|
||||||
enum TYPE { NONE, PIERRE, ALINE, MAXENCE, VICTORIA, EVAN, ALEX, GERALDINE }
|
enum TYPE { NONE, PIERRE, ALINE, MAXENCE, VICTORIA, EVAN, ALEX, GERALDINE }
|
||||||
|
|
||||||
var projectile : PackedScene = preload("res://Projectiles/projectile.tscn")
|
var projectileScene : PackedScene = preload("res://Projectiles/projectile.tscn")
|
||||||
|
|
||||||
@export var tower_name : String = "None"
|
@export var tower_name : String = "None"
|
||||||
@export var tower_type : TYPE
|
@export var tower_type : TYPE
|
||||||
@export var icone : Texture2D
|
@export var icone : Texture2D
|
||||||
@export var bio : String
|
@export var bio : String
|
||||||
|
|
||||||
@export var price : int = 100
|
@export var price : int = 100
|
||||||
|
|
||||||
@export_group("Attack")
|
@export_group("Attack")
|
||||||
@export var projectile_damage : int = 1
|
@export var projectileRessource : ProjectileResource
|
||||||
@export var action_cooldown : float = 1.5:
|
@export var action_cooldown : float = 1.5:
|
||||||
set(value):
|
set(value):
|
||||||
action_cooldown = clamp(value, 0.3, 999)
|
action_cooldown = clamp(value, 0.3, 999)
|
||||||
|
|
@ -103,10 +103,8 @@ func _process(delta: float) -> void:
|
||||||
func shoot() -> void:
|
func shoot() -> void:
|
||||||
energy -= energy_cost
|
energy -= energy_cost
|
||||||
|
|
||||||
var projectile : Projectile = projectile.instantiate()
|
var projectile : Projectile = projectileScene.instantiate()
|
||||||
projectile.target = current
|
projectile.loadProjectile(projectileRessource, $Aim.global_position, current)
|
||||||
projectile.damage = projectile_damage
|
|
||||||
projectile.global_position = $Aim.global_position
|
|
||||||
EventBus.projectile_shooted.emit(projectile)
|
EventBus.projectile_shooted.emit(projectile)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=10 format=3 uid="uid://trg7ag3dqr2l"]
|
[gd_scene load_steps=10 format=3 uid="uid://trg7ag3dqr2l"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://8kpvuurr5h5n" path="res://Towers/tower.gd" id="1_egfuc"]
|
[ext_resource type="Script" uid="uid://8kpvuurr5h5n" path="res://Towers/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://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="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://Scripts/Upgrades/TowerUpgrade.gd" id="3_5dr1v"]
|
[ext_resource type="Script" uid="uid://bg0x4egeu17qb" path="res://Scripts/Upgrades/TowerUpgrade.gd" id="3_5dr1v"]
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ func _on_button_quit_game_pressed() -> void:
|
||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
func allowedTowerHasChange(allowedTowers : Array[Tower.TYPE]) -> void:
|
func allowedTowerHasChange(_allowedTowers : Array[Tower.TYPE]) -> void:
|
||||||
self.allowedTowers = allowedTowers
|
allowedTowers = _allowedTowers
|
||||||
if is_node_ready():
|
if is_node_ready():
|
||||||
addTowerButtonNodes()
|
addTowerButtonNodes()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
extends Node3D
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
EventBus.projectile_shooted.connect(_on_EventBus_projectile_shooted)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_EventBus_projectile_shooted(projectile : Projectile) -> void:
|
|
||||||
add_child(projectile)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
uid://xkk2pxkrwsq8
|
|
||||||
Loading…
Add table
Reference in a new issue