mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 06:05:54 +00:00
Danmaku system
This commit is contained in:
parent
9c8ec486fc
commit
fdec052c16
38 changed files with 924 additions and 9 deletions
54
Scripts/Actors/Boss.cs
Normal file
54
Scripts/Actors/Boss.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Actors;
|
||||
|
||||
public partial class Boss : Enemy
|
||||
{
|
||||
[Export] private Array<BossPhase> Phases;
|
||||
private int currentPhaseIndex = 0;
|
||||
|
||||
private GameManager _gameManager;
|
||||
|
||||
private Vector2 _homePosition;
|
||||
public Vector2 HomePosition => _homePosition;
|
||||
|
||||
public GameManager GameManager => _gameManager;
|
||||
|
||||
private BossPhase CurrentPhase => Phases[currentPhaseIndex];
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_gameManager = GetNode<GameManager>("/root/GameScene");
|
||||
|
||||
_homePosition = this.GlobalPosition;
|
||||
|
||||
StartPhase(CurrentPhase);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
|
||||
CurrentPhase.UpdatePhase(delta);
|
||||
if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count)
|
||||
{
|
||||
currentPhaseIndex++;
|
||||
StartPhase(CurrentPhase);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void StartPhase(BossPhase phase)
|
||||
{
|
||||
phase.Start(this);
|
||||
}
|
||||
|
||||
public void TakeDamage(int amount)
|
||||
{
|
||||
_currentHealth -= amount;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue