diff options
-rw-r--r-- | assets/json/enemies.json | 248 | ||||
-rw-r--r-- | assets/json/enemies_gen.py | 16 | ||||
-rw-r--r-- | scripts/enemies.gd | 21 | ||||
-rw-r--r-- | scripts/load_shapes.gd | 5 | ||||
-rw-r--r-- | scripts/resources.gd | 2 |
5 files changed, 256 insertions, 36 deletions
diff --git a/assets/json/enemies.json b/assets/json/enemies.json index 056d215..7a74885 100644 --- a/assets/json/enemies.json +++ b/assets/json/enemies.json @@ -7,7 +7,13 @@ "name": "T", "model_name": "T.glb", "thumbnail_name": "T.png", - "resource": "T" + "resource": "T", + "color": [ + 1.0, + 1.0, + 1.0, + 1.0 + ] }, { "lives": 10, @@ -18,7 +24,13 @@ "spawn_on_death": "T", "model_name": "kT.glb", "thumbnail_name": "kT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.6, + 0.85, + 0.5, + 1.0 + ] }, { "lives": 10, @@ -29,7 +41,13 @@ "spawn_on_death": "kT", "model_name": "dkT.glb", "thumbnail_name": "dkT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.39999999999999997, + 0.7000000000000001, + 0.6666666666666666, + 1.0 + ] }, { "lives": 10, @@ -40,7 +58,13 @@ "spawn_on_death": "T", "model_name": "aT.glb", "thumbnail_name": "aT.png", - "resource": "a" + "resource": "a", + "color": [ + 1.0, + 0.5, + 0.5, + 1.0 + ] }, { "lives": 10, @@ -51,7 +75,13 @@ "spawn_on_death": "aT", "model_name": "kaT.glb", "thumbnail_name": "kaT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.7333333333333334, + 0.5666666666666667, + 0.3333333333333333, + 1.0 + ] }, { "lives": 10, @@ -62,7 +92,13 @@ "spawn_on_death": "kaT", "model_name": "dkaT.glb", "thumbnail_name": "dkaT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.55, + 0.525, + 0.5, + 1.0 + ] }, { "lives": 10, @@ -73,7 +109,13 @@ "spawn_on_death": "aT", "model_name": "aaT.glb", "thumbnail_name": "aaT.png", - "resource": "a" + "resource": "a", + "color": [ + 1.0, + 0.3333333333333333, + 0.3333333333333333, + 1.0 + ] }, { "lives": 10, @@ -84,7 +126,13 @@ "spawn_on_death": "aaT", "model_name": "daaT.glb", "thumbnail_name": "daaT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.75, + 0.35, + 0.5, + 1.0 + ] }, { "lives": 10, @@ -95,7 +143,13 @@ "spawn_on_death": "daaT", "model_name": "kdaaT.glb", "thumbnail_name": "kdaaT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.64, + 0.42000000000000004, + 0.4, + 1.0 + ] }, { "lives": 10, @@ -106,7 +160,13 @@ "spawn_on_death": "kdaaT", "model_name": "dkdaaT.glb", "thumbnail_name": "dkdaaT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.5333333333333333, + 0.4166666666666667, + 0.5, + 1.0 + ] }, { "lives": 10, @@ -117,7 +177,13 @@ "spawn_on_death": "aaT", "model_name": "aaaT.glb", "thumbnail_name": "aaaT.png", - "resource": "a" + "resource": "a", + "color": [ + 1.0, + 0.25, + 0.25, + 1.0 + ] }, { "lives": 10, @@ -128,7 +194,13 @@ "spawn_on_death": "aaaT", "model_name": "daaaT.glb", "thumbnail_name": "daaaT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.8, + 0.27999999999999997, + 0.4, + 1.0 + ] }, { "lives": 10, @@ -139,7 +211,13 @@ "spawn_on_death": "aT", "model_name": "daT.glb", "thumbnail_name": "daT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.6666666666666666, + 0.4666666666666666, + 0.6666666666666666, + 1.0 + ] }, { "lives": 10, @@ -150,7 +228,13 @@ "spawn_on_death": "daT", "model_name": "kdaT.glb", "thumbnail_name": "kdaT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.55, + 0.525, + 0.5, + 1.0 + ] }, { "lives": 10, @@ -161,7 +245,13 @@ "spawn_on_death": "kdaT", "model_name": "dkdaT.glb", "thumbnail_name": "dkdaT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.44000000000000006, + 0.5, + 0.6, + 1.0 + ] }, { "lives": 30, @@ -172,7 +262,13 @@ "spawn_on_death": "aT", "model_name": "saT.glb", "thumbnail_name": "saT.png", - "resource": "s" + "resource": "s", + "color": [ + 1.0, + 0.6666666666666666, + 0.3333333333333333, + 1.0 + ] }, { "lives": 30, @@ -183,7 +279,13 @@ "spawn_on_death": "saT", "model_name": "dsaT.glb", "thumbnail_name": "dsaT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.75, + 0.6, + 0.5, + 1.0 + ] }, { "lives": 30, @@ -194,7 +296,13 @@ "spawn_on_death": "T", "model_name": "sT.glb", "thumbnail_name": "sT.png", - "resource": "s" + "resource": "s", + "color": [ + 1.0, + 1.0, + 0.5, + 1.0 + ] }, { "lives": 30, @@ -205,7 +313,13 @@ "spawn_on_death": "sT", "model_name": "ksT.glb", "thumbnail_name": "ksT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.7333333333333334, + 0.9, + 0.3333333333333333, + 1.0 + ] }, { "lives": 30, @@ -216,7 +330,13 @@ "spawn_on_death": "ksT", "model_name": "dksT.glb", "thumbnail_name": "dksT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.55, + 0.775, + 0.5, + 1.0 + ] }, { "lives": 30, @@ -227,7 +347,13 @@ "spawn_on_death": "sT", "model_name": "asT.glb", "thumbnail_name": "asT.png", - "resource": "a" + "resource": "a", + "color": [ + 1.0, + 0.6666666666666666, + 0.3333333333333333, + 1.0 + ] }, { "lives": 30, @@ -238,7 +364,13 @@ "spawn_on_death": "asT", "model_name": "dasT.glb", "thumbnail_name": "dasT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.75, + 0.6, + 0.5, + 1.0 + ] }, { "lives": 30, @@ -249,7 +381,13 @@ "spawn_on_death": "dasT", "model_name": "kdasT.glb", "thumbnail_name": "kdasT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.64, + 0.62, + 0.4, + 1.0 + ] }, { "lives": 30, @@ -260,7 +398,13 @@ "spawn_on_death": "kdasT", "model_name": "dkdasT.glb", "thumbnail_name": "dkdasT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.5333333333333333, + 0.5833333333333334, + 0.5, + 1.0 + ] }, { "lives": 30, @@ -271,7 +415,13 @@ "spawn_on_death": "asT", "model_name": "aasT.glb", "thumbnail_name": "aasT.png", - "resource": "a" + "resource": "a", + "color": [ + 1.0, + 0.5, + 0.25, + 1.0 + ] }, { "lives": 30, @@ -282,7 +432,13 @@ "spawn_on_death": "aasT", "model_name": "daasT.glb", "thumbnail_name": "daasT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.8, + 0.48, + 0.4, + 1.0 + ] }, { "lives": 30, @@ -293,7 +449,13 @@ "spawn_on_death": "sT", "model_name": "dsT.glb", "thumbnail_name": "dsT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.6666666666666666, + 0.7999999999999999, + 0.6666666666666666, + 1.0 + ] }, { "lives": 30, @@ -304,7 +466,13 @@ "spawn_on_death": "dsT", "model_name": "kdsT.glb", "thumbnail_name": "kdsT.png", - "resource": "k" + "resource": "k", + "color": [ + 0.55, + 0.775, + 0.5, + 1.0 + ] }, { "lives": 30, @@ -315,7 +483,13 @@ "spawn_on_death": "kdsT", "model_name": "dkdsT.glb", "thumbnail_name": "dkdsT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.44000000000000006, + 0.7, + 0.6, + 1.0 + ] }, { "lives": 90, @@ -326,7 +500,13 @@ "spawn_on_death": "sT", "model_name": "ssT.glb", "thumbnail_name": "ssT.png", - "resource": "s" + "resource": "s", + "color": [ + 1.0, + 1.0, + 0.3333333333333333, + 1.0 + ] }, { "lives": 90, @@ -337,6 +517,12 @@ "spawn_on_death": "ssT", "model_name": "dssT.glb", "thumbnail_name": "dssT.png", - "resource": "d" + "resource": "d", + "color": [ + 0.75, + 0.85, + 0.5, + 1.0 + ] } ] diff --git a/assets/json/enemies_gen.py b/assets/json/enemies_gen.py index 695b264..8e1ba88 100644 --- a/assets/json/enemies_gen.py +++ b/assets/json/enemies_gen.py @@ -54,6 +54,14 @@ bonus = { "s": { "speed": 0.8, "lives": 3 }, } +colors = { + "T": [1, 1, 1, 1], + "k": [0.2, 0.7, 0, 1], + "a": [1, 0, 0, 1], + "d": [0, 0.4, 1, 1], + "s": [1, 1, 0, 1], +} + def get_stats (node): stats = base.copy() bonuses = { k:1 for k in stats } @@ -66,6 +74,13 @@ def get_stats (node): stats[s] *= bonuses[s] return stats +def get_color (node): + color = [0,0,0,0] + for r in node: + for i in range(len(color)): color[i] += colors[r][i] + for i in range(len(color)): color[i] /= len(node) + return color + def get_enemy (node): enemy = get_stats(node) enemy['name'] = node @@ -75,6 +90,7 @@ def get_enemy (node): enemy["model_name"] = node + '.glb' enemy["thumbnail_name"] = node + '.png' enemy["resource"] = node[0] + enemy["color"] = get_color(node) return enemy 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" |