EnterBattleSenceWindow.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.UI;
  5. namespace YLBattle
  6. {
  7. /// <summary>
  8. ///
  9. /// </summary>
  10. public class EnterBattleSenceWindow : MonoBehaviour
  11. {
  12. /// <summary>
  13. ///
  14. /// </summary>
  15. public GameObject mBtnEnterBattleSecne;
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. public GameObject mButtonLoadBundle;
  20. /// <summary>
  21. ///
  22. /// </summary>
  23. public GameObject mButtonUnLoadBundle;
  24. /// <summary>
  25. ///
  26. /// </summary>
  27. public GameObject mButtonPreLoadedRes;
  28. /// <summary>
  29. ///
  30. /// </summary>
  31. public List<string> mons = new List<string>() { "201004", "201001", "201011", "201013", "201015", "201002", };
  32. /// <summary>
  33. /// 特效挂在点
  34. /// </summary>
  35. public Transform mEffectPoint = null;
  36. /// <summary>
  37. /// 测试帧率
  38. /// </summary>
  39. public int MaxFrame = 30;
  40. /// <summary>
  41. /// 关卡ID
  42. /// </summary>
  43. public int mGateId = 0;
  44. /// <summary>
  45. /// bundle.name
  46. /// </summary>
  47. public string bundleName = "";
  48. public InputField mInputFieldTest = null;
  49. //
  50. /// <summary>
  51. /// Use this for initialization
  52. /// </summary>
  53. void Start()
  54. {
  55. //LogHelper.LogError(aa.color.ToString());
  56. //return;
  57. Application.targetFrameRate = Const.GAME_MAX_FRAME;
  58. EventTriggerListener.Get(mBtnEnterBattleSecne).onClick = OnEnterWindow;
  59. EventTriggerListener.Get(mButtonLoadBundle).onClick = OnLoadBundleWindow;
  60. EventTriggerListener.Get(mButtonUnLoadBundle).onClick = OnButtonUnLoadRes;
  61. EventTriggerListener.Get(mButtonPreLoadedRes).onClick = OnButtonPreLoadedRes;
  62. //StartCoroutine("Login");
  63. StartCoroutine(AddExp());
  64. }
  65. int MaxExp = 100;
  66. IEnumerator AddExp()
  67. {
  68. yield return null;
  69. int tmpExp = 0;
  70. if (tmpExp < MaxExp)
  71. {
  72. tmpExp++;
  73. this.mInputFieldTest.text = tmpExp.ToString();
  74. yield return new WaitForSeconds(0.01f);
  75. }
  76. }
  77. /// <summary>
  78. ///
  79. /// </summary>
  80. /// <returns></returns>
  81. IEnumerator Login()
  82. {
  83. //GameCfg.Init();
  84. while (true)
  85. {
  86. if (!GameCfg.DownloadIsOver)
  87. {
  88. yield return null;
  89. }
  90. else
  91. {
  92. UserProxy.Instance.UserLogin("nliang", 1, resp =>
  93. {
  94. //GameCfg.InitGameCfg();
  95. //UserProxy.Instance.player = new Player();
  96. //UserProxy.Instance.player.Initlize(resp);
  97. //UI_GuideManager.Instance.SetGuide(EGuide_GuideType.Battle,0);
  98. //Invoke("LateToWorldMap", 0.25f);
  99. }, () =>
  100. {
  101. });
  102. break;
  103. }
  104. }
  105. }
  106. /// <summary>
  107. ///
  108. /// </summary>
  109. /// <param name="go"></param>
  110. public void OnButtonUnLoadRes(GameObject go)
  111. {
  112. if (this.bundleName == string.Empty)
  113. {
  114. return;
  115. }
  116. ResourceHelper.Instance.UnloadAssetBundle(this.bundleName);
  117. }
  118. /// <summary>
  119. ///
  120. /// </summary>
  121. /// <param name="go"></param>
  122. public void OnButtonPreLoadedRes(GameObject go)
  123. {
  124. //foreach (string s in mons)
  125. {
  126. FightingResManager.Instance.PreLoadDragonBones(mons, FightingResManager.EDragonResLevel.Monster);
  127. }
  128. //FightingDragonResManager.Instance.GetDragonBone("101001", () =>
  129. //{
  130. // _dragonboneCont = FightingDragonResManager.GameDragonBoneFactory.BuildArmatureComponent("101001", "101001");
  131. // _dragonboneCont.transform.SetParent(mEffectPoint);
  132. // LogHelper.LogError(" hashcode:" + _dragonboneCont.GetHashCode());
  133. // _dragonboneCont.animation.Play("Idle");
  134. //});
  135. }
  136. /// <summary>
  137. ///
  138. /// </summary>
  139. /// <param name="go"></param>
  140. public void OnEnterWindow(GameObject go)
  141. {
  142. //LogHelper.LogError(_dragonboneCont.animation.lastAnimationName);
  143. //_dragonboneCont.animation.Play(bundleName);
  144. StartCoroutine("OnLoadBUILoading");
  145. //PanelHelper.Instance.ShowPanel("BUI_Loading", "/CameraManager/UICamera", (GameObject panel) =>
  146. //{
  147. List<string> tempData = new List<string>();
  148. ///此处应该是服务器同步下来的角色实例ID
  149. tempData.Add("10001,0");
  150. tempData.Add("10002,1");
  151. tempData.Add("10003,2");
  152. FightingResManager.Instance.PreLoadDragonBones(mons, FightingResManager.EDragonResLevel.Monster);
  153. //tempData.Add("10004,3");///外网无数据
  154. //tempData.Add("10005,4");
  155. GameBattleManager.Instance().BattleInitialize(mGateId, tempData, false, new List<string>(), 0);
  156. //});
  157. }
  158. private void OnLoadBUILoading()
  159. {
  160. PanelHelper.Instance.ShowPanel("BUI_Loading", (GameObject panel) =>
  161. {
  162. }, null, -1, null, "/CameraManager/UICamera");
  163. }
  164. /// <summary>
  165. ///
  166. /// </summary>
  167. /// <param name="go"></param>
  168. public void OnLoadBundleWindow(GameObject go)
  169. {
  170. if (this.bundleName == string.Empty)
  171. {
  172. return;
  173. }
  174. ResourceHelper.Instance.LoadAssetBundle(bundleName, ab =>
  175. {
  176. if (ab != null)
  177. {
  178. GameObject model = (GameObject)Instantiate(ab.LoadAsset(bundleName));
  179. Transform[] all = model.GetComponentsInChildren<Transform>();
  180. ///默认UI相机照射所有特效
  181. ///如果是bomb在敌人身上(3D)身上,则使用3D摄像机;
  182. foreach (Transform rc in all)
  183. {
  184. rc.gameObject.layer = LayerMask.NameToLayer("UI"); //指定Layer
  185. }
  186. if (mEffectPoint == null)
  187. {
  188. mEffectPoint = this.transform.Find("EffectPoint");
  189. }
  190. model.transform.SetParent(mEffectPoint);
  191. model.transform.position = Vector3.zero;
  192. model.transform.rotation = Quaternion.identity;
  193. model.transform.localScale = new Vector3(1, 1, 1);
  194. }
  195. }
  196. );
  197. }
  198. }
  199. }