This commit is contained in:
pennyrigate 2024-08-13 20:33:46 -04:00
parent 1dc515904c
commit 2a1eda7cc0
10 changed files with 100 additions and 2 deletions

View file

@ -47,6 +47,8 @@ var skip_blood: bool = false
#whether sg has landed before
var first_land = true
var can_shield = true
# NODE REFERENCES #
onready var state_chart: StateChart = $StateChart
@ -116,6 +118,17 @@ func _physics_process(delta: float) -> void:
state_chart.send_event("duck_pressed")
if Input.is_action_just_released("move_down"):
state_chart.send_event("duck_released")
if Input.is_action_just_pressed("shield") && Game.can_use_shield == true:
if can_shield:
Audio.play_sound(Audio.a_shield,Audio.ac_die)
$ShieldTimer.start()
$ShieldCooldown.start()
$Shield.visible = true
$"%AirborneShape".disabled = true
$"%GroundedShape".disabled = true
can_shield = false
# send relevant events
if is_on_floor(): # check on floor status
@ -571,3 +584,14 @@ func make_blood():
func _on_Zapping_state_exited():
$Graphics/ZapSprite.visible = false
emit_signal("died")
func _on_ShieldTimer_timeout():
$Shield.visible = false
$"%AirborneShape".disabled = false
$"%GroundedShape".disabled = false
func _on_ShieldCooldown_timeout():
can_shield = true
Audio.play_sound(Audio.a_shield_cooldown,Audio.ac_boss)

View file

@ -1515,13 +1515,27 @@ margin_bottom = -18.0
theme = ExtResource( 7 )
align = 1
[node name="ShieldTimer" type="Timer" parent="."]
wait_time = 0.5
[node name="Shield" type="Polygon2D" parent="."]
visible = false
position = Vector2( 1, -1 )
scale = Vector2( 1.06667, 0.727273 )
color = Color( 0.0352941, 0.796078, 0.854902, 0.470588 )
polygon = PoolVector2Array( 0, -29, -8, -14.3333, -1, 4, 7, -14 )
[node name="ShieldCooldown" type="Timer" parent="."]
wait_time = 2.0
one_shot = true
[connection signal="tree_exited" from="." to="." method="_on_Player_tree_exited"]
[connection signal="body_entered" from="Hitbox" to="." method="_on_Hitbox_body_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded" to="." method="_process_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement_grounded"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Still" to="." method="_on_Still_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Walking" to="." method="_on_Walking_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Blinking" to="." method="_on_Blinking_state_entered"]
@ -1535,8 +1549,8 @@ align = 1
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="reset_fall_speed"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_jump"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_exited"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/LadderJump" to="." method="_on_LadderJump_state_entered"]
@ -1569,3 +1583,5 @@ align = 1
[connection signal="state_entered" from="StateChart/Root/Health/Zapping" to="." method="_on_Zapping_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Health/Zapping" to="." method="_on_Zapping_state_exited"]
[connection signal="timeout" from="OxygenTimer" to="." method="_on_OxygenTimer_timeout"]
[connection signal="timeout" from="ShieldTimer" to="." method="_on_ShieldTimer_timeout"]
[connection signal="timeout" from="ShieldCooldown" to="." method="_on_ShieldCooldown_timeout"]