GameTools.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using UnityEditor;
  2. using UnityEngine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. public class GameTools : EditorWindow
  6. {
  7. private string addCraftId = "1";
  8. private string addCraftX = "64";
  9. private string addCraftY = "56";
  10. private string selfHurt = "300";
  11. private string testDevice = "";
  12. private string clanId = "0";
  13. private string msg = "";
  14. private string replayFile = "";
  15. // Add menu item named "My Window" to the Window menu
  16. [MenuItem("BattleArray/Game Tools")]
  17. public static void ShowWindow()
  18. {
  19. //Show existing window instance. If one doesn't exist, make one.
  20. EditorWindow.GetWindow(typeof(GameTools));
  21. }
  22. void OnGUI()
  23. {
  24. if(GUILayout.Button("Delete All PlayerPrefs"))
  25. {
  26. LocalSaver.GetInstance().DeleteAll();
  27. }
  28. GUILayout.Label("Test device");
  29. testDevice = GUILayout.TextField(testDevice);
  30. if(GUILayout.Button("Login with test device"))
  31. {
  32. Session.GetInstance ().myUserData.deviceId = testDevice;
  33. Session.GetInstance ().GetNetworkManager ().Login (null);
  34. }
  35. GUILayout.Label("Show tools");
  36. GUILayout.BeginHorizontal();
  37. if(GUILayout.Button("Self Hurt, Range(6)"))
  38. {
  39. if(Application.isPlaying)
  40. {
  41. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  42. Craft craft = battleSession.GetBattleController().GetCtrlCraft();
  43. if(craft != null)
  44. {
  45. List<BattleObject> list = battleSession.GetBattleController().GetMap().GetBattleObjectByRange(craft.position, 6f, craft.team);
  46. for(int i=0; i<list.Count; i++)
  47. {
  48. list[i].MakeDamage(StringUtil.ToFloat(selfHurt));
  49. }
  50. }
  51. }
  52. }
  53. GUILayout.Label("Damage:", GUILayout.Width(50));
  54. selfHurt = GUILayout.TextField(selfHurt);
  55. GUILayout.EndHorizontal();
  56. GUILayout.Label("Pose tools");
  57. GUILayout.BeginHorizontal();
  58. if(GUILayout.Button("Add Craft"))
  59. {
  60. if(Application.isPlaying)
  61. {
  62. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  63. int craftId = StringUtil.ToInt(addCraftId);
  64. CraftData craftData = new CraftData(craftId);
  65. craftData.id = Random.Range(1000, 10000);
  66. craftData.userId = battleSession.myUserId;
  67. craftData.position = new Vector3(8f, 0, 8f);
  68. craftData.team = TeamUtil.Team.Blue;
  69. craftData.aiType = AI.AIType.Show;
  70. craftData.nick = "";
  71. craftData.isHero = true;
  72. Craft craft = battleSession.GetBattleController().CreateCraft(craftData, new CraftEquipModify());
  73. craft.position = new Vector3(8f, 0, 8f);
  74. craft.bodyTrans.gameObject.AddComponent<CraftPoseRotater>();
  75. CraftSelectionPanel craftSelectPanel = GameObject.FindObjectOfType<CraftSelectionPanel>();
  76. if(craftSelectPanel != null)
  77. craftSelectPanel.Close();
  78. }
  79. }
  80. GUILayout.Label("ID:", GUILayout.Width(25));
  81. addCraftId = GUILayout.TextField(addCraftId);
  82. GUILayout.EndHorizontal();
  83. if (Application.isPlaying) {
  84. if (GUILayout.Button ("Battle Win")) {
  85. Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
  86. Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Blue);
  87. }
  88. if (GUILayout.Button ("Battle lose")) {
  89. Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
  90. Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Red);
  91. }
  92. if (GUILayout.Button ("Battle draw")) {
  93. Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
  94. Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Yellow);
  95. }
  96. }
  97. if (Application.isPlaying) {
  98. if (GUILayout.Button ("Create clan")) {
  99. ClanRequest.Create ("Fenix", "My first clan, wa ha ha.", ClanData.Limit.Anyone);
  100. }
  101. }
  102. if(GUILayout.Button("WWW.EscapeURL"))
  103. {
  104. Debug.Log (WWW.EscapeURL(msg));
  105. Debug.Log (StringUtil.LimitInput(msg, 6));
  106. }
  107. replayFile = EditorGUILayout.TextField(replayFile);
  108. // if(GUILayout.Button("Load Replay"))
  109. // {
  110. // ReplayManager.GetInstance ().Load (replayFile);
  111. // }
  112. // if(GUILayout.Button("Share Replay"))
  113. // {
  114. // ChatRequest.Replay ("my first replay", replayFile);
  115. // }
  116. if (GUILayout.Button ("Battle Win")) {
  117. ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Win, Random.Range(10, 100)));
  118. }
  119. if (GUILayout.Button ("Battle Lose")) {
  120. ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Lose, Random.Range(10, 100)));
  121. }
  122. if (GUILayout.Button ("Battle Draw")) {
  123. ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Draw, Random.Range(10, 100)));
  124. }
  125. }
  126. }