150 lines
4.5 KiB
C#
150 lines
4.5 KiB
C#
using UnityEngine;
|
|
|
|
[System.Serializable]
|
|
public class BattleStrategy
|
|
{
|
|
[Header("Strategy Configuration")]
|
|
public StrategyType strategyType;
|
|
public string strategyName;
|
|
public string description;
|
|
|
|
[Header("Engagement Rules")]
|
|
public float engagementRange = 15f; // Distance at which to engage enemies
|
|
public float formationTightness = 1f; // How tight the formation should be (0-2)
|
|
public bool maintainFormation = true;
|
|
public bool allowRetreat = true;
|
|
|
|
[Header("Unit Type Specific Settings")]
|
|
public InfantryTactics infantryTactics = InfantryTactics.HoldLine;
|
|
public CavalryTactics cavalryTactics = CavalryTactics.Flank;
|
|
public ArcherTactics archerTactics = ArcherTactics.WaitForOptimalRange;
|
|
|
|
[Header("Conditional Behaviors")]
|
|
public float aggressionLevel = 0.5f; // 0 = defensive, 1 = very aggressive
|
|
public bool focusFireOnWeakTargets = true;
|
|
public bool supportAllies = true;
|
|
public float retreatThreshold = 0.3f; // Health percentage to retreat
|
|
|
|
public BattleStrategy()
|
|
{
|
|
strategyType = StrategyType.HoldPosition; // Set a default strategy type
|
|
strategyName = "Default Strategy";
|
|
description = "Basic battle strategy";
|
|
}
|
|
|
|
public BattleStrategy(StrategyType type, string name, string desc)
|
|
{
|
|
strategyType = type;
|
|
strategyName = name;
|
|
description = desc;
|
|
}
|
|
|
|
// Preset strategies for common battle tactics
|
|
public static BattleStrategy CreateHoldPositionStrategy()
|
|
{
|
|
return new BattleStrategy(StrategyType.HoldPosition, "Hold the Line", "Maintain defensive positions and repel enemy attacks")
|
|
{
|
|
engagementRange = 8f,
|
|
formationTightness = 1.5f,
|
|
maintainFormation = true,
|
|
aggressionLevel = 0.3f,
|
|
infantryTactics = InfantryTactics.HoldLine,
|
|
cavalryTactics = CavalryTactics.Defend,
|
|
archerTactics = ArcherTactics.SupportInfantry
|
|
};
|
|
}
|
|
|
|
public static BattleStrategy CreateFlankStrategy()
|
|
{
|
|
return new BattleStrategy(StrategyType.Flank, "Flank Attack", "Circle around enemy flanks for devastating attacks")
|
|
{
|
|
engagementRange = 12f,
|
|
formationTightness = 0.8f,
|
|
maintainFormation = false,
|
|
aggressionLevel = 0.8f,
|
|
infantryTactics = InfantryTactics.Advance,
|
|
cavalryTactics = CavalryTactics.Flank,
|
|
archerTactics = ArcherTactics.WaitForOptimalRange
|
|
};
|
|
}
|
|
|
|
public static BattleStrategy CreateChargeStrategy()
|
|
{
|
|
return new BattleStrategy(StrategyType.Charge, "All-Out Charge", "Aggressive frontal assault on enemy lines")
|
|
{
|
|
engagementRange = 20f,
|
|
formationTightness = 0.5f,
|
|
maintainFormation = false,
|
|
aggressionLevel = 1.0f,
|
|
infantryTactics = InfantryTactics.Charge,
|
|
cavalryTactics = CavalryTactics.Charge,
|
|
archerTactics = ArcherTactics.AdvanceAndFire
|
|
};
|
|
}
|
|
|
|
public static BattleStrategy CreateSpreadWideStrategy()
|
|
{
|
|
return new BattleStrategy(StrategyType.SpreadWide, "Spread Formation", "Spread wide to avoid concentrated attacks")
|
|
{
|
|
engagementRange = 15f,
|
|
formationTightness = 0.3f,
|
|
maintainFormation = true,
|
|
aggressionLevel = 0.6f,
|
|
infantryTactics = InfantryTactics.SpreadOut,
|
|
cavalryTactics = CavalryTactics.HitAndRun,
|
|
archerTactics = ArcherTactics.SpreadAndFire
|
|
};
|
|
}
|
|
|
|
public static BattleStrategy CreateWaitForCloseStrategy()
|
|
{
|
|
return new BattleStrategy(StrategyType.WaitForClose, "Wait for Close Range", "Hold fire until enemies are at optimal range")
|
|
{
|
|
engagementRange = 6f,
|
|
formationTightness = 1.2f,
|
|
maintainFormation = true,
|
|
aggressionLevel = 0.4f,
|
|
infantryTactics = InfantryTactics.HoldLine,
|
|
cavalryTactics = CavalryTactics.WaitForOpportunity,
|
|
archerTactics = ArcherTactics.WaitForOptimalRange
|
|
};
|
|
}
|
|
}
|
|
|
|
public enum StrategyType
|
|
{
|
|
HoldPosition,
|
|
Flank,
|
|
Charge,
|
|
SpreadWide,
|
|
WaitForClose,
|
|
Custom
|
|
}
|
|
|
|
public enum InfantryTactics
|
|
{
|
|
HoldLine,
|
|
Advance,
|
|
Charge,
|
|
SpreadOut,
|
|
FormSquare
|
|
}
|
|
|
|
public enum CavalryTactics
|
|
{
|
|
Charge,
|
|
Flank,
|
|
HitAndRun,
|
|
Defend,
|
|
WaitForOpportunity
|
|
}
|
|
|
|
public enum ArcherTactics
|
|
{
|
|
WaitForOptimalRange,
|
|
SupportInfantry,
|
|
AdvanceAndFire,
|
|
SpreadAndFire,
|
|
FocusHeavyTargets
|
|
}
|