| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using UnityEngine;
- namespace MazeGen
- {
- /// <summary>
- /// Types of actions a combatant can take during their turn.
- /// </summary>
- public enum ActionType
- {
- Move, // Move towards/away from target or selected position
- Attack, // Attack a target (if in range)
- UseItem, // Use a consumable item (health potion, etc.)
- Defend, // Brace for impact (future: reduce damage taken)
- Pass // Do nothing this turn
- }
- /// <summary>
- /// Represents a single action a combatant can take during their turn in combat.
- /// This is decided by the AI (or eventually player input) and then executed by CombatResolver.
- /// </summary>
- public class CombatAction
- {
- /// <summary>ID of the combatant taking this action.</summary>
- public int ActorId { get; set; }
- /// <summary>Type of action being taken.</summary>
- public ActionType ActionType { get; set; }
- /// <summary>Target combatant (for Attack, Defend). Null for Move/UseItem/Pass.</summary>
- public Combatant TargetCombatant { get; set; }
- /// <summary>Target grid position (for Move actions). Zero for other action types.</summary>
- public Vector2Int TargetPosition { get; set; }
- /// <summary>Item to use (for UseItem actions). Null for other action types.</summary>
- public Consumable TargetItem { get; set; }
- public CombatAction()
- {
- ActorId = -1;
- ActionType = ActionType.Pass;
- TargetCombatant = null;
- TargetPosition = Vector2Int.zero;
- TargetItem = null;
- }
- public CombatAction(int actorId, ActionType actionType)
- {
- ActorId = actorId;
- ActionType = actionType;
- TargetCombatant = null;
- TargetPosition = Vector2Int.zero;
- TargetItem = null;
- }
- public CombatAction(int actorId, Combatant targetCombatant)
- {
- ActorId = actorId;
- ActionType = ActionType.Attack;
- TargetCombatant = targetCombatant;
- TargetPosition = Vector2Int.zero;
- TargetItem = null;
- }
- public CombatAction(int actorId, Vector2Int targetPosition)
- {
- ActorId = actorId;
- ActionType = ActionType.Move;
- TargetCombatant = null;
- TargetPosition = targetPosition;
- TargetItem = null;
- }
- public override string ToString()
- {
- return ActionType switch
- {
- ActionType.Move => $"Move to {TargetPosition}",
- ActionType.Attack => $"Attack {TargetCombatant?.Name ?? "null"}",
- ActionType.UseItem => $"Use {TargetItem?.ItemName ?? "null"}",
- ActionType.Defend => "Defend",
- ActionType.Pass => "Pass",
- _ => "Unknown action"
- };
- }
- }
- }
|