Add durability reduction for the tower
This commit is contained in:
parent
f0920ce37d
commit
4c37508012
10 changed files with 173 additions and 68 deletions
|
@ -91,5 +91,15 @@ shape = SubResource("CircleShape2D_wmsbt")
|
|||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
modulate = Color(0.431373, 0.815686, 0, 1)
|
||||
offset_left = 4.0
|
||||
offset_top = -15.0
|
||||
offset_right = 106.0
|
||||
offset_bottom = 12.0
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.3, 0.3)
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
|
||||
|
|
|
@ -90,5 +90,15 @@ shape = SubResource("CircleShape2D_wmsbt")
|
|||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
modulate = Color(0.431373, 0.815686, 0, 1)
|
||||
offset_left = 4.0
|
||||
offset_top = -15.0
|
||||
offset_right = 106.0
|
||||
offset_bottom = 12.0
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.3, 0.3)
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://mxre00inxhlf"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_8bvcy"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_pqmds"]
|
||||
[ext_resource type="Texture2D" uid="uid://by4hjrjfcxsdl" path="res://assets/spritesheets/towers/cannon-3.png" id="3_k5iet"]
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_pa8xy"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_gqu6e"]
|
||||
[ext_resource type="Texture2D" uid="uid://by4hjrjfcxsdl" path="res://assets/spritesheets/towers/cannon-3.png" id="3_tjfbt"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_roben"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(0, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uo3hi"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(128, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_85qm5"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(256, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tv0aa"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(384, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1ttn5"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(512, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vpsw3"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(640, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_rp8py"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(768, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e6hsk"]
|
||||
atlas = ExtResource("3_k5iet")
|
||||
atlas = ExtResource("3_tjfbt")
|
||||
region = Rect2(896, 0, 128, 128)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_ta4uo"]
|
||||
|
@ -72,8 +72,8 @@ animations = [{
|
|||
radius = 138.293
|
||||
|
||||
[node name="cannon-3" type="Node2D" groups=["Towers"]]
|
||||
script = ExtResource("1_8bvcy")
|
||||
bullet = ExtResource("2_pqmds")
|
||||
script = ExtResource("1_pa8xy")
|
||||
bullet = ExtResource("2_gqu6e")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(-1, 0)
|
||||
|
@ -90,5 +90,15 @@ shape = SubResource("CircleShape2D_wmsbt")
|
|||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
modulate = Color(0.431373, 0.815686, 0, 1)
|
||||
offset_left = 4.0
|
||||
offset_top = -15.0
|
||||
offset_right = 106.0
|
||||
offset_bottom = 12.0
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.3, 0.3)
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://biyhuyx177dw8"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_1kehv"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_stgpo"]
|
||||
[ext_resource type="Texture2D" uid="uid://c02ebkmjpxium" path="res://assets/spritesheets/towers/railgun-1.png" id="3_ibkbv"]
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_8623k"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_1uwpq"]
|
||||
[ext_resource type="Texture2D" uid="uid://c02ebkmjpxium" path="res://assets/spritesheets/towers/railgun-1.png" id="3_vo8au"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_60mof"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(0, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_etl58"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(128, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3ojyw"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(256, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4nido"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(384, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6l18x"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(512, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fcrte"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(640, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_c4er5"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(768, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v35ak"]
|
||||
atlas = ExtResource("3_ibkbv")
|
||||
atlas = ExtResource("3_vo8au")
|
||||
region = Rect2(896, 0, 128, 128)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_geya5"]
|
||||
|
@ -72,8 +72,8 @@ animations = [{
|
|||
radius = 138.293
|
||||
|
||||
[node name="railgun-1" type="Node2D" groups=["Towers"]]
|
||||
script = ExtResource("1_1kehv")
|
||||
bullet = ExtResource("2_stgpo")
|
||||
script = ExtResource("1_8623k")
|
||||
bullet = ExtResource("2_1uwpq")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(-1, 0)
|
||||
|
@ -91,5 +91,15 @@ shape = SubResource("CircleShape2D_wmsbt")
|
|||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
modulate = Color(0.431373, 0.815686, 0, 1)
|
||||
offset_left = 4.0
|
||||
offset_top = -15.0
|
||||
offset_right = 106.0
|
||||
offset_bottom = 12.0
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.3, 0.3)
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://ctnlfsnc2gl03"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_th1rt"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_nr2g5"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0dawx5rlcyo3" path="res://assets/spritesheets/towers/railgun-2.png" id="3_uumfa"]
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_rnv08"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_fshi3"]
|
||||
[ext_resource type="Texture2D" uid="uid://b0dawx5rlcyo3" path="res://assets/spritesheets/towers/railgun-2.png" id="3_aeasn"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fss1a"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(0, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6n843"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(128, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xjwev"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(256, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g520l"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(384, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_os6e1"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(512, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_whr0e"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(640, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_m7sk4"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(768, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1jok4"]
|
||||
atlas = ExtResource("3_uumfa")
|
||||
atlas = ExtResource("3_aeasn")
|
||||
region = Rect2(896, 0, 128, 128)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_xw8jx"]
|
||||
|
@ -72,8 +72,8 @@ animations = [{
|
|||
radius = 138.293
|
||||
|
||||
[node name="railgun-2" type="Node2D" groups=["Towers"]]
|
||||
script = ExtResource("1_th1rt")
|
||||
bullet = ExtResource("2_nr2g5")
|
||||
script = ExtResource("1_rnv08")
|
||||
bullet = ExtResource("2_fshi3")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(-1, 0)
|
||||
|
@ -90,5 +90,15 @@ shape = SubResource("CircleShape2D_wmsbt")
|
|||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
modulate = Color(0.431373, 0.815686, 0, 1)
|
||||
offset_left = 4.0
|
||||
offset_top = -15.0
|
||||
offset_right = 106.0
|
||||
offset_bottom = 12.0
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.3, 0.3)
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
|
||||
|
|
|
@ -1,39 +1,39 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://cfelbpijg3dp0"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_0tcnl"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_xodqu"]
|
||||
[ext_resource type="Texture2D" uid="uid://dk3toqlc7igld" path="res://assets/spritesheets/towers/railgun-3.png" id="3_unh2r"]
|
||||
[ext_resource type="Script" path="res://scripts/towers/tower.gd" id="1_3s425"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqa80ptcc8p70" path="res://scenes/bullets/bullet_1.tscn" id="2_af8yd"]
|
||||
[ext_resource type="Texture2D" uid="uid://dk3toqlc7igld" path="res://assets/spritesheets/towers/railgun-3.png" id="3_g5gi2"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g3wst"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(0, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kpvk8"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(128, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xv60f"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(256, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hocp4"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(384, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_00rie"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(512, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fqp56"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(640, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_42mkq"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(768, 0, 128, 128)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cj5ok"]
|
||||
atlas = ExtResource("3_unh2r")
|
||||
atlas = ExtResource("3_g5gi2")
|
||||
region = Rect2(896, 0, 128, 128)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_olaum"]
|
||||
|
@ -72,8 +72,8 @@ animations = [{
|
|||
radius = 138.293
|
||||
|
||||
[node name="railgun-3" type="Node2D" groups=["Towers"]]
|
||||
script = ExtResource("1_0tcnl")
|
||||
bullet = ExtResource("2_xodqu")
|
||||
script = ExtResource("1_3s425")
|
||||
bullet = ExtResource("2_af8yd")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
position = Vector2(-1, 0)
|
||||
|
@ -90,5 +90,15 @@ shape = SubResource("CircleShape2D_wmsbt")
|
|||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="HealthBar" type="ProgressBar" parent="."]
|
||||
modulate = Color(0.431373, 0.815686, 0, 1)
|
||||
offset_left = 4.0
|
||||
offset_top = -15.0
|
||||
offset_right = 106.0
|
||||
offset_bottom = 12.0
|
||||
rotation = 1.5708
|
||||
scale = Vector2(0.3, 0.3)
|
||||
show_percentage = false
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_body_exited"]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
extends Area2D
|
||||
|
||||
const right = Vector2.RIGHT
|
||||
@export var speed : int = 200
|
||||
@export var damage : int = 20
|
||||
var speed : int = 0
|
||||
var damage : int = 0
|
||||
|
||||
func _physics_process(delta):
|
||||
var movement = right.rotated(rotation) * speed * delta
|
||||
|
|
|
@ -66,50 +66,56 @@ var tower = [
|
|||
{
|
||||
"name": "Cannon",
|
||||
"asset": preload("res://scenes/towers/cannon_1.tscn"),
|
||||
"timer": 0.2,
|
||||
"timer": 1,
|
||||
"speed": 200,
|
||||
"damage": 30,
|
||||
"health": 100
|
||||
"health": 100,
|
||||
"durability_reduction": 10
|
||||
},
|
||||
{
|
||||
"name": "Railgun",
|
||||
"asset": preload("res://scenes/towers/railgun_1.tscn"),
|
||||
"timer": 0.2,
|
||||
"timer": 1,
|
||||
"speed": 200,
|
||||
"damage": 40,
|
||||
"health": 100
|
||||
"health": 100,
|
||||
"durability_reduction": 10
|
||||
},
|
||||
{
|
||||
"name": "Cannon (V2)",
|
||||
"asset": preload("res://scenes/towers/cannon_2.tscn"),
|
||||
"timer": 0.2,
|
||||
"timer": 1,
|
||||
"speed": 200,
|
||||
"damage": 40,
|
||||
"health": 100
|
||||
"health": 100,
|
||||
"durability_reduction": 10
|
||||
},
|
||||
{
|
||||
"name": "Railgun (V2)",
|
||||
"asset": preload("res://scenes/towers/railgun_2.tscn"),
|
||||
"timer": 0.2,
|
||||
"timer": 1,
|
||||
"speed": 200,
|
||||
"damage": 40,
|
||||
"health": 100
|
||||
"health": 100,
|
||||
"durability_reduction": 10
|
||||
},
|
||||
{
|
||||
"name": "Cannon (V3)",
|
||||
"asset": preload("res://scenes/towers/cannon_3.tscn"),
|
||||
"timer": 0.2,
|
||||
"timer": 1,
|
||||
"speed": 200,
|
||||
"damage": 40,
|
||||
"health": 100
|
||||
"health": 100,
|
||||
"durability_reduction": 10
|
||||
},
|
||||
{
|
||||
"name": "Railgun (V3)",
|
||||
"asset": preload("res://scenes/towers/railgun_3.tscn"),
|
||||
"timer": 0.2,
|
||||
"timer": 1,
|
||||
"speed": 200,
|
||||
"damage": 40,
|
||||
"health": 100
|
||||
"health": 100,
|
||||
"durability_reduction": 10
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ extends Node2D
|
|||
|
||||
class_name GameManager
|
||||
|
||||
var config = load("res://scripts/stages/1/config.gd").new()
|
||||
var config_path = "res://scripts/stages/1/config.gd"
|
||||
var config = load(config_path).new()
|
||||
|
||||
var data = {
|
||||
"tower": {},
|
||||
|
@ -53,6 +54,9 @@ func on_build_tower(pos, tower_id, tower_placement_id):
|
|||
|
||||
var tower = config.tower[tower_id]['asset'].instantiate()
|
||||
get_tree().current_scene.add_child(tower)
|
||||
tower.set_config(config_path)
|
||||
tower.set_tower(tower_id)
|
||||
tower.set_timer()
|
||||
tower.global_position = pos
|
||||
|
||||
data['tower'][str(tower_placement_id)]['id'] = tower_id
|
||||
|
|
|
@ -5,16 +5,40 @@ extends Node2D
|
|||
|
||||
@export var bullet: PackedScene = null
|
||||
|
||||
var config = load("res://scripts/stages/1/config.gd").new()
|
||||
var config = null
|
||||
var tower_id: int = 0
|
||||
var health: int = 0
|
||||
var damage: int = 0
|
||||
var speed: int = 0
|
||||
var shoot_timer: float = 0
|
||||
var durability_reduction: int = 0
|
||||
|
||||
var is_shoot: bool = true
|
||||
|
||||
var enemies = []
|
||||
|
||||
func set_config(config_path):
|
||||
config = load(config_path).new()
|
||||
|
||||
func set_tower(id: int):
|
||||
tower_id = id
|
||||
health = config.tower[tower_id]['health']
|
||||
damage = config.tower[tower_id]['damage']
|
||||
speed = config.tower[tower_id]['speed']
|
||||
shoot_timer = config.tower[tower_id]['timer']
|
||||
durability_reduction = config.tower[tower_id]['durability_reduction']
|
||||
|
||||
func set_timer():
|
||||
timer.wait_time = shoot_timer
|
||||
|
||||
func _update_look_at(enemy: Vector2):
|
||||
look_at(enemy)
|
||||
|
||||
func _physics_process(_delta):
|
||||
update_healthbar()
|
||||
if health < 1:
|
||||
queue_free()
|
||||
|
||||
if enemies.is_empty():
|
||||
$AnimatedSprite2D.stop()
|
||||
else:
|
||||
|
@ -27,9 +51,20 @@ func _shoot():
|
|||
if bullet:
|
||||
var bullet_instance: Node2D = bullet.instantiate()
|
||||
get_tree().current_scene.add_child(bullet_instance)
|
||||
bullet_instance.speed = speed
|
||||
bullet_instance.damage = damage
|
||||
bullet_instance.global_position = global_position
|
||||
bullet_instance.global_rotation = rayCast.global_rotation + 0.1
|
||||
health -= durability_reduction
|
||||
timer.start()
|
||||
|
||||
func update_healthbar():
|
||||
$HealthBar.value = health
|
||||
|
||||
if health >= 100:
|
||||
$HealthBar.visible = false
|
||||
else:
|
||||
$HealthBar.visible = true
|
||||
|
||||
func _on_body_entered(body):
|
||||
if body.is_in_group("Enemy"):
|
||||
|
|
Loading…
Reference in a new issue