mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Game over and proper acid death
This commit is contained in:
parent
bacf41e726
commit
7d49c5a25e
13 changed files with 925 additions and 784 deletions
|
|
@ -102,9 +102,10 @@ public partial class PlayerAnimationProvider3D : Node3D
|
|||
|
||||
public void PlayDeathAnimation()
|
||||
{
|
||||
this.Visible = false;
|
||||
// if (_deathParticles is null) return;
|
||||
// this.CreateSibling<AutodeleteParticle>(_deathParticles, this.GlobalPosition);
|
||||
// _animatedSprite.Visible = false;
|
||||
|
||||
}
|
||||
|
||||
public void PlayDrowningAnimation()
|
||||
|
|
|
|||
|
|
@ -1,20 +1,53 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Components.Actors._3D;
|
||||
using Cirno.Scripts.Controllers;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
|
||||
public partial class Dead : BaseState<PlayerState, CharacterBody3D>
|
||||
{
|
||||
public override PlayerState StateId => PlayerState.Dead;
|
||||
|
||||
[Export]
|
||||
private ActorResourceProvider _motivationProvider;
|
||||
[Export]
|
||||
private InputProvider _inputProvider;
|
||||
|
||||
[Export]
|
||||
private ActorResourceProvider _healthProvider;
|
||||
|
||||
[Export]
|
||||
private PlayerAnimationProvider3D _animationProvider;
|
||||
|
||||
private bool _isGameOver = false;
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
base.EnterState();
|
||||
MainObject.Hide();
|
||||
//MainObject.Hide();
|
||||
|
||||
_animationProvider.PlayDeathAnimation();
|
||||
|
||||
|
||||
if (_motivationProvider.CurrentResource < 100f)
|
||||
{
|
||||
// If motivation is not enough show game over scene
|
||||
Hud.Instance.ShowGameOver();
|
||||
_isGameOver = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Else show respawn notification
|
||||
Hud.Instance.ShowTerminated();
|
||||
_isGameOver = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
{
|
||||
base.ExitState();
|
||||
Hud.Instance.HideTerminated();
|
||||
}
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
|
|
@ -25,5 +58,34 @@ public partial class Dead : BaseState<PlayerState, CharacterBody3D>
|
|||
public override void ProcessState(double delta)
|
||||
{
|
||||
base.ProcessState(delta);
|
||||
|
||||
if (_inputProvider.GetShootJustPressed())
|
||||
{
|
||||
if (_isGameOver)
|
||||
{
|
||||
// Restart Level
|
||||
GlobalState.Instance.RestartLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
Respawn();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Respawn()
|
||||
{
|
||||
MainObject.GlobalPosition = GameController.Instance.LastCheckPointPosition;
|
||||
_healthProvider.FillResource();
|
||||
PoolingManager.Instance.ClearBullets();
|
||||
|
||||
_motivationProvider.CurrentResource -= 100f;
|
||||
if (_motivationProvider.CurrentResource <= 1f)
|
||||
{
|
||||
_motivationProvider.CurrentResource = 1f;
|
||||
}
|
||||
|
||||
ChangeState(PlayerState.Active);
|
||||
}
|
||||
}
|
||||
30
Scripts/Components/FSM/3DPlayer/Drowning.cs
Normal file
30
Scripts/Components/FSM/3DPlayer/Drowning.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using Cirno.Scripts.Components.Actors._3D;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
|
||||
public partial class Drowning : BaseState<PlayerState, CharacterBody3D>
|
||||
{
|
||||
public override PlayerState StateId => PlayerState.Drowning;
|
||||
|
||||
[Export]
|
||||
private PlayerAnimationProvider3D _animationProvider;
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
_animationProvider.PlayDrowningAnimation();
|
||||
|
||||
// Wait for animation to be over and switch to death
|
||||
_animationProvider.OnAnimationEnded += AnimationProviderOnOnAnimationEnded;
|
||||
}
|
||||
|
||||
private void AnimationProviderOnOnAnimationEnded(StringName animationName)
|
||||
{
|
||||
if (animationName != _animationProvider.DrowningAnimationName) return;
|
||||
|
||||
_animationProvider.OnAnimationEnded -= AnimationProviderOnOnAnimationEnded;
|
||||
|
||||
StateMachine.SetState(PlayerState.Dead);
|
||||
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/FSM/3DPlayer/Drowning.cs.uid
Normal file
1
Scripts/Components/FSM/3DPlayer/Drowning.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bwdmhpotan5ai
|
||||
Loading…
Add table
Add a link
Reference in a new issue