Merge pull request 'Made the fight world completable' (#33) from feature/night_to_day into develop
Reviewed-on: #33
This commit was merged in pull request #33.
This commit is contained in:
@@ -4,11 +4,8 @@ using Babushka.scripts.CSharp.Common.Util;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Fight.Actions;
|
||||
|
||||
public class BlobAttackAction : FighterAction
|
||||
public class BlobAttackAction(int damage = 3) : FighterAction
|
||||
{
|
||||
// settings
|
||||
private const int Damage = 3;
|
||||
|
||||
public override Variant<float, Func<bool>> GetAnimationEnd()
|
||||
{
|
||||
return 1;
|
||||
@@ -21,7 +18,7 @@ public class BlobAttackAction : FighterAction
|
||||
|
||||
public override void ExecuteAction()
|
||||
{
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-Damage);
|
||||
FightWorld.Instance.allyFighters.vesnaFighter.AddHealth(-damage);
|
||||
}
|
||||
|
||||
public override async Task AnimateAction(AllFightersVisual allFightersVisual)
|
||||
@@ -34,7 +31,7 @@ public class BlobAttackAction : FighterAction
|
||||
|
||||
await currentFighterVisual.AnimatePosToTarget(targetFighterVisual);
|
||||
_ = targetFighterVisual.AnimateHit();
|
||||
targetFighterVisual.SpawnDamageIndicatorNumber(Damage);
|
||||
targetFighterVisual.SpawnDamageIndicatorNumber(damage);
|
||||
await currentFighterVisual.AnimatePosToBase();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class AllyFighters
|
||||
public FightWorld.Fighter vesnaFighter = new()
|
||||
{
|
||||
type = FightWorld.Fighter.Type.Vesna,
|
||||
maxHealth = 20,
|
||||
maxHealth = 60,
|
||||
availableActions =
|
||||
[
|
||||
new AllyAttackAction()
|
||||
|
||||
@@ -11,6 +11,7 @@ public partial class FightSceneSwitcher : Node
|
||||
[Export] private Node _sceneRoot = null!;
|
||||
[Export] private string _fightRoomScenePath = null!;
|
||||
[Export] private string _fightHappeningScene = null!;
|
||||
[Export] private string _nightEndScene = null!;
|
||||
|
||||
private void LoadNext()
|
||||
{
|
||||
@@ -36,6 +37,12 @@ public partial class FightSceneSwitcher : Node
|
||||
if (!FightWorld.Instance.currentRoom.paths.TryGetValue(pathIndex, out var nextRoom))
|
||||
throw new Exception("Trying to go down a non-existent path");
|
||||
|
||||
if (nextRoom.specialRoom == FightWorld.Room.Special.EndOfNight)
|
||||
{
|
||||
ExitFightWorld();
|
||||
return;
|
||||
}
|
||||
|
||||
FightWorld.Instance.currentRoom = nextRoom;
|
||||
LoadNext();
|
||||
}
|
||||
@@ -60,4 +67,10 @@ public partial class FightSceneSwitcher : Node
|
||||
FightWorld.Instance.fightHappeningData = null;
|
||||
LoadNext();
|
||||
}
|
||||
|
||||
public void ExitFightWorld()
|
||||
{
|
||||
SceneTransitionThreaded.Instance.ChangeSceneToFile(_nightEndScene);
|
||||
_ = UnloadAfterDelay();
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,14 @@ public partial class FightWorld : Node
|
||||
|
||||
public class Room
|
||||
{
|
||||
public enum Special
|
||||
{
|
||||
None,
|
||||
EndOfNight
|
||||
}
|
||||
public required Dictionary<int, Room> paths;
|
||||
public required List<FighterGroup> enemyGroups;
|
||||
public Special specialRoom = Special.None;
|
||||
}
|
||||
|
||||
public class FighterGroup
|
||||
@@ -66,7 +72,6 @@ public partial class FightWorld : Node
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Instance = this;
|
||||
MyEnterTree();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -76,7 +81,7 @@ public partial class FightWorld : Node
|
||||
public FightHappeningData? fightHappeningData = null;
|
||||
public AllyFighters allyFighters = new();
|
||||
|
||||
public void MyEnterTree()
|
||||
public void ResetFightWorld()
|
||||
{
|
||||
Generate();
|
||||
currentRoom = world!.rooms[0];
|
||||
@@ -108,6 +113,13 @@ public partial class FightWorld : Node
|
||||
{
|
||||
rooms.Add(GenerateDisconnectedRoom());
|
||||
}
|
||||
|
||||
rooms.Add(new Room
|
||||
{
|
||||
paths = [],
|
||||
enemyGroups = [],
|
||||
specialRoom = Room.Special.EndOfNight
|
||||
});
|
||||
|
||||
// Connect rooms linearly
|
||||
for (var i = 0; i < rooms.Count - 1; i++)
|
||||
@@ -133,7 +145,7 @@ public partial class FightWorld : Node
|
||||
{
|
||||
var enemyGroups = new List<FighterGroup>();
|
||||
|
||||
var enemyGroupCount = GD.RandRange(1, 3);
|
||||
var enemyGroupCount = GD.RandRange(1, 2);
|
||||
|
||||
for (var i = 0; i < enemyGroupCount; i++)
|
||||
{
|
||||
@@ -150,7 +162,7 @@ public partial class FightWorld : Node
|
||||
fighters = []
|
||||
};
|
||||
|
||||
var enemyCount = GD.RandRange(1, 3);
|
||||
var enemyCount = GD.RandRange(2, 3);
|
||||
|
||||
for (var i = 0; i < enemyCount; i++)
|
||||
{
|
||||
@@ -178,10 +190,10 @@ public partial class FightWorld : Node
|
||||
{
|
||||
type = type,
|
||||
health = null,
|
||||
maxHealth = 12,
|
||||
maxHealth = GD.RandRange(8, 20),
|
||||
availableActions =
|
||||
[
|
||||
new BlobAttackAction()
|
||||
new BlobAttackAction(GD.RandRange(2, 5))
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.Fight;
|
||||
|
||||
public partial class NightStarter : Node
|
||||
{
|
||||
[Export] private int _sceneIndexToLoad;
|
||||
|
||||
[Signal] public delegate void LoadSceneEventHandler(int index);
|
||||
|
||||
public void StartNight()
|
||||
{
|
||||
FightWorld.Instance.ResetFightWorld();
|
||||
EmitSignalLoadScene(_sceneIndexToLoad);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://puw74w6lmcvl
|
||||
Reference in New Issue
Block a user