HazardTravelEvent.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using UnityEngine;
  2. /// <summary>
  3. /// Hazard events - natural dangers, traps, environmental challenges
  4. /// </summary>
  5. [CreateAssetMenu(fileName = "New Hazard Event", menuName = "RPG/Travel Events/Hazard Event")]
  6. public class HazardTravelEvent : TravelEvent
  7. {
  8. [Header("Hazard Settings")]
  9. public int minHealthLoss = 5;
  10. public int maxHealthLoss = 20;
  11. public int goldCost = 0; // Cost to avoid the hazard
  12. [Header("Hazard Descriptions")]
  13. [TextArea(2, 4)]
  14. public string[] hazardDescriptions = {
  15. "Your party gets caught in a sudden rockslide, losing {damage} health.",
  16. "Treacherous terrain causes injuries to your party members, resulting in {damage} health loss.",
  17. "A hidden pit trap catches one of your party members, causing {damage} damage."
  18. };
  19. public override EventResult ExecuteEvent(TravelEventContext context)
  20. {
  21. int damage = Random.Range(minHealthLoss, maxHealthLoss + 1);
  22. string description = hazardDescriptions[Random.Range(0, hazardDescriptions.Length)];
  23. description = description.Replace("{damage}", damage.ToString());
  24. return new EventResult(description)
  25. {
  26. healthChange = -damage,
  27. goldChange = -goldCost
  28. };
  29. }
  30. void OnEnable()
  31. {
  32. eventType = EventType.Hazard;
  33. rarity = EventRarity.Common;
  34. // More likely in dangerous terrain
  35. mountainChance = 0.9f;
  36. forestChance = 0.6f;
  37. riverChance = 0.7f;
  38. oceanChance = 0.8f;
  39. // Less likely in safe areas
  40. roadChance = 0.2f;
  41. townChance = 0.1f;
  42. villageChance = 0.2f;
  43. plainsChance = 0.4f;
  44. }
  45. }