mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 04:35:53 +00:00
Fix for phase switch animation
This commit is contained in:
parent
bfdb71dd84
commit
95979bd3b8
7 changed files with 21 additions and 14 deletions
|
|
@ -14,6 +14,7 @@ public partial class Boss : Enemy, IActivable
|
|||
private int currentPhaseIndex = 0;
|
||||
|
||||
private bool _started = false;
|
||||
private bool _waiting = false;
|
||||
|
||||
private GameManager _gameManager;
|
||||
public GameManager GameManager => _gameManager;
|
||||
|
|
@ -22,7 +23,7 @@ public partial class Boss : Enemy, IActivable
|
|||
private BossPhase CurrentPhase => Phases[currentPhaseIndex];
|
||||
|
||||
private Marker2D _cameraMarker;
|
||||
|
||||
|
||||
[Export]
|
||||
public Vector2 CameraOffset = Vector2.Zero;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ public partial class Boss : Enemy, IActivable
|
|||
base._Process(delta);
|
||||
|
||||
if (!_started) return;
|
||||
if (_waiting) return;
|
||||
|
||||
CurrentPhase.UpdatePhase(delta);
|
||||
if (_currentHealth <= CurrentPhase.Threshold && currentPhaseIndex + 1 < Phases.Count)
|
||||
|
|
@ -108,6 +110,8 @@ public partial class Boss : Enemy, IActivable
|
|||
{
|
||||
if (phase.PlayAnimation)
|
||||
{
|
||||
_waiting = true;
|
||||
_invulnerable = true;
|
||||
_ = Switchphase(phase);
|
||||
}
|
||||
else
|
||||
|
|
@ -138,6 +142,8 @@ public partial class Boss : Enemy, IActivable
|
|||
{
|
||||
await PlayAnimation();
|
||||
|
||||
_waiting = false;
|
||||
_invulnerable = false;
|
||||
phase.Start(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ public partial class Enemy : CharacterBody2D
|
|||
private bool _isDestroyed = false;
|
||||
|
||||
private NavigationAgent2D _navigationAgent;
|
||||
|
||||
|
||||
protected bool _invulnerable = false;
|
||||
|
||||
private bool IsPlayerInRange => _playerDetection is { IsPlayerInRange: true };
|
||||
|
||||
private bool IsPlayerInSight => _playerDetection is not null && _playerDetection.IsPlayerInSight(CollisionMask);
|
||||
|
|
@ -203,7 +205,9 @@ public partial class Enemy : CharacterBody2D
|
|||
private void _on_damage_hitbox_area_entered(Area2D area)
|
||||
{
|
||||
if (area is not Bullet bullet) return;
|
||||
GD.Print("Enemy Received damage");
|
||||
if (_invulnerable) return;
|
||||
if (bullet.BulletInfo.Owner == BulletOwner.Enemy) return;
|
||||
|
||||
this.Hit(bullet.Damage);
|
||||
bullet.QueueFree();
|
||||
}
|
||||
|
|
@ -225,9 +229,10 @@ public partial class Enemy : CharacterBody2D
|
|||
public void Hit(float damage)
|
||||
{
|
||||
if (_isDestroyed) return;
|
||||
if (_invulnerable) return;
|
||||
|
||||
_currentHealth -= damage;
|
||||
EmitSignal(nameof(HealthChanged), _currentHealth);
|
||||
EmitSignal(SignalName.HealthChanged, _currentHealth);
|
||||
if (!(_currentHealth <= 0)) return;
|
||||
_isDestroyed = true;
|
||||
Explode();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue