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
|
@ -1,5 +1,7 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
signal hatch_exited
|
||||
|
||||
const ArrowProjectile = preload("res://objects/player/arrow_projectile.tscn")
|
||||
|
||||
##CLEAN UP CODE LATER
|
||||
|
@ -20,10 +22,12 @@ onready var sword_hitbox = $SwordArea
|
|||
onready var death_particles = $DeathSplatter
|
||||
onready var dust_particles = $DustParticles
|
||||
onready var iframe_timer = $IframeTimer
|
||||
onready var hitbox = $Area2D/CollisionShape2D2
|
||||
|
||||
#Map
|
||||
onready var map = get_owner()
|
||||
##States
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT}
|
||||
enum State {IDLE,WALK,JUMP,FALL,STUNNED,CLIMB,SWORD,SHOOT,INACTIVE,TRANSPORT,HATCH}
|
||||
var current_state = State.IDLE
|
||||
var can_die = true
|
||||
##Runtime
|
||||
|
@ -83,6 +87,9 @@ func _physics_process(delta):
|
|||
State.TRANSPORT:
|
||||
_process_transport(delta)
|
||||
return
|
||||
State.HATCH:
|
||||
_process_hatch(delta)
|
||||
return
|
||||
|
||||
#Gravity
|
||||
if current_state != State.CLIMB:
|
||||
|
@ -217,6 +224,11 @@ func _process_shoot():
|
|||
func _process_transport(delta):
|
||||
position += transport_direction * transport_speed * delta
|
||||
|
||||
func _process_hatch(delta):
|
||||
if Input.is_action_just_pressed("exit_hatch"):
|
||||
anims.play("enter hatch", -1, -1.25,true)
|
||||
emit_signal("hatch_exited")
|
||||
|
||||
func spawn_arrow():
|
||||
Audio.play_sound(Audio.a_shoot,Audio.ac_jump)
|
||||
var arrow = ArrowProjectile.instance()
|
||||
|
@ -299,6 +311,13 @@ func enter_transport(speed, direction):
|
|||
func exit_transport():
|
||||
current_state = State.FALL
|
||||
|
||||
func enter_hatch(snap_position):
|
||||
position = snap_position
|
||||
current_state = State.INACTIVE
|
||||
hitbox.disabled = true
|
||||
collision_layer = 0
|
||||
anims.play("enter hatch", -1, 1.25)
|
||||
|
||||
func die():
|
||||
if can_die:
|
||||
Audio.ac_climb.set_stream(null) # stop climbing sound\
|
||||
|
@ -346,6 +365,16 @@ func die():
|
|||
sprite.visible = true
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
#Set hatch state
|
||||
if anim_name == "enter hatch":
|
||||
match current_state:
|
||||
State.INACTIVE:
|
||||
current_state = State.HATCH
|
||||
return
|
||||
State.HATCH:
|
||||
current_state = State.IDLE
|
||||
hitbox.disabled = false
|
||||
collision_layer = 2
|
||||
if current_state == State.INACTIVE:
|
||||
return
|
||||
#Return to idle after slash
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue