forked from team-sg/hero-mark-2
added hatches!
This commit is contained in:
parent
9947cdfc45
commit
3433dae09c
10 changed files with 267 additions and 18 deletions
30
objects/environment/hatch/hatch.gd
Normal file
30
objects/environment/hatch/hatch.gd
Normal file
|
@ -0,0 +1,30 @@
|
|||
extends Node2D
|
||||
|
||||
onready var anims = $SpriteAnim
|
||||
onready var down_prompt = $DownPrompt
|
||||
onready var snap_position = $Position2D
|
||||
var can_interact = false
|
||||
var player = null
|
||||
|
||||
func _physics_process(delta):
|
||||
if Input.is_action_just_pressed("enter_hatch") && can_interact:
|
||||
anims.play("open")
|
||||
player.enter_hatch(position + snap_position.position)
|
||||
down_prompt.scale.y = -1
|
||||
down_prompt.visible = true
|
||||
player.connect("hatch_exited", self, "exit_hatch", [], CONNECT_ONESHOT)
|
||||
|
||||
func exit_hatch():
|
||||
anims.play("open")
|
||||
down_prompt.scale.y = 1
|
||||
|
||||
func _on_TriggerArea_area_entered(area):
|
||||
down_prompt.visible = true
|
||||
down_prompt.scale.y = 1
|
||||
can_interact = true
|
||||
player = area.get_owner()
|
||||
|
||||
func _on_TriggerArea_area_exited(area):
|
||||
if down_prompt.scale.y == 1:
|
||||
down_prompt.visible = false
|
||||
can_interact = false
|
Loading…
Add table
Add a link
Reference in a new issue