Fight happening base setup

This commit is contained in:
jonathan
2025-09-21 14:54:55 +02:00
parent fd0e631b1f
commit f27dd199b8
38 changed files with 1022 additions and 681 deletions
+37 -13
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Babushka.scripts.CSharp.Common.Util;
using Godot;
namespace Babushka.scripts.CSharp.Common.Fight;
@@ -18,21 +19,39 @@ public partial class FightWorld : Node
public class EnemyGroup
{
public required List<Enemy> enemies;
public required List<Fighter> enemies;
}
public class Enemy
public class FightHappeningData
{
public FightHappening.FightState fightState = FightHappening.FightState.None;
public FighterStack fighterStack = new();
public required EnemyGroup enemyGroup;
}
public class Fighter
{
public enum Type
{
Blob,
BigBlob,
Mavka,
YourMom
YourMom,
Vesna
}
public required Type type;
public required int? health = null; // null => initialize to full health on spawn
public required int maxHealth;
public required bool isEnemy;
public required List<FighterAction> availableActions;
public int? health = null; // null => initialize to full health on spawn
public bool entered = false;
public int actionsLeft;
public FighterAction AutoSelectAction()
{
return availableActions.Random() ?? new FighterAction.Skip();
}
}
#region AutoLoad ( Contains _EnterTree() )
@@ -46,10 +65,10 @@ public partial class FightWorld : Node
}
#endregion
public World? world = null;
public Room? currentRoom = null;
public EnemyGroup? inFightWith = null;
public FightHappeningData? fightHappeningData = null;
public void MyEnterTree()
{
@@ -135,22 +154,27 @@ public partial class FightWorld : Node
return enemyGroup;
}
private Enemy GenerateSingleEnemy()
private Fighter GenerateSingleEnemy()
{
var typeRoll = GD.RandRange(0, 99);
var type = typeRoll switch
{
< 50 => Enemy.Type.Blob,
< 75 => Enemy.Type.BigBlob,
< 90 => Enemy.Type.Mavka,
_ => Enemy.Type.YourMom
< 50 => Fighter.Type.Blob,
< 75 => Fighter.Type.BigBlob,
< 90 => Fighter.Type.Mavka,
_ => Fighter.Type.YourMom
};
var enemy = new Enemy
var enemy = new Fighter
{
type = type,
health = null
health = null,
isEnemy = true,
maxHealth = 12,
availableActions = [
new FighterAction.Skip()
]
};
return enemy;