EnemyGeneratorDebugGUI.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using DatabaseModel;
  3. using UnityEngine;
  4. namespace Tools
  5. {
  6. public class EnemyGeneratorDebugGUI : DebugGuiBase
  7. {
  8. protected override string UIDebugButtonName
  9. {
  10. get
  11. {
  12. return "敌人生成";
  13. }
  14. }
  15. public override void OnDebugGUI()
  16. {
  17. Array values = Enum.GetValues(typeof(EnemyType));
  18. string text = values.GetValue(this.index).ToString();
  19. if (this.InVisible)
  20. {
  21. GUILayout.BeginVertical("box", new GUILayoutOption[0]);
  22. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  23. GUILayout.Label(string.Format("Current Enemy: {0}", text), new GUILayoutOption[0]);
  24. GUILayout.EndHorizontal();
  25. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  26. if (GUILayout.Button("Previous", new GUILayoutOption[]
  27. {
  28. GUILayout.Width(50f),
  29. GUILayout.Height(30f)
  30. }))
  31. {
  32. this.index = (this.index - 1 + values.Length) % values.Length;
  33. }
  34. if (GUILayout.Button("Next", new GUILayoutOption[]
  35. {
  36. GUILayout.Width(50f),
  37. GUILayout.Height(30f)
  38. }))
  39. {
  40. this.index = (this.index + 1) % values.Length;
  41. }
  42. if (GUILayout.Button("Generate", new GUILayoutOption[]
  43. {
  44. GUILayout.Width(50f),
  45. GUILayout.Height(30f)
  46. }))
  47. {
  48. Vector2 value = R.Player.Transform.position;
  49. EnemyAttrData enemyAttrData = EnemyAttrData.FindBySceneNameAndType(LevelManager.SceneName, (EnemyType)Enum.Parse(typeof(EnemyType), text));
  50. value.x += UnityEngine.Random.Range(-3f, 3f);
  51. value.y = ((enemyAttrData.flyHeight != 0) ? MathfX.HeightToPos((float)enemyAttrData.flyHeight) : -3.69999981f);
  52. Singleton<EnemyGenerator>.Instance.GenerateEnemy(EnumTools.ToEnum<EnemyType>(text, false), new Vector2?(value), true, true);
  53. }
  54. GUILayout.EndHorizontal();
  55. GUILayout.EndVertical();
  56. }
  57. }
  58. protected override void GUIStart()
  59. {
  60. }
  61. private int index;
  62. }
  63. }