aboutsummaryrefslogtreecommitdiff
path: root/scripts/enemies.gd
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-01-19 20:08:32 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-01-19 20:08:32 +0100
commitc930eb8a0cabaeb3651e2dc7f94a26310fb2dcf3 (patch)
tree5256261a9510a9ac8e1150c8902ffefbec32ddac /scripts/enemies.gd
parent10d700152deeea4a8c6acea1124b9f9ea4905486 (diff)
turrets implementation finished
Diffstat (limited to 'scripts/enemies.gd')
-rw-r--r--scripts/enemies.gd27
1 files changed, 17 insertions, 10 deletions
diff --git a/scripts/enemies.gd b/scripts/enemies.gd
index fe5ae14..a0f4416 100644
--- a/scripts/enemies.gd
+++ b/scripts/enemies.gd
@@ -7,7 +7,7 @@ var _enemy_blue
var _dissolve_mat : ShaderMaterial
var _enemy_mat : Material
-var wave
+var control
var _fx_holder
var _fx_enemy_damage
@@ -33,7 +33,7 @@ var colors = [
func _ready():
var root = get_tree().root.get_node("world")
_fx_holder = root.get_node("fx")
- wave = root.get_node("wave")
+ control = root.get_node("player").get_node("control")
_path = root.get_node("path")
_resources = root.get_node("player").get_node("resources")
_dissolve_mat = load("res://shaders/dissolve_mat.tres")
@@ -61,8 +61,8 @@ func spawn(name, node_cur=0, rel_pos=0):
enemies[serial_enemy] = {
"name": name,
"hp": info.lives,
- "slowed_effect": 0,
- "slowed_time": 0,
+ "slow_effect": 0,
+ "slow_time": 0,
"cur": node_cur,
"rel": rel_pos,
"axis": [axis.x, axis.y, axis.z]
@@ -93,8 +93,11 @@ func _physics_process(delta):
# todo rel +- epslion
spawn(info.spawn_on_death, enemy.cur, enemy.rel - n/10)
continue
+
+ enemy.slow_time -= delta
+ if enemy.slow_time < 0: enemy.slow_effect = 0
- var speed = info.speed
+ var speed = info.speed * (1-enemy.slow_effect)
enemy.rel += speed * delta
while enemy.rel > 1:
enemy.rel -= 1
@@ -120,18 +123,22 @@ func _physics_process(delta):
enemies.erase(id)
if enemies.size() == 0:
- wave.end()
+ control.end_wave_event()
-func damage(name, amt):
+func damage(name, dam, slow_effect=0, slow_time=0):
var id = int(name)
var enemy = enemies[id]
var info = load_shapes.info[enemy.name]
if enemy.hp > 0:
- enemy.hp -= amt
- _resources.add({ info.resource: amt })
- fx_damage(name)
+ if dam > 0:
+ enemy.hp -= dam
+ _resources.add({ info.resource: dam })
+ fx_damage(name)
+ if slow_effect > 0:
+ enemy.slow_effect = max(slow_effect, enemy.slow_effect)
+ enemy.slow_time = slow_time
func fx_damage(name):
var id = int(name)