Tower rest + The Cube damaged + movement Tower
This commit is contained in:
parent
6d1b50d0d6
commit
fd72147865
10 changed files with 130 additions and 10 deletions
18
Tiles/cube.gd
Normal file
18
Tiles/cube.gd
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
extends StaticBody3D
|
||||||
|
class_name TheCube
|
||||||
|
|
||||||
|
@export var max_life : int = 50
|
||||||
|
var health : int = max_life :
|
||||||
|
set(value):
|
||||||
|
health = value
|
||||||
|
if health <= 0:
|
||||||
|
death()
|
||||||
|
|
||||||
|
|
||||||
|
func take_damage(damage : int) -> void:
|
||||||
|
health -= damage
|
||||||
|
print(health)
|
||||||
|
|
||||||
|
|
||||||
|
func death():
|
||||||
|
print("GAME OVER")
|
||||||
1
Tiles/cube.gd.uid
Normal file
1
Tiles/cube.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bjbmd8pcg5jr8
|
||||||
17
Tiles/cube.tscn
Normal file
17
Tiles/cube.tscn
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dpjfo15otkfru"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bjbmd8pcg5jr8" path="res://Tiles/cube.gd" id="1_wrmut"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_ppsqf"]
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wrmut"]
|
||||||
|
albedo_color = Color(0.051971, 0.051971, 0.051971, 1)
|
||||||
|
|
||||||
|
[node name="TheCube" type="StaticBody3D"]
|
||||||
|
script = ExtResource("1_wrmut")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("BoxShape3D_ppsqf")
|
||||||
|
|
||||||
|
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||||
|
material = SubResource("StandardMaterial3D_wrmut")
|
||||||
|
|
@ -13,6 +13,7 @@ radius = 3.0
|
||||||
collision_layer = 4
|
collision_layer = 4
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
script = ExtResource("1_pb6ru")
|
script = ExtResource("1_pb6ru")
|
||||||
|
tower_name = "Aline"
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00914001, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00914001, 0)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ extends StaticBody3D
|
||||||
class_name Tower
|
class_name Tower
|
||||||
|
|
||||||
var bullet : PackedScene = preload("res://Bullets/arrow.tscn")
|
var bullet : PackedScene = preload("res://Bullets/arrow.tscn")
|
||||||
|
@export var tower_name : String = "Pierre"
|
||||||
@export var bullet_damage : int = 1
|
@export var bullet_damage : int = 1
|
||||||
|
@export var energy : float = 100.0 #Next thing to do
|
||||||
var current_targets : Array = []
|
var current_targets : Array = []
|
||||||
var current : CharacterBody3D
|
var current : CharacterBody3D
|
||||||
var can_shoot : bool = true
|
var can_shoot : bool = true
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://dknt1oiyei5e5"]
|
[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="Script" uid="uid://dg6f6na1nn2c6" path="res://enemies/enemy.gd" id="1_l7e03"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bn6ikwol6x8r0" path="res://Assets/Characters/Male1.png" id="2_l7e03"]
|
[ext_resource type="Texture2D" uid="uid://bn6ikwol6x8r0" path="res://Assets/Characters/Male1.png" id="2_l7e03"]
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_7frlh"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_7frlh"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_cmo2f"]
|
||||||
|
radius = 1.0
|
||||||
|
|
||||||
[node name="PathFollow3D" type="PathFollow3D"]
|
[node name="PathFollow3D" type="PathFollow3D"]
|
||||||
|
|
||||||
[node name="EnemyA" type="CharacterBody3D" parent="."]
|
[node name="EnemyA" type="CharacterBody3D" parent="."]
|
||||||
|
|
@ -25,3 +28,13 @@ vframes = 12
|
||||||
|
|
||||||
[node name="HealthBar3D" parent="EnemyA" instance=ExtResource("3_cmo2f")]
|
[node name="HealthBar3D" parent="EnemyA" instance=ExtResource("3_cmo2f")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
|
||||||
|
|
||||||
|
[node name="AttackRange" type="Area3D" parent="EnemyA"]
|
||||||
|
|
||||||
|
[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"]
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="EnemyA/AttackRange" to="EnemyA" method="_on_attack_range_body_entered"]
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ class_name Enemy
|
||||||
@onready var sad_vfx_packed : PackedScene = preload("res://VFX/sad_particles.tscn")
|
@onready var sad_vfx_packed : PackedScene = preload("res://VFX/sad_particles.tscn")
|
||||||
|
|
||||||
@export var speed : int = 2
|
@export var speed : int = 2
|
||||||
|
@export var base_attack_damage : int = 1
|
||||||
@export var max_life : int = 10
|
@export var max_life : int = 10
|
||||||
var health : int = 0 :
|
var health : int = 0 :
|
||||||
set(value):
|
set(value):
|
||||||
|
|
@ -14,7 +15,16 @@ var health : int = 0 :
|
||||||
|
|
||||||
@onready var Path : PathFollow3D = get_parent()
|
@onready var Path : PathFollow3D = get_parent()
|
||||||
|
|
||||||
|
var attack_target : Node3D :
|
||||||
|
set(value):
|
||||||
|
attack_target = value
|
||||||
|
if value:
|
||||||
|
movement_stop = true
|
||||||
|
else:
|
||||||
|
movement_stop = false
|
||||||
|
|
||||||
var is_alive : bool = true
|
var is_alive : bool = true
|
||||||
|
var movement_stop : bool = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$HealthBar3D.set_up(health, max_life)
|
$HealthBar3D.set_up(health, max_life)
|
||||||
|
|
@ -24,17 +34,21 @@ func _physics_process(delta: float) -> void:
|
||||||
if !is_alive:
|
if !is_alive:
|
||||||
return
|
return
|
||||||
|
|
||||||
Path.set_progress(Path.get_progress() + speed * delta)
|
if not movement_stop:
|
||||||
|
Path.set_progress(Path.get_progress() + speed * delta)
|
||||||
if Path.get_progress_ratio() >= 0.99:
|
else:
|
||||||
#Global.health -= 20
|
attack()
|
||||||
death()
|
|
||||||
|
|
||||||
|
|
||||||
func take_damage(damage : int) -> void:
|
func take_damage(damage : int) -> void:
|
||||||
health += damage
|
health += damage
|
||||||
$HealthBar3D.update(health)
|
$HealthBar3D.update(health)
|
||||||
|
|
||||||
|
func attack():
|
||||||
|
if $AttackCooldown.is_stopped():
|
||||||
|
$AttackCooldown.start()
|
||||||
|
attack_target.take_damage(base_attack_damage)
|
||||||
|
|
||||||
|
|
||||||
func death() -> void:
|
func death() -> void:
|
||||||
is_alive = false
|
is_alive = false
|
||||||
|
|
@ -46,3 +60,8 @@ func death() -> void:
|
||||||
death_vfx.global_position = global_position
|
death_vfx.global_position = global_position
|
||||||
|
|
||||||
Path.queue_free()
|
Path.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_attack_range_body_entered(body: Node3D) -> void:
|
||||||
|
if body is TheCube:
|
||||||
|
attack_target = body
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ build={
|
||||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(344, 20),"global_position":Vector2(353, 68),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(344, 20),"global_position":Vector2(353, 68),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
rest={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(263, 18),"global_position":Vector2(272, 66),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
||||||
46
world.gd
46
world.gd
|
|
@ -5,6 +5,10 @@ extends Node3D
|
||||||
@onready var cam : Camera3D = $Camera3D
|
@onready var cam : Camera3D = $Camera3D
|
||||||
@onready var selector : Node3D = $Selector
|
@onready var selector : Node3D = $Selector
|
||||||
|
|
||||||
|
|
||||||
|
var team_in_action : Array[Tower]
|
||||||
|
var team_in_rest : Array[Tower]
|
||||||
|
var target_tower : Tower
|
||||||
var in_build_menu : bool = false
|
var in_build_menu : bool = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
@ -12,10 +16,13 @@ func _ready() -> void:
|
||||||
$CanvasLayer/UI/ShopPanel.visible = in_build_menu
|
$CanvasLayer/UI/ShopPanel.visible = in_build_menu
|
||||||
EventBus.tower_selected.connect(_on_EventBus_tower_selected)
|
EventBus.tower_selected.connect(_on_EventBus_tower_selected)
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
handle_player_controls()
|
handle_player_controls()
|
||||||
if Input.is_action_just_pressed("build"):
|
if Input.is_action_just_pressed("build"):
|
||||||
build_tower(tower_blueprint)
|
build_tower(tower_blueprint)
|
||||||
|
if Input.is_action_just_pressed("rest") && target_tower:
|
||||||
|
send_to_rest(target_tower)
|
||||||
|
|
||||||
|
|
||||||
func handle_player_controls() -> void:
|
func handle_player_controls() -> void:
|
||||||
|
|
@ -38,14 +45,47 @@ func handle_player_controls() -> void:
|
||||||
selector.global_position = collider.global_position
|
selector.global_position = collider.global_position
|
||||||
selector.global_position += Vector3(0.0,0.2,0.0)
|
selector.global_position += Vector3(0.0,0.2,0.0)
|
||||||
|
|
||||||
|
if collider is Tower:
|
||||||
|
target_tower = collider
|
||||||
|
else:
|
||||||
|
target_tower = null
|
||||||
|
|
||||||
|
|
||||||
func build_tower(scene : PackedScene) -> void:
|
func build_tower(scene : PackedScene) -> void:
|
||||||
if !selector.visible:
|
if !selector.visible:
|
||||||
return
|
return
|
||||||
|
var temp_tower : Tower = scene.instantiate()
|
||||||
|
|
||||||
var temp_cannon : Tower = scene.instantiate()
|
for tower : Tower in team_in_action:
|
||||||
add_child(temp_cannon)
|
if tower.tower_name == temp_tower.tower_name:
|
||||||
temp_cannon.global_position = selector.global_position
|
move_tower(tower)
|
||||||
|
return
|
||||||
|
|
||||||
|
for tower : Tower in team_in_rest:
|
||||||
|
if tower.tower_name == temp_tower.tower_name:
|
||||||
|
move_tower(tower)
|
||||||
|
send_to_action(tower)
|
||||||
|
return
|
||||||
|
|
||||||
|
add_child(temp_tower)
|
||||||
|
team_in_action.append(temp_tower)
|
||||||
|
temp_tower.global_position = selector.global_position
|
||||||
|
|
||||||
|
|
||||||
|
func move_tower(tower : Tower):
|
||||||
|
tower.global_position = selector.global_position
|
||||||
|
|
||||||
|
|
||||||
|
func send_to_rest(tower : Tower):
|
||||||
|
team_in_action.erase(tower)
|
||||||
|
team_in_rest.append(tower)
|
||||||
|
tower.visible = false
|
||||||
|
|
||||||
|
|
||||||
|
func send_to_action(tower : Tower):
|
||||||
|
team_in_rest.erase(tower)
|
||||||
|
team_in_action.append(tower)
|
||||||
|
tower.visible = true
|
||||||
|
|
||||||
|
|
||||||
func _on_EventBus_tower_selected(tower : PackedScene):
|
func _on_EventBus_tower_selected(tower : PackedScene):
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
[gd_scene load_steps=12 format=3 uid="uid://ky0uewndeuwv"]
|
[gd_scene load_steps=13 format=3 uid="uid://ky0uewndeuwv"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://world.gd" id="1_fj7yv"]
|
[ext_resource type="Script" uid="uid://qqid42jkpkmv" path="res://world.gd" id="1_fj7yv"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d1f6m15niwgt" path="res://Tiles/tile.tscn" id="3_aqk2v"]
|
[ext_resource type="PackedScene" uid="uid://d1f6m15niwgt" path="res://Tiles/tile.tscn" id="3_aqk2v"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d17sleiqkdoo2" path="res://Assets/GLB format/selection-a.glb" id="3_tlwt5"]
|
[ext_resource type="PackedScene" uid="uid://d17sleiqkdoo2" path="res://Assets/GLB format/selection-a.glb" id="3_tlwt5"]
|
||||||
[ext_resource type="PackedScene" uid="uid://do7gm1gjhu1t5" path="res://Tiles/road.tscn" id="4_036b0"]
|
[ext_resource type="PackedScene" uid="uid://do7gm1gjhu1t5" path="res://Tiles/road.tscn" id="4_036b0"]
|
||||||
[ext_resource type="Script" uid="uid://tpon511km4al" path="res://spawner.gd" id="5_036b0"]
|
[ext_resource type="Script" uid="uid://tpon511km4al" path="res://spawner.gd" id="5_036b0"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dpjfo15otkfru" path="res://Tiles/cube.tscn" id="5_wse8f"]
|
||||||
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Wave.gd" id="6_gbfbk"]
|
[ext_resource type="Script" uid="uid://chu8s12rtdeqx" path="res://Scripts/Wave.gd" id="6_gbfbk"]
|
||||||
[ext_resource type="Resource" uid="uid://dkbuy7fetnihs" path="res://Waves/wave_1.tres" id="7_ioo17"]
|
[ext_resource type="Resource" uid="uid://dkbuy7fetnihs" path="res://Waves/wave_1.tres" id="7_ioo17"]
|
||||||
[ext_resource type="Resource" uid="uid://dvw6vm3vbpmdl" path="res://Waves/wave_2.tres" id="8_wse8f"]
|
[ext_resource type="Resource" uid="uid://dvw6vm3vbpmdl" path="res://Waves/wave_2.tres" id="8_wse8f"]
|
||||||
|
|
@ -138,6 +139,9 @@ transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 9.5, 0
|
||||||
[node name="Road10" parent="Map" instance=ExtResource("4_036b0")]
|
[node name="Road10" parent="Map" instance=ExtResource("4_036b0")]
|
||||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 9.5, 0, 0.5)
|
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 9.5, 0, 0.5)
|
||||||
|
|
||||||
|
[node name="TheCube" parent="Map" instance=ExtResource("5_wse8f")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10.1496, 0.657819, 0.497613)
|
||||||
|
|
||||||
[node name="Spawner" type="Path3D" parent="."]
|
[node name="Spawner" type="Path3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
curve = SubResource("Curve3D_aqk2v")
|
curve = SubResource("Curve3D_aqk2v")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue