Browse Source

[Hero 1] Make walls translucent before confirming

master
Luna 7 years ago
parent
commit
05a74debba
2 changed files with 20 additions and 16 deletions
  1. +18
    -13
      scripts/heroes/0-wall.gd
  2. +2
    -3
      scripts/heroes/1.gd

+ 18
- 13
scripts/heroes/0-wall.gd View File

@ -1,20 +1,25 @@
extends StaticBody 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() var mat = SpatialMaterial.new()
color.a = 0.5
mat.flags_transparent = true
mat.albedo_color = color mat.albedo_color = color
get_node("MeshInstance").set_surface_material(0, mat) 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

+ 2
- 3
scripts/heroes/1.gd View File

@ -49,15 +49,14 @@ func add_wall():
var wall = preload("res://scenes/wall.tscn").instance() var wall = preload("res://scenes/wall.tscn").instance()
var friendly = player_info.is_right_team == master_player.player_info.is_right_team var friendly = player_info.is_right_team == master_player.player_info.is_right_team
var color = friend_color if friendly else enemy_color var color = friend_color if friendly else enemy_color
wall.set_color(color)
wall.init(self, color)
get_node("/root/Level").add_child(wall) get_node("/root/Level").add_child(wall)
return wall return wall
func finalize_wall(wall, tf=null): func finalize_wall(wall, tf=null):
if tf: if tf:
wall.set_transform(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 # Remember this wall, and return to non-placing state
# We need to do this even as slave, because we keep track of the count # We need to do this even as slave, because we keep track of the count
walls.append(wall) walls.append(wall)


Loading…
Cancel
Save