Advertisement
VolfKingLuck

ConditionsDB

Jan 16th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ConditionsDB
  6. {
  7. public static void Init()
  8. {
  9. foreach (var kvp in Conditions)
  10. {
  11. var conditionId = kvp.Key;
  12. var condition = kvp.Value;
  13.  
  14. condition.Id = conditionId;
  15. }
  16. }
  17.  
  18.  
  19. public static Dictionary<ConditionID, Condition> Conditions { get; set; } = new Dictionary<ConditionID, Condition>()
  20. {
  21. {
  22. ConditionID.psn,
  23. new Condition()
  24. {
  25. Name = "Poison",
  26. StartMessage = "has been poisoned",
  27. OnAfterTurn = (MonsterGirl monsterGirl) =>
  28. {
  29. monsterGirl.UpdateHP(monsterGirl.MaxHP /8);
  30. monsterGirl.StatusChanges.Enqueue($"{monsterGirl.Base.Name} is hurt due to poison");
  31. }
  32. }
  33. },
  34. {
  35. ConditionID.brn,
  36. new Condition()
  37. {
  38. Name = "Burn",
  39. StartMessage = "has been burned",
  40. OnAfterTurn = (MonsterGirl monsterGirl) =>
  41. {
  42. monsterGirl.UpdateHP(monsterGirl.MaxHP / 16);
  43. monsterGirl.StatusChanges.Enqueue($"{monsterGirl.Base.Name} is hurt due to burn");
  44. }
  45. }
  46. },
  47. {
  48. ConditionID.par,
  49. new Condition()
  50. {
  51. Name = "Paralyzed",
  52. StartMessage = "has been paralyzed",
  53. OnBeforeTurn = (MonsterGirl monsterGirl) =>
  54. {
  55. if (Random.Range(1, 5) == 1)
  56. {
  57. monsterGirl.StatusChanges.Enqueue($"{monsterGirl.Base.Name} felt numb and is unable to move");
  58. return false;
  59. }
  60. return true;
  61. }
  62. }
  63. },
  64. {
  65. ConditionID.frz,
  66. new Condition()
  67. {
  68. Name = "Freeze",
  69. StartMessage = "has been frozen",
  70. OnBeforeTurn = (MonsterGirl monsterGirl) =>
  71. {
  72. if (Random.Range(1, 5) == 1)
  73. {
  74. monsterGirl.CureStatus();
  75. monsterGirl.StatusChanges.Enqueue($"{monsterGirl.Base.Name} is no longer frozen");
  76. return true;
  77. }
  78. return false;
  79. }
  80. }
  81. },
  82. {
  83. ConditionID.slp,
  84. new Condition()
  85. {
  86. Name = "Sleep",
  87. StartMessage = "has fallen asleep",
  88. OnStart = (MonsterGirl monstergirl) =>
  89. {
  90. //Sleep for 1-3 turns
  91. monstergirl.StatusTime = Random.Range(1, 4);
  92. Debug.Log($"Will be asleep for {monstergirl.StatusTime} turns");
  93. },
  94. OnBeforeTurn = (MonsterGirl monsterGirl) =>
  95. {
  96. if (monsterGirl.StatusTime <= 0)
  97. {
  98. monsterGirl.CureStatus();
  99. monsterGirl.StatusChanges.Enqueue($"{monsterGirl.Base.Name} woke up!");
  100. return true;
  101. }
  102.  
  103. monsterGirl.StatusTime--;
  104. monsterGirl.StatusChanges.Enqueue($"{monsterGirl.Base.Name} is still fast asleep");
  105. return false;
  106. }
  107. }
  108. }
  109.  
  110. };
  111. }
  112.  
  113. public enum ConditionID
  114. {
  115. none, psn, brn, slp, par, frz
  116. }
Tags: Unity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement