UpgradeAPIDemo.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using UnityEngine;
  2. using UnityEngine.InputSystem;
  3. /// <summary>
  4. /// Example script demonstrating the Upgrade API.
  5. /// Attach this to a GameObject in your scene to test upgrades with keyboard input.
  6. /// </summary>
  7. public class UpgradeAPIDemo : MonoBehaviour
  8. {
  9. void Update()
  10. {
  11. if (Keyboard.current == null)
  12. return;
  13. // Press 'E' to upgrade explosive radius
  14. if (Keyboard.current.eKey.wasPressedThisFrame)
  15. {
  16. GameManager.Instance.UpgradeExplosiveRadius(0.5f);
  17. }
  18. // Press 'D' to upgrade explosive damage
  19. if (Keyboard.current.dKey.wasPressedThisFrame)
  20. {
  21. GameManager.Instance.UpgradeExplosiveDamage(1.5f);
  22. }
  23. // Press 'S' to upgrade split angle
  24. if (Keyboard.current.sKey.wasPressedThisFrame)
  25. {
  26. GameManager.Instance.UpgradeSplitAngle(10f);
  27. }
  28. // Press 'P' to upgrade split speed
  29. if (Keyboard.current.pKey.wasPressedThisFrame)
  30. {
  31. GameManager.Instance.UpgradeSplitSpeed(1.5f);
  32. }
  33. // Press 'I' to upgrade piercing hits
  34. if (Keyboard.current.iKey.wasPressedThisFrame)
  35. {
  36. GameManager.Instance.UpgradePiercingHits(1);
  37. }
  38. // Press 'H' to upgrade homing turn rate
  39. if (Keyboard.current.hKey.wasPressedThisFrame)
  40. {
  41. GameManager.Instance.UpgradeHomingTurnRate(1.5f);
  42. }
  43. // Press 'T' to upgrade teleport distance
  44. if (Keyboard.current.tKey.wasPressedThisFrame)
  45. {
  46. GameManager.Instance.UpgradeTeleportDistance(1.5f);
  47. }
  48. // Press 'R' to reset all upgrades
  49. if (Keyboard.current.rKey.wasPressedThisFrame)
  50. {
  51. GameManager.Instance.ResetAllUpgrades();
  52. }
  53. // Press 'U' to print upgrade summary
  54. if (Keyboard.current.uKey.wasPressedThisFrame)
  55. {
  56. UpgradeState state = GameManager.Instance.GetUpgradeState();
  57. Debug.Log("=== CURRENT UPGRADES ===\n" + state.ToString());
  58. }
  59. }
  60. void OnGUI()
  61. {
  62. GUILayout.BeginArea(new Rect(10, 10, 400, 300));
  63. GUILayout.Label("UPGRADE API DEMO - Press keys to test:", new GUIStyle(GUI.skin.label) { fontSize = 14 });
  64. GUILayout.Label("E - Explosive Radius (+0.5)");
  65. GUILayout.Label("D - Explosive Damage (x1.5)");
  66. GUILayout.Label("S - Split Angle (+10°)");
  67. GUILayout.Label("P - Split Speed (x1.5)");
  68. GUILayout.Label("I - Piercing Hits (+1)");
  69. GUILayout.Label("H - Homing Turn Rate (x1.5)");
  70. GUILayout.Label("T - Teleport Distance (x1.5)");
  71. GUILayout.Label("R - Reset All Upgrades");
  72. GUILayout.Label("U - Print Upgrade Summary (check Console)");
  73. GUILayout.EndArea();
  74. }
  75. }