123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- using UnityEditor;
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class GameTools : EditorWindow
- {
- private string addCraftId = "1";
- private string addCraftX = "64";
- private string addCraftY = "56";
- private string selfHurt = "300";
- private string testDevice = "";
- private string clanId = "0";
- private string msg = "";
- private string replayFile = "";
- // Add menu item named "My Window" to the Window menu
- [MenuItem("BattleArray/Game Tools")]
- public static void ShowWindow()
- {
- //Show existing window instance. If one doesn't exist, make one.
- EditorWindow.GetWindow(typeof(GameTools));
- }
-
- void OnGUI()
- {
- if(GUILayout.Button("Delete All PlayerPrefs"))
- {
- LocalSaver.GetInstance().DeleteAll();
- }
- GUILayout.Label("Test device");
- testDevice = GUILayout.TextField(testDevice);
- if(GUILayout.Button("Login with test device"))
- {
- Session.GetInstance ().myUserData.deviceId = testDevice;
- Session.GetInstance ().GetNetworkManager ().Login (null);
- }
- GUILayout.Label("Show tools");
- GUILayout.BeginHorizontal();
- if(GUILayout.Button("Add Craft(Red)"))
- {
- if(Application.isPlaying)
- {
- BattleSession battleSession = Session.GetInstance().GetBattleSession();
- int craftId = StringUtil.ToInt(addCraftId);
- float x = StringUtil.ToFloat(addCraftX);
- float y = StringUtil.ToFloat(addCraftY);
- CraftData craftData = new CraftData(craftId);
- craftData.id = Random.Range(1000, 10000);
- craftData.userId = Random.Range(1000, 10000);
- craftData.position = new Vector3(x, 0, y);
- craftData.team = TeamUtil.Team.Red;
- craftData.aiType = AI.AIType.Show;
-
- craftData.nick = "";
- craftData.isHero = true;
- battleSession.GetBattleController().CreateCraft(craftData);
- }
- }
- if(GUILayout.Button("Add Craft(Blue)"))
- {
- if(Application.isPlaying)
- {
- BattleSession battleSession = Session.GetInstance().GetBattleSession();
-
- int craftId = StringUtil.ToInt(addCraftId);
- float x = StringUtil.ToFloat(addCraftX);
- float y = StringUtil.ToFloat(addCraftY);
-
- CraftData craftData = new CraftData(craftId);
- craftData.id = Random.Range(1000, 10000);
- craftData.userId = Random.Range(1000, 10000);
- craftData.position = new Vector3(x, 0, y);
- craftData.team = TeamUtil.Team.Blue;
- craftData.aiType = AI.AIType.Show;
-
- craftData.nick = "";
- craftData.isHero = true;
- battleSession.GetBattleController().CreateCraft(craftData);
- }
- }
- GUILayout.Label("ID:", GUILayout.Width(25));
- addCraftId = GUILayout.TextField(addCraftId);
- GUILayout.Label("X:", GUILayout.Width(20));
- addCraftX = GUILayout.TextField(addCraftX);
- GUILayout.Label("Y:", GUILayout.Width(20));
- addCraftY = GUILayout.TextField(addCraftY);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal();
- if(GUILayout.Button("Self Hurt, Range(6)"))
- {
- if(Application.isPlaying)
- {
- BattleSession battleSession = Session.GetInstance().GetBattleSession();
- Craft craft = battleSession.GetBattleController().GetCtrlCraft();
- if(craft != null)
- {
- List<BattleObject> list = battleSession.GetBattleController().GetMap().GetBattleObjectByRange(craft.position, 6f, craft.team);
- for(int i=0; i<list.Count; i++)
- {
- list[i].MakeDamage(StringUtil.ToFloat(selfHurt));
- }
- }
- }
- }
- GUILayout.Label("Damage:", GUILayout.Width(50));
- selfHurt = GUILayout.TextField(selfHurt);
- GUILayout.EndHorizontal();
- GUILayout.Label("Pose tools");
- GUILayout.BeginHorizontal();
- if(GUILayout.Button("Add Craft"))
- {
- if(Application.isPlaying)
- {
- BattleSession battleSession = Session.GetInstance().GetBattleSession();
-
- int craftId = StringUtil.ToInt(addCraftId);
- CraftData craftData = new CraftData(craftId);
- craftData.id = Random.Range(1000, 10000);
- craftData.userId = battleSession.myUserId;
- craftData.position = new Vector3(8f, 0, 8f);
- craftData.team = TeamUtil.Team.Blue;
- craftData.aiType = AI.AIType.Show;
-
- craftData.nick = "";
- craftData.isHero = true;
- Craft craft = battleSession.GetBattleController().CreateCraft(craftData);
- craft.position = new Vector3(8f, 0, 8f);
- craft.bodyTrans.gameObject.AddComponent<CraftPoseRotater>();
- CraftSelectionPanel craftSelectPanel = GameObject.FindObjectOfType<CraftSelectionPanel>();
- if(craftSelectPanel != null)
- craftSelectPanel.Close();
- }
- }
- GUILayout.Label("ID:", GUILayout.Width(25));
- addCraftId = GUILayout.TextField(addCraftId);
- GUILayout.EndHorizontal();
- if (Application.isPlaying) {
- if (GUILayout.Button ("Battle Win")) {
- Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
- Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Blue);
- }
- if (GUILayout.Button ("Battle lose")) {
- Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
- Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Red);
- }
- if (GUILayout.Button ("Battle draw")) {
- Session.GetInstance ().GetBattleSession ().myPlayer.coinSpend = Random.Range(100, 150);
- Session.GetInstance ().GetBattleSession ().GetBattleController().GameOver(TeamUtil.Team.Yellow);
- }
- }
- if (Application.isPlaying) {
- if (GUILayout.Button ("Create clan")) {
- ClanRequest.Create ("Fenix", "My first clan, wa ha ha.", ClanData.Limit.Anyone);
- }
- }
- if(GUILayout.Button("WWW.EscapeURL"))
- {
- Debug.Log (WWW.EscapeURL(msg));
- Debug.Log (StringUtil.LimitInput(msg, 6));
- }
- replayFile = EditorGUILayout.TextField(replayFile);
- // if(GUILayout.Button("Load Replay"))
- // {
- // ReplayManager.GetInstance ().Load (replayFile);
- // }
- // if(GUILayout.Button("Share Replay"))
- // {
- // ChatRequest.Replay ("my first replay", replayFile);
- // }
- if (GUILayout.Button ("Battle Win")) {
- ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Win, Random.Range(10, 100)));
- }
- if (GUILayout.Button ("Battle Lose")) {
- ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Lose, Random.Range(10, 100)));
- }
- if (GUILayout.Button ("Battle Draw")) {
- ResultPanel.Show (new ResultPanel.ResultData(null, null, ResultPanel.Result.Draw, Random.Range(10, 100)));
- }
- }
- }
|