From 05a74debba3325537aac96b072350f98c4709655 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 17 Feb 2018 01:48:02 -0500 Subject: [PATCH] [Hero 1] Make walls translucent before confirming --- scripts/heroes/0-wall.gd | 31 ++++++++++++++++++------------- scripts/heroes/1.gd | 5 ++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/scripts/heroes/0-wall.gd b/scripts/heroes/0-wall.gd index 01229f6..6c1aad7 100644 --- a/scripts/heroes/0-wall.gd +++ b/scripts/heroes/0-wall.gd @@ -1,20 +1,25 @@ extends StaticBody -# class member variables go here, for example: -# var a = 2 -# var b = "textvar" +var maker_node +var touch_charge = 1 -func _ready(): - # Called every time the node is added to the scene. - # Initialization here - pass - -func set_color(color): +func init(maker, color): + maker_node = maker var mat = SpatialMaterial.new() + color.a = 0.5 + mat.flags_transparent = true mat.albedo_color = color get_node("MeshInstance").set_surface_material(0, mat) -#func _process(delta): -# # Called every frame. Delta is time since last frame. -# # Update game logic here. -# pass +func place(): + # Originally, the wall is disabled to avoid weird physics + get_node("CollisionShape").disabled = false + get_node("MeshInstance").get_surface_material(0).flags_transparent = false + +func _process(delta): + pass + # var cols = get_colliding_bodies() + # for col in cols: + # if col != maker_node: # Don't count ourself. This encourages teamwork and discourages wall-touching-for-charge abuse + # maker_node.switch_charge += touch_charge * delta + diff --git a/scripts/heroes/1.gd b/scripts/heroes/1.gd index 2c40963..d17b671 100644 --- a/scripts/heroes/1.gd +++ b/scripts/heroes/1.gd @@ -49,15 +49,14 @@ func add_wall(): var wall = preload("res://scenes/wall.tscn").instance() var friendly = player_info.is_right_team == master_player.player_info.is_right_team var color = friend_color if friendly else enemy_color - wall.set_color(color) + wall.init(self, color) get_node("/root/Level").add_child(wall) return wall func finalize_wall(wall, tf=null): if tf: wall.set_transform(tf) - # Originally, the wall is disabled to avoid weird physics - wall.get_node("CollisionShape").disabled = false + wall.place() # Remember this wall, and return to non-placing state # We need to do this even as slave, because we keep track of the count walls.append(wall)