aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorjacopograndi <jacopo.grandi@outlook.it>2022-02-08 14:14:42 +0100
committerjacopograndi <jacopo.grandi@outlook.it>2022-02-08 14:14:42 +0100
commite0a389ff5964c34022fb90d9c3fb29053567ec65 (patch)
tree8d6dd57951e7532f6864c90a46bd288371bcfd3d /scripts
parenteea642395bb0ef706c7241d4a749f3e0ac4cc460 (diff)
enemy colorsHEADmain
Diffstat (limited to 'scripts')
-rw-r--r--scripts/enemies.gd21
-rw-r--r--scripts/load_shapes.gd5
-rw-r--r--scripts/resources.gd2
3 files changed, 23 insertions, 5 deletions
diff --git a/scripts/enemies.gd b/scripts/enemies.gd
index 3e8276d..61529ff 100644
--- a/scripts/enemies.gd
+++ b/scripts/enemies.gd
@@ -66,11 +66,20 @@ func spawn(name, node_cur=0, rel_pos=0, hp=0):
"slow_time": 0,
"cur": node_cur,
"rel": rel_pos,
- "axis": [axis.x, axis.y, axis.z]
+ "axis": [axis.x, axis.y, axis.z],
+ "basecolor": Color(info.color[0], info.color[1], info.color[2], info.color[3]),
+ "color": Color(info.color[0], info.color[1], info.color[2], info.color[3])
}
+ var next_color = Color.black;
+ if info.has("spawn_on_death"):
+ next_color = load_shapes.info[info.spawn_on_death].color
+ enemies[serial_enemy].color = info.color.linear_interpolate(
+ next_color, enemies[serial_enemy].hp/info.lives)
instance.transform.origin = abs_pos(serial_enemy)
serial_enemy += 1
+
+
func node_from_id (id):
return get_node(str(id))
@@ -92,7 +101,7 @@ func _physics_process(delta):
enemy.rel = 0
for n in range(info.get("spawn_num", 0)):
# todo rel +- epslion
- spawn(info.spawn_on_death, enemy.cur, enemy.rel - n/10)
+ spawn(info.spawn_on_death, enemy.cur, enemy.rel - n/10.0)
continue
enemy.slow_time -= delta
@@ -117,7 +126,7 @@ func _physics_process(delta):
child.transform.basis = child.transform.basis.rotated(axis, delta)
var mesh : MeshInstance = child.get_child(1).get_child(0)
- mesh.get_active_material(0).albedo_color = colors[0]
+ mesh.get_active_material(0).albedo_color = enemy.color
for id in delist:
get_node(str(id)).queue_free()
@@ -137,6 +146,10 @@ func damage(name, dam, slow_effect=0, slow_time=0):
enemy.hp -= dam
_resources.add({ info.resource: dam })
fx_damage(name)
+ var next_color = Color.black;
+ if info.has("spawn_on_death"):
+ next_color = load_shapes.info[info.spawn_on_death].color
+ enemy.color = info.color.linear_interpolate(next_color, enemy.hp/info.lives)
if slow_effect > 0:
enemy.slow_effect = max(slow_effect, enemy.slow_effect)
enemy.slow_time = slow_time
@@ -156,4 +169,4 @@ func fx_damage(name):
var instance_model = load_shapes.models[info.model_name].instance()
instance.add_child(instance_model)
- instance.refresh_shader(_dissolve_mat.duplicate(), colors[0])
+ instance.refresh_shader(_dissolve_mat.duplicate(), enemy.color)
diff --git a/scripts/load_shapes.gd b/scripts/load_shapes.gd
index 289afd9..d7b0d71 100644
--- a/scripts/load_shapes.gd
+++ b/scripts/load_shapes.gd
@@ -40,6 +40,11 @@ func load_info():
var parsed = saveload.load_parse_json("res://assets/json/" + f)
if parsed != null:
for tin in parsed:
+ tin.color = Color(
+ tin.color[0],
+ tin.color[1],
+ tin.color[2],
+ tin.color[3])
info[tin.name] = tin
diff --git a/scripts/resources.gd b/scripts/resources.gd
index 53462a6..16a9b5d 100644
--- a/scripts/resources.gd
+++ b/scripts/resources.gd
@@ -6,7 +6,7 @@ var a : float = 0
var d : float = 0
var s : float = 0
-var lives : int = 0
+var lives : int = 100
func get_names(): return "Tkads"