UPGRADE_API_GUIDE.cs.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /// UPGRADE API USAGE GUIDE
  2. ///
  3. /// The Upgrade system allows you to modify ball effect parameters at runtime.
  4. /// This is perfect for progression systems, difficulty scaling, or power-ups.
  5. ///
  6. /// HOW IT WORKS:
  7. /// 1. GameManager holds an UpgradeState that tracks all active upgrades
  8. /// 2. When a ball is assigned a random effect, the UpgradeManager applies active upgrades
  9. /// 3. Upgraded definitions are created as runtime copies - originals are never modified
  10. /// 4. Each ball spawned with upgrades active will have those upgrades applied
  11. ///
  12. /// ========================================
  13. /// BASIC USAGE EXAMPLES
  14. /// ========================================
  15. ///
  16. /// // Increase explosive radius by 0.5 units
  17. /// GameManager.Instance.UpgradeExplosiveRadius(0.5f);
  18. ///
  19. /// // Double the explosive damage (1.0 = no change, 2.0 = double)
  20. /// GameManager.Instance.UpgradeExplosiveDamage(2.0f);
  21. ///
  22. /// // Add 15 degrees to split angle
  23. /// GameManager.Instance.UpgradeSplitAngle(15f);
  24. ///
  25. /// // Increase split projectile speed by 50%
  26. /// GameManager.Instance.UpgradeSplitSpeed(1.5f);
  27. ///
  28. /// // Double split projectile damage
  29. /// GameManager.Instance.UpgradeSplitDamage(2.0f);
  30. ///
  31. /// // Add 2 extra piercing hits
  32. /// GameManager.Instance.UpgradePiercingHits(2);
  33. ///
  34. /// // Increase homing turn rate by 50%
  35. /// GameManager.Instance.UpgradeHomingTurnRate(1.5f);
  36. ///
  37. /// // Triple teleport distance
  38. /// GameManager.Instance.UpgradeTeleportDistance(3.0f);
  39. ///
  40. /// // Reset all upgrades back to defaults
  41. /// GameManager.Instance.ResetAllUpgrades();
  42. ///
  43. /// // Get current upgrade state (for UI display or debugging)
  44. /// UpgradeState state = GameManager.Instance.GetUpgradeState();
  45. ///
  46. /// ========================================
  47. /// UPGRADE STACKING
  48. /// ========================================
  49. ///
  50. /// Additive upgrades (radius, angle, hits) stack by addition:
  51. /// - UpgradeExplosiveRadius(0.5f) called twice = +1.0 total
  52. ///
  53. /// Multiplicative upgrades (damage, speed, turn rate, distance) stack by multiplication:
  54. /// - UpgradeSplitSpeed(1.5f) called twice = 1.5 * 1.5 = 2.25x total
  55. ///
  56. /// ========================================
  57. /// UPGRADE SCOPES
  58. /// ========================================
  59. ///
  60. /// Explosive Effect Upgrades:
  61. /// - ExplosiveRadius / ExplosiveRadiusBonus
  62. /// - ExplosiveDamage / ExplosiveDamageMultiplier
  63. ///
  64. /// Triple Split Effect Upgrades:
  65. /// - SplitAngle / SplitAngleBonus
  66. /// - SplitSpeed / SplitSpeedMultiplier
  67. /// - SplitDamage / SplitDamageMultiplier
  68. ///
  69. /// Piercing Effect Upgrades:
  70. /// - PiercingHits / PiercingHitsBonus
  71. ///
  72. /// Homing Effect Upgrades:
  73. /// - HomingTurnRate / HomingTurnRateMultiplier
  74. ///
  75. /// Teleport Effect Upgrades:
  76. /// - TeleportDistance / TeleportDistanceMultiplier
  77. ///
  78. /// ========================================
  79. /// PRACTICAL PROGRESSION EXAMPLE
  80. /// ========================================
  81. ///
  82. /// public class ProgressionManager : MonoBehaviour
  83. /// {
  84. /// private int level = 1;
  85. ///
  86. /// public void ProgressToNextLevel()
  87. /// {
  88. /// level++;
  89. ///
  90. /// // Scale all upgrades by level
  91. /// GameManager.Instance.UpgradeExplosiveRadius(level * 0.1f);
  92. /// GameManager.Instance.UpgradeExplosiveDamage(1.0f + (level * 0.1f));
  93. /// GameManager.Instance.UpgradeSplitSpeed(1.0f + (level * 0.05f));
  94. /// GameManager.Instance.UpgradePiercingHits(level);
  95. /// GameManager.Instance.UpgradeHomingTurnRate(1.0f + (level * 0.1f));
  96. ///
  97. /// Debug.Log($"Level {level} upgrades applied!");
  98. /// }
  99. /// }
  100. ///
  101. /// ========================================
  102. /// IMPLEMENTATION DETAILS
  103. /// ========================================
  104. ///
  105. /// UpgradeState.cs:
  106. /// - Tracks all upgrade values (both additive and multiplicative)
  107. /// - ResetAll() method returns to defaults
  108. /// - ToString() provides debug output
  109. ///
  110. /// UpgradeManager.cs (Static):
  111. /// - ApplyUpgrades(definition, upgrades) creates modified copies of definitions
  112. /// - Each effect type has its own upgrade application method
  113. /// - Never modifies original ScriptableObject assets - creates runtime copies only
  114. /// - Safely handles null inputs
  115. ///
  116. /// GameManager.cs Changes:
  117. /// - Added _upgrades field initialized in Awake()
  118. /// - Modified GetRandomEffect() to apply upgrades via UpgradeManager
  119. /// - Added public methods for each upgrade type
  120. /// - GetUpgradeState() for external inspection
  121. /// - All upgrade methods emit Debug.Log for testing
  122. ///
  123. /// ========================================
  124. /// NOTES FOR DEVELOPERS
  125. /// ========================================
  126. ///
  127. /// • Upgrades persist across ball respawns - they apply to all future balls
  128. /// • Upgrade application happens in GetRandomEffect(), called when:
  129. /// - InitializeBallQueue() (initial 5 balls)
  130. /// - InitializeBallQueue() in level restart
  131. /// - Automatically on each new ball from queue
  132. /// • Multipliers use "x" notation (1.5x = 50% increase, 2.0x = 100% increase)
  133. /// • Bonus values are added directly (0.5 units, 15 degrees, 2 hits)
  134. /// • Created upgraded definitions are temporary runtime objects
  135. /// - They don't persist to disk
  136. /// - New definitions recreated each time GetRandomEffect() is called
  137. /// • Safe to call multiple times - values accumulate appropriately
  138. ///
  139. /// ========================================
  140. /// DEBUG OUTPUT
  141. /// ========================================
  142. ///
  143. /// Each upgrade method emits a Debug.Log showing the change and new total.
  144. /// Enable Debug.Log in the Console to see progression:
  145. ///
  146. /// Example console output:
  147. /// - Upgraded Explosive Radius: +0.5 (Total: +0.5)
  148. /// - Upgraded Explosive Damage: x2 (Total: x2.00)
  149. /// - Upgraded Split Speed: x1.5 (Total: x2.25)
  150. /// - All upgrades reset to default values.
  151. ///