Compare commits

..

2 Commits

Author SHA1 Message Date
jonathan edbd4a182b 🎨Removed comment 2025-11-11 10:19:37 +01:00
jonathan f51275ccc0 made dead fighters shrink to telegraph to the player that they are dead 2025-11-04 16:42:16 +01:00
4 changed files with 11 additions and 55 deletions
@@ -59,7 +59,7 @@ public partial class AllFightersVisual : Node
if (from == FightHappening.FightState.ActionAnim)
{
_fighterVisuals.Values.ForEach(fv => fv.UpdateHealthBar());
_fighterVisuals.Values.ForEach(fv => fv.UpdateVisuals());
}
}
@@ -192,8 +192,6 @@ public partial class FightHappening : Node
HappeningData.actionStaging = null;
HappeningData.fightersEnterStaging = null;
RemoveDeadFighters();
if (!FightWorld.Instance.allyFighters.IsAlive())
{
ChangeState(FightState.EnemyWin);
@@ -348,17 +346,6 @@ public partial class FightHappening : Node
GD.Print("Vesna has been revived. This is for the current prototype only");
}
private void RemoveDeadFighters()
{
foreach (var f in HappeningData.fighterTurn)
{
if (f.IsDead())
{
HappeningData.fighterTurn.Remove(f);
}
}
}
#endregion // Game Logic
#region Utility
+2 -28
View File
@@ -1,12 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Babushka.scripts.CSharp.Common.Fight;
public class FighterTurn : IEnumerable<FightWorld.Fighter>
public class FighterTurn
{
private class Node
{
@@ -16,8 +13,7 @@ public class FighterTurn : IEnumerable<FightWorld.Fighter>
private Node? _currentNode;
public FightWorld.Fighter Current =>
_currentNode?.fighter ?? throw new InvalidOperationException("No current fighter");
public FightWorld.Fighter Current => _currentNode?.fighter ?? throw new InvalidOperationException("No current fighter");
public void Next()
{
@@ -98,26 +94,4 @@ public class FighterTurn : IEnumerable<FightWorld.Fighter>
return false;
}
public IEnumerator<FightWorld.Fighter> GetEnumerator()
{
if (_currentNode == null) return Enumerable.Empty<FightWorld.Fighter>().GetEnumerator();
var list = new List<FightWorld.Fighter>();
var n = _currentNode;
while (true)
{
list.Add(n.fighter);
if (n.next == _currentNode)
break;
n = n.next;
}
return list.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
+7 -12
View File
@@ -7,7 +7,6 @@ using Godot.Collections;
namespace Babushka.scripts.CSharp.Common.Fight;
public partial class FighterVisual : Node2D
{
#region Shortcuts
@@ -28,21 +27,17 @@ public partial class FighterVisual : Node2D
public void Initialize(FightWorld.Fighter fighter)
{
_boundFighter = fighter;
UpdateMirrorState();
UpdateHealthBar();
UpdateVisuals();
}
/// <summary>
/// fighter visuals should always look to the right in the scene.
/// This function flips the sprites horizontally, when the fighter is an enemy.
/// </summary>
private void UpdateMirrorState()
public void UpdateVisuals()
{
_visualParent.Scale = new Vector2(_boundFighter.IsInFormation(HappeningData.enemyFighterFormation) ? -1 : 1, 1);
}
// fighter visuals should always look to the right in the scene.
// This function flips the sprites horizontally, when the fighter is an enemy.
_visualParent.Scale = new Vector2(
_boundFighter.IsInFormation(HappeningData.enemyFighterFormation) ? -1 : 1,
_boundFighter.IsDead() ? .3f : 1);
public void UpdateHealthBar()
{
healthBarVisual.UpdateHealth(_boundFighter.GetHealth(), _boundFighter.maxHealth);
}