mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
New boss system
This commit is contained in:
parent
0322748d86
commit
c2a72e4e77
14 changed files with 480 additions and 11 deletions
30
Scripts/Components/FSM/Boss/Idle.cs
Normal file
30
Scripts/Components/FSM/Boss/Idle.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Components.FSM.Enemy;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Boss;
|
||||
|
||||
public partial class Idle : EnemyStateBase
|
||||
{
|
||||
public override EnemyState StateId => EnemyState.Idle;
|
||||
|
||||
[Export]
|
||||
public EnemyStorageModule StorageModule { get; private set; }
|
||||
|
||||
[Export]
|
||||
public GenericDamageReceiver DamageReceiver { get; private set; }
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
base.EnterState();
|
||||
DamageReceiver.ChangeState(false);
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
{
|
||||
base.ExitState();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
1
Scripts/Components/FSM/Boss/Idle.cs.uid
Normal file
1
Scripts/Components/FSM/Boss/Idle.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cprumccndvblc
|
||||
121
Scripts/Components/FSM/Boss/Shooting.cs
Normal file
121
Scripts/Components/FSM/Boss/Shooting.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Components.FSM.Enemy;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.ScriptableBullets;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Boss;
|
||||
|
||||
public partial class Shooting : EnemyStateBase
|
||||
{
|
||||
public override EnemyState StateId => EnemyState.Shooting;
|
||||
[Export] public GenericDamageReceiver DamageReceiver { get; private set; }
|
||||
|
||||
[Export] public Weapon EquippedWeapon;
|
||||
|
||||
[Export] public EnemyStorageModule StorageModule { get; private set; }
|
||||
|
||||
[Export] public BossScript BossScript { get; set; }
|
||||
|
||||
// private Marker2D _cameraMarker;
|
||||
//
|
||||
// [Export]
|
||||
// public Vector2 CameraOffset = Vector2.Zero;
|
||||
|
||||
private int _currentPhaseIndex = 0;
|
||||
|
||||
public Vector2 HomePosition => StorageModule.HomePosition;
|
||||
|
||||
private BossPhase CurrentPhase => BossScript.Phases[_currentPhaseIndex];
|
||||
|
||||
private bool _waiting = false;
|
||||
|
||||
public float CurrentHealth => DamageReceiver.HealthProvider.CurrentResource;
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
base.EnterState();
|
||||
|
||||
DamageReceiver.ChangeState(true);
|
||||
|
||||
DamageReceiver.HealthProvider.ResourceDepleted += HealthProviderOnResourceDepleted;
|
||||
|
||||
StartPhase(CurrentPhase);
|
||||
|
||||
//CallDeferred(MethodName.InitDeferred);
|
||||
}
|
||||
|
||||
private void InitDeferred()
|
||||
{
|
||||
}
|
||||
|
||||
private void GrabCamera()
|
||||
{
|
||||
}
|
||||
|
||||
private void HealthProviderOnResourceDepleted()
|
||||
{
|
||||
ChangeState(EnemyState.Dead);
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
{
|
||||
base.ExitState();
|
||||
|
||||
DamageReceiver.HealthProvider.ResourceDepleted -= HealthProviderOnResourceDepleted;
|
||||
|
||||
DamageReceiver.ChangeState(false);
|
||||
}
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
{
|
||||
base.PhysicsProcessState(delta);
|
||||
}
|
||||
|
||||
public override void ProcessState(double delta)
|
||||
{
|
||||
base.ProcessState(delta);
|
||||
|
||||
if (_waiting) return;
|
||||
CurrentPhase.UpdatePhase(delta);
|
||||
|
||||
if (CurrentHealth <= CurrentPhase.Threshold && _currentPhaseIndex + 1 < BossScript.Phases.Count)
|
||||
{
|
||||
_currentPhaseIndex++;
|
||||
//_bossHud.SpellCardName = CurrentPhase.PhaseName;
|
||||
StartPhase(CurrentPhase);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartPhase(BossPhase phase)
|
||||
{
|
||||
GameManager.Instance.ClearBullets();
|
||||
if (phase.PlayAnimation)
|
||||
{
|
||||
_waiting = true;
|
||||
|
||||
DamageReceiver.ChangeState(false);
|
||||
_ = Switchphase(phase);
|
||||
}
|
||||
else
|
||||
{
|
||||
phase.Start(this);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Switchphase(BossPhase phase)
|
||||
{
|
||||
await PlayAnimation();
|
||||
|
||||
_waiting = false;
|
||||
DamageReceiver.ChangeState(true);
|
||||
phase.Start(this);
|
||||
}
|
||||
|
||||
private async Task PlayAnimation()
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/FSM/Boss/Shooting.cs.uid
Normal file
1
Scripts/Components/FSM/Boss/Shooting.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://difn6d5np1pui
|
||||
Loading…
Add table
Add a link
Reference in a new issue