PlayerEnemyHealth.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using UnityEngine;
  3. namespace Tools
  4. {
  5. public class PlayerEnemyHealth : DebugGuiBase
  6. {
  7. protected override string UIDebugButtonName
  8. {
  9. get
  10. {
  11. return "血量控制";
  12. }
  13. }
  14. protected override void GUIStart()
  15. {
  16. float num = (float)Screen.width;
  17. this.GUIArea = new Rect(num / 2f - 320f, 20f, 640f, 500f);
  18. }
  19. public override void OnDebugGUI()
  20. {
  21. GUILayout.BeginArea(this.GUIArea);
  22. GUILayout.BeginVertical("box", new GUILayoutOption[0]);
  23. GUILayout.Label("HP " + R.Player.Attribute.currentHP, new GUILayoutOption[0]);
  24. GUILayout.BeginHorizontal(new GUILayoutOption[]
  25. {
  26. GUILayout.Width(600f)
  27. });
  28. GUILayout.FlexibleSpace();
  29. if (GUILayout.Button("Kill All Enemies", new GUILayoutOption[]
  30. {
  31. GUILayout.Width(400f)
  32. }))
  33. {
  34. this.KillAllEnemy();
  35. }
  36. GUILayout.FlexibleSpace();
  37. GUILayout.EndHorizontal();
  38. GUILayout.BeginHorizontal(new GUILayoutOption[]
  39. {
  40. GUILayout.Width(600f)
  41. });
  42. GUILayout.FlexibleSpace();
  43. if (GUILayout.Button("Full HP", new GUILayoutOption[]
  44. {
  45. GUILayout.Width(400f)
  46. }))
  47. {
  48. this.PlayerHPRecover();
  49. }
  50. GUILayout.FlexibleSpace();
  51. GUILayout.EndHorizontal();
  52. GUILayout.BeginHorizontal(new GUILayoutOption[]
  53. {
  54. GUILayout.Width(600f)
  55. });
  56. GUILayout.FlexibleSpace();
  57. if (GUILayout.Button("Kill yourself", new GUILayoutOption[]
  58. {
  59. GUILayout.Width(400f)
  60. }))
  61. {
  62. this.KillPlayer();
  63. }
  64. GUILayout.FlexibleSpace();
  65. GUILayout.EndHorizontal();
  66. GUILayout.BeginHorizontal(new GUILayoutOption[]
  67. {
  68. GUILayout.Width(600f)
  69. });
  70. GUILayout.FlexibleSpace();
  71. if (GUILayout.Button("HP -20", new GUILayoutOption[]
  72. {
  73. GUILayout.Width(400f)
  74. }))
  75. {
  76. R.Player.Attribute.currentHP -= 20;
  77. }
  78. GUILayout.FlexibleSpace();
  79. GUILayout.EndHorizontal();
  80. GUILayout.EndVertical();
  81. GUILayout.EndArea();
  82. }
  83. private void KillAllEnemy()
  84. {
  85. R.Enemy.KillAllEnemy();
  86. }
  87. private void PlayerHPRecover()
  88. {
  89. PlayerAction.Reborn();
  90. }
  91. private void KillPlayer()
  92. {
  93. R.Player.Kill();
  94. }
  95. private Rect GUIArea;
  96. }
  97. }