Merge branch 'develop' into feature/farming_bugfixes_and_magic_word
# Conflicts: # scenes/Babushka_scene_farm_outside_2d.tscn # scenes/Babushka_scene_indoor_vesnas_room.tscn # scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs
This commit is contained in:
@@ -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,6 +192,8 @@ public partial class FightHappening : Node
|
||||
HappeningData.actionStaging = null;
|
||||
HappeningData.fightersEnterStaging = null;
|
||||
|
||||
RemoveDeadFighters();
|
||||
|
||||
if (!FightWorld.Instance.allyFighters.IsAlive())
|
||||
{
|
||||
ChangeState(FightState.EnemyWin);
|
||||
@@ -345,6 +347,17 @@ public partial class FightHappening : Node
|
||||
vesnaFighter.health = vesnaFighter.maxHealth;
|
||||
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
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.Util;
|
||||
using Godot;
|
||||
|
||||
@@ -15,15 +16,14 @@ public partial class FightRoomSceneSetup : Node
|
||||
{
|
||||
var room = FightWorld.Instance.currentRoom!;
|
||||
|
||||
var i = 0;
|
||||
foreach (var availableParent in _enemyGroupSpawns.Shuffle())
|
||||
foreach (var (parent, group) in _enemyGroupSpawns.Zip(room.enemyGroups))
|
||||
{
|
||||
var enemyGroup = room.enemyGroups[i];
|
||||
if (group.AreAllDead())
|
||||
continue;
|
||||
|
||||
var roamingEnemyGroup = _roamingEnemyGroupPrefab.Instantiate<RoamingEnemyGroup>();
|
||||
roamingEnemyGroup.Initialize(enemyGroup, _fightSceneSwitcher);
|
||||
availableParent.AddChild(roamingEnemyGroup);
|
||||
if (i >= room.enemyGroups.Count - 1) break;
|
||||
i++;
|
||||
roamingEnemyGroup.Initialize(group, _fightSceneSwitcher);
|
||||
parent.AddChild(roamingEnemyGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public class FighterTurn
|
||||
public class FighterTurn : IEnumerable<FightWorld.Fighter>
|
||||
{
|
||||
private class Node
|
||||
{
|
||||
@@ -13,7 +16,8 @@ public class FighterTurn
|
||||
|
||||
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()
|
||||
{
|
||||
@@ -84,7 +88,7 @@ public class FighterTurn
|
||||
{
|
||||
// if removing current, keep current
|
||||
// it will be implicitly deleted by loss of reference on the next Next() call
|
||||
|
||||
|
||||
node.next = node.next.next;
|
||||
return true;
|
||||
}
|
||||
@@ -94,4 +98,26 @@ public class FighterTurn
|
||||
|
||||
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,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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user