Save boss and player statuses
This commit is contained in:
parent
b0c5798328
commit
6ea21b3181
9 changed files with 43 additions and 3 deletions
|
@ -9,6 +9,11 @@ export (int) var ACCELERATION = 70
|
|||
onready var rightWallCheck = $RightWallCheck
|
||||
onready var leftWallCheck = $LeftWallCheck
|
||||
|
||||
func _ready():
|
||||
._ready()
|
||||
if SaverLoader.custom_data.boss_defeated:
|
||||
self.queue_free()
|
||||
|
||||
func _process(delta):
|
||||
chase_player(delta)
|
||||
|
||||
|
@ -35,3 +40,8 @@ func fire_bullet() -> void:
|
|||
|
||||
func _on_Timer_timeout():
|
||||
fire_bullet()
|
||||
|
||||
|
||||
func _on_BossEnemy_died():
|
||||
SaverLoader.custom_data.boss_defeated = true
|
||||
self.queue_free()
|
||||
|
|
|
@ -1023,6 +1023,7 @@ collision_mask = 2
|
|||
wait_time = 0.3
|
||||
autostart = true
|
||||
|
||||
[connection signal="died" from="." to="." method="_on_BossEnemy_died"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
extends StaticBody2D
|
||||
|
||||
var PlayerStats = ResourceLoader.PlayerStats
|
||||
|
||||
onready var animation = $Animation
|
||||
|
||||
func _on_SaveArea_body_entered(_body):
|
||||
print(_body)
|
||||
# PlayerStats.set_max_health()
|
||||
animation.play("Save")
|
||||
SaverLoader.save_game()
|
||||
|
|
|
@ -50,6 +50,9 @@ func set_invincible(value):
|
|||
|
||||
func _ready():
|
||||
PlayerStats.connect("player_died", self, "_on_died")
|
||||
PlayerStats.health = SaverLoader.custom_data.health
|
||||
PlayerStats.missiles_unlocked = SaverLoader.custom_data.missiles_unlocked
|
||||
PlayerStats.missiles = SaverLoader.custom_data.missiles
|
||||
MainInstances.Player = self
|
||||
call_deferred("assign_world_camera")
|
||||
|
||||
|
@ -261,6 +264,7 @@ func _on_Hurtbox_hit(damage):
|
|||
if not invincible:
|
||||
PlayerStats.health -= damage
|
||||
blinkAnimator.play("Blink")
|
||||
SaverLoader.custom_data.health = PlayerStats.health
|
||||
|
||||
func _on_died():
|
||||
queue_free()
|
||||
|
|
|
@ -22,10 +22,15 @@ func set_health(value):
|
|||
if health == 0:
|
||||
emit_signal("player_died")
|
||||
|
||||
func set_max_health():
|
||||
set_health(max_health)
|
||||
|
||||
func set_missiles(value):
|
||||
missiles = clamp(value, 0, max_missiles)
|
||||
SaverLoader.custom_data.missiles = missiles
|
||||
emit_signal("player_missiles_changed", missiles)
|
||||
|
||||
func set_missiles_unlocked(value):
|
||||
missiles_unlocked = value
|
||||
SaverLoader.custom_data.missiles_unlocked = value
|
||||
emit_signal("player_missiles_unlocked", value)
|
||||
|
|
|
@ -9,7 +9,7 @@ func _ready():
|
|||
PlayerStats.connect("player_missiles_unlocked", self, "_on_player_missiles_unlocked")
|
||||
|
||||
func _on_player_missiles_changed(value):
|
||||
label.text = str(value)
|
||||
label.text = str(value) + "/" + str(PlayerStats.max_missiles)
|
||||
|
||||
func _on_player_missiles_unlocked(value):
|
||||
visible = value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue