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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=34 format=2]
|
||||
[gd_scene load_steps=35 format=2]
|
||||
|
||||
[ext_resource path="res://objects/player/player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/player/sg_walk.png" type="Texture" id=2]
|
||||
|
@ -170,6 +170,45 @@ tracks/4/keys = {
|
|||
"values": [ 0.0, 0.0, 90.0, 90.0, 180.0, 180.0, 270.0, 270.0, 360.0 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=45]
|
||||
resource_name = "enter hatch"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:offset")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.1, 0.3, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, 0 ), Vector2( 0, -6 ), Vector2( 0, 0 ), Vector2( 0, 10 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("Sprite:texture")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ ExtResource( 5 ) ]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/path = NodePath("Sprite:region_rect")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/keys = {
|
||||
"times": PoolRealArray( 0, 0.3, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Rect2( 1, 0, 20, 20 ), Rect2( 1, 0, 20, 20 ), Rect2( 1, 0, 20, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=30]
|
||||
resource_name = "idle"
|
||||
length = 0.5
|
||||
|
@ -621,9 +660,9 @@ max_fall_speed = 255.0
|
|||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
material = SubResource( 38 )
|
||||
texture = ExtResource( 3 )
|
||||
texture = ExtResource( 5 )
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 20, 20 )
|
||||
region_rect = Rect2( 1, 0, 20, 20 )
|
||||
script = ExtResource( 17 )
|
||||
|
||||
[node name="SwordSprite" type="Sprite" parent="."]
|
||||
|
@ -664,6 +703,7 @@ collide_with_bodies = false
|
|||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/climb = SubResource( 29 )
|
||||
anims/doublejump = SubResource( 35 )
|
||||
"anims/enter hatch" = SubResource( 45 )
|
||||
anims/idle = SubResource( 30 )
|
||||
anims/jump = SubResource( 31 )
|
||||
"anims/shoot air" = SubResource( 37 )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue