forked from team-sg/hero-mark-2
tasty little switch refactoring and an extra dessert :) :3 :3
This commit is contained in:
parent
5684e5b3a0
commit
a8e187a150
3 changed files with 19 additions and 6 deletions
|
@ -133,18 +133,19 @@ scale = Vector2( 1, 6 )
|
|||
|
||||
[node name="Button" parent="Environment" instance=ExtResource( 15 )]
|
||||
position = Vector2( 80, 113 )
|
||||
target_group = "button1"
|
||||
|
||||
[node name="Button2" parent="Environment" instance=ExtResource( 15 )]
|
||||
position = Vector2( 728, 168 )
|
||||
switch_index = 3
|
||||
target_group = "button3"
|
||||
|
||||
[node name="Button4" parent="Environment" instance=ExtResource( 15 )]
|
||||
position = Vector2( 272, 168 )
|
||||
switch_index = 4
|
||||
target_group = "button4"
|
||||
|
||||
[node name="Button3" parent="Environment" instance=ExtResource( 15 )]
|
||||
position = Vector2( 520, 16 )
|
||||
switch_index = 2
|
||||
target_group = "button2"
|
||||
|
||||
[node name="Barrier2" parent="Environment" instance=ExtResource( 22 )]
|
||||
position = Vector2( 332, 63 )
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
tool
|
||||
extends "res://objects/environment/switches/switch.gd"
|
||||
|
||||
var pressed = false
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
tool
|
||||
extends Node2D
|
||||
|
||||
export var switch_index = 1
|
||||
export var type = "switch"
|
||||
export (String) var target_group = ""
|
||||
|
||||
func activate():
|
||||
for object in get_tree().get_nodes_in_group(str(type) + str(switch_index)):
|
||||
for object in get_tree().get_nodes_in_group(target_group):
|
||||
object.switch_action()
|
||||
|
||||
func _process(delta):
|
||||
# redraw lines every frame to account for things changing
|
||||
if Engine.editor_hint and Engine.get_frames_drawn() % 10 == 0:
|
||||
update()
|
||||
|
||||
func _draw():
|
||||
if Engine.editor_hint:
|
||||
for node in get_tree().get_nodes_in_group(target_group):
|
||||
if node is Node2D:
|
||||
draw_line(Vector2.ZERO, to_local(node.global_position), Color(0.2, 1.0, 0.0, 0.5), 1.5)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue