-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoor.gd
33 lines (29 loc) · 906 Bytes
/
door.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
extends StaticBody2D
var openOrClosed = false
var reopen = false
var player
func _ready():
player = get_owner().get_node("player")
func _on_doorButton_pressed():
global.text = self.get_name()
get_node("/root/baseNode/player/Panel").updateText()
# door4 is locked
if(self.get_name() != "door4"):
if(openOrClosed == false and checkDistance()):
set_rotd(get_rotd() + 90)
openOrClosed = true
elif(openOrClosed == true and checkDistance()):
set_rotd(get_rotd() - 90)
openOrClosed = false
# if player has the key, door4 can be opened
elif(player.hasSilverKey == true):
if(openOrClosed == false and checkDistance()):
set_rotd(get_rotd() + 90)
openOrClosed = true
elif(openOrClosed == true and checkDistance()):
set_rotd(get_rotd() - 90)
openOrClosed = false
func checkDistance():
if(player.position.distance_to(self.get_global_pos()) < 130):
return true
return false