CombatAction.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using UnityEngine;
  2. namespace MazeGen
  3. {
  4. /// <summary>
  5. /// Types of actions a combatant can take during their turn.
  6. /// </summary>
  7. public enum ActionType
  8. {
  9. Move, // Move towards/away from target or selected position
  10. Attack, // Attack a target (if in range)
  11. UseItem, // Use a consumable item (health potion, etc.)
  12. Defend, // Brace for impact (future: reduce damage taken)
  13. Pass // Do nothing this turn
  14. }
  15. /// <summary>
  16. /// Represents a single action a combatant can take during their turn in combat.
  17. /// This is decided by the AI (or eventually player input) and then executed by CombatResolver.
  18. /// </summary>
  19. public class CombatAction
  20. {
  21. /// <summary>ID of the combatant taking this action.</summary>
  22. public int ActorId { get; set; }
  23. /// <summary>Type of action being taken.</summary>
  24. public ActionType ActionType { get; set; }
  25. /// <summary>Target combatant (for Attack, Defend). Null for Move/UseItem/Pass.</summary>
  26. public Combatant TargetCombatant { get; set; }
  27. /// <summary>Target grid position (for Move actions). Zero for other action types.</summary>
  28. public Vector2Int TargetPosition { get; set; }
  29. /// <summary>Item to use (for UseItem actions). Null for other action types.</summary>
  30. public Consumable TargetItem { get; set; }
  31. public CombatAction()
  32. {
  33. ActorId = -1;
  34. ActionType = ActionType.Pass;
  35. TargetCombatant = null;
  36. TargetPosition = Vector2Int.zero;
  37. TargetItem = null;
  38. }
  39. public CombatAction(int actorId, ActionType actionType)
  40. {
  41. ActorId = actorId;
  42. ActionType = actionType;
  43. TargetCombatant = null;
  44. TargetPosition = Vector2Int.zero;
  45. TargetItem = null;
  46. }
  47. public CombatAction(int actorId, Combatant targetCombatant)
  48. {
  49. ActorId = actorId;
  50. ActionType = ActionType.Attack;
  51. TargetCombatant = targetCombatant;
  52. TargetPosition = Vector2Int.zero;
  53. TargetItem = null;
  54. }
  55. public CombatAction(int actorId, Vector2Int targetPosition)
  56. {
  57. ActorId = actorId;
  58. ActionType = ActionType.Move;
  59. TargetCombatant = null;
  60. TargetPosition = targetPosition;
  61. TargetItem = null;
  62. }
  63. public override string ToString()
  64. {
  65. return ActionType switch
  66. {
  67. ActionType.Move => $"Move to {TargetPosition}",
  68. ActionType.Attack => $"Attack {TargetCombatant?.Name ?? "null"}",
  69. ActionType.UseItem => $"Use {TargetItem?.ItemName ?? "null"}",
  70. ActionType.Defend => "Defend",
  71. ActionType.Pass => "Pass",
  72. _ => "Unknown action"
  73. };
  74. }
  75. }
  76. }