GameTools.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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("Add Craft(Red)"))
  38. {
  39. if(Application.isPlaying)
  40. {
  41. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  42. int craftId = StringUtil.ToInt(addCraftId);
  43. float x = StringUtil.ToFloat(addCraftX);
  44. float y = StringUtil.ToFloat(addCraftY);
  45. CraftData craftData = new CraftData(craftId);
  46. craftData.id = Random.Range(1000, 10000);
  47. craftData.userId = Random.Range(1000, 10000);
  48. craftData.position = new Vector3(x, 0, y);
  49. craftData.team = TeamUtil.Team.Red;
  50. craftData.aiType = AI.AIType.Show;
  51. craftData.nick = "";
  52. craftData.isHero = true;
  53. battleSession.GetBattleController().CreateCraft(craftData);
  54. }
  55. }
  56. if(GUILayout.Button("Add Craft(Blue)"))
  57. {
  58. if(Application.isPlaying)
  59. {
  60. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  61. int craftId = StringUtil.ToInt(addCraftId);
  62. float x = StringUtil.ToFloat(addCraftX);
  63. float y = StringUtil.ToFloat(addCraftY);
  64. CraftData craftData = new CraftData(craftId);
  65. craftData.id = Random.Range(1000, 10000);
  66. craftData.userId = Random.Range(1000, 10000);
  67. craftData.position = new Vector3(x, 0, y);
  68. craftData.team = TeamUtil.Team.Blue;
  69. craftData.aiType = AI.AIType.Show;
  70. craftData.nick = "";
  71. craftData.isHero = true;
  72. battleSession.GetBattleController().CreateCraft(craftData);
  73. }
  74. }
  75. GUILayout.Label("ID:", GUILayout.Width(25));
  76. addCraftId = GUILayout.TextField(addCraftId);
  77. GUILayout.Label("X:", GUILayout.Width(20));
  78. addCraftX = GUILayout.TextField(addCraftX);
  79. GUILayout.Label("Y:", GUILayout.Width(20));
  80. addCraftY = GUILayout.TextField(addCraftY);
  81. GUILayout.EndHorizontal();
  82. GUILayout.BeginHorizontal();
  83. if(GUILayout.Button("Self Hurt, Range(6)"))
  84. {
  85. if(Application.isPlaying)
  86. {
  87. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  88. Craft craft = battleSession.GetBattleController().GetCtrlCraft();
  89. if(craft != null)
  90. {
  91. List<BattleObject> list = battleSession.GetBattleController().GetMap().GetBattleObjectByRange(craft.position, 6f, craft.team);
  92. for(int i=0; i<list.Count; i++)
  93. {
  94. list[i].MakeDamage(StringUtil.ToFloat(selfHurt));
  95. }
  96. }
  97. }
  98. }
  99. GUILayout.Label("Damage:", GUILayout.Width(50));
  100. selfHurt = GUILayout.TextField(selfHurt);
  101. GUILayout.EndHorizontal();
  102. GUILayout.Label("Pose tools");
  103. GUILayout.BeginHorizontal();
  104. if(GUILayout.Button("Add Craft"))
  105. {
  106. if(Application.isPlaying)
  107. {
  108. BattleSession battleSession = Session.GetInstance().GetBattleSession();
  109. int craftId = StringUtil.ToInt(addCraftId);
  110. CraftData craftData = new CraftData(craftId);
  111. craftData.id = Random.Range(1000, 10000);
  112. craftData.userId = battleSession.myUserId;
  113. craftData.position = new Vector3(8f, 0, 8f);
  114. craftData.team = TeamUtil.Team.Blue;
  115. craftData.aiType = AI.AIType.Show;
  116. craftData.nick = "";
  117. craftData.isHero = true;
  118. Craft craft = battleSession.GetBattleController().CreateCraft(craftData);
  119. craft.position = new Vector3(8f, 0, 8f);
  120. craft.bodyTrans.gameObject.AddComponent<CraftPoseRotater>();
  121. CraftSelectionPanel craftSelectPanel = GameObject.FindObjectOfType<CraftSelectionPanel>();
  122. if(craftSelectPanel != null)
  123. craftSelectPanel.Close();
  124. }
  125. }
  126. GUILayout.Label("ID:", GUILayout.Width(25));
  127. addCraftId = GUILayout.TextField(addCraftId);
  128. GUILayout.EndHorizontal();
  129. if (Application.isPlaying) {
  130. if (GUILayout.Button ("Battle Win")) {
  131. Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
  132. Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Blue);
  133. }
  134. if (GUILayout.Button ("Battle lose")) {
  135. Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
  136. Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Red);
  137. }
  138. if (GUILayout.Button ("Battle draw")) {
  139. Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
  140. Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Yellow);
  141. }
  142. }
  143. if (Application.isPlaying) {
  144. if (GUILayout.Button ("Create clan")) {
  145. ClanRequest.Create ("Fenix", "My first clan, wa ha ha.", ClanData.Limit.Anyone);
  146. }
  147. }
  148. if(GUILayout.Button("WWW.EscapeURL"))
  149. {
  150. Debug.Log (WWW.EscapeURL(msg));
  151. Debug.Log (StringUtil.LimitInput(msg, 6));
  152. }
  153. replayFile = EditorGUILayout.TextField(replayFile);
  154. // if(GUILayout.Button("Load Replay"))
  155. // {
  156. // ReplayManager.GetInstance ().Load (replayFile);
  157. // }
  158. // if(GUILayout.Button("Share Replay"))
  159. // {
  160. // ChatRequest.Replay ("my first replay", replayFile);
  161. // }
  162. if (GUILayout.Button ("Battle Win")) {
  163. ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Win, Random.Range(10, 100)));
  164. }
  165. if (GUILayout.Button ("Battle Lose")) {
  166. ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Lose, Random.Range(10, 100)));
  167. }
  168. if (GUILayout.Button ("Battle Draw")) {
  169. ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Draw, Random.Range(10, 100)));
  170. }
  171. }
  172. }