123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine.UI;
- namespace YLBattle
- {
- /// <summary>
- ///
- /// </summary>
- public class EnterBattleSenceWindow : MonoBehaviour
- {
- /// <summary>
- ///
- /// </summary>
- public GameObject mBtnEnterBattleSecne;
- /// <summary>
- ///
- /// </summary>
- public GameObject mButtonLoadBundle;
- /// <summary>
- ///
- /// </summary>
- public GameObject mButtonUnLoadBundle;
- /// <summary>
- ///
- /// </summary>
- public GameObject mButtonPreLoadedRes;
- /// <summary>
- ///
- /// </summary>
- public List<string> mons = new List<string>() { "201004", "201001", "201011", "201013", "201015", "201002", };
- /// <summary>
- /// 特效挂在点
- /// </summary>
- public Transform mEffectPoint = null;
- /// <summary>
- /// 测试帧率
- /// </summary>
- public int MaxFrame = 30;
- /// <summary>
- /// 关卡ID
- /// </summary>
- public int mGateId = 0;
- /// <summary>
- /// bundle.name
- /// </summary>
- public string bundleName = "";
- public InputField mInputFieldTest = null;
- //
- /// <summary>
- /// Use this for initialization
- /// </summary>
- void Start()
- {
- //LogHelper.LogError(aa.color.ToString());
- //return;
- Application.targetFrameRate = Const.GAME_MAX_FRAME;
- EventTriggerListener.Get(mBtnEnterBattleSecne).onClick = OnEnterWindow;
- EventTriggerListener.Get(mButtonLoadBundle).onClick = OnLoadBundleWindow;
- EventTriggerListener.Get(mButtonUnLoadBundle).onClick = OnButtonUnLoadRes;
- EventTriggerListener.Get(mButtonPreLoadedRes).onClick = OnButtonPreLoadedRes;
- //StartCoroutine("Login");
- StartCoroutine(AddExp());
- }
- int MaxExp = 100;
- IEnumerator AddExp()
- {
- yield return null;
- int tmpExp = 0;
- if (tmpExp < MaxExp)
- {
- tmpExp++;
- this.mInputFieldTest.text = tmpExp.ToString();
- yield return new WaitForSeconds(0.01f);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- IEnumerator Login()
- {
- //GameCfg.Init();
- while (true)
- {
- if (!GameCfg.DownloadIsOver)
- {
- yield return null;
- }
- else
- {
- UserProxy.Instance.UserLogin("nliang", 1, resp =>
- {
- //GameCfg.InitGameCfg();
- //UserProxy.Instance.player = new Player();
- //UserProxy.Instance.player.Initlize(resp);
- //UI_GuideManager.Instance.SetGuide(EGuide_GuideType.Battle,0);
- //Invoke("LateToWorldMap", 0.25f);
- }, () =>
- {
- });
- break;
- }
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="go"></param>
- public void OnButtonUnLoadRes(GameObject go)
- {
- if (this.bundleName == string.Empty)
- {
- return;
- }
- ResourceHelper.Instance.UnloadAssetBundle(this.bundleName);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="go"></param>
- public void OnButtonPreLoadedRes(GameObject go)
- {
- //foreach (string s in mons)
- {
- FightingResManager.Instance.PreLoadDragonBones(mons, FightingResManager.EDragonResLevel.Monster);
- }
- //FightingDragonResManager.Instance.GetDragonBone("101001", () =>
- //{
- // _dragonboneCont = FightingDragonResManager.GameDragonBoneFactory.BuildArmatureComponent("101001", "101001");
- // _dragonboneCont.transform.SetParent(mEffectPoint);
- // LogHelper.LogError(" hashcode:" + _dragonboneCont.GetHashCode());
- // _dragonboneCont.animation.Play("Idle");
- //});
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="go"></param>
- public void OnEnterWindow(GameObject go)
- {
- //LogHelper.LogError(_dragonboneCont.animation.lastAnimationName);
- //_dragonboneCont.animation.Play(bundleName);
- StartCoroutine("OnLoadBUILoading");
- //PanelHelper.Instance.ShowPanel("BUI_Loading", "/CameraManager/UICamera", (GameObject panel) =>
- //{
- List<string> tempData = new List<string>();
- ///此处应该是服务器同步下来的角色实例ID
- tempData.Add("10001,0");
- tempData.Add("10002,1");
- tempData.Add("10003,2");
- FightingResManager.Instance.PreLoadDragonBones(mons, FightingResManager.EDragonResLevel.Monster);
- //tempData.Add("10004,3");///外网无数据
- //tempData.Add("10005,4");
- GameBattleManager.Instance().BattleInitialize(mGateId, tempData, false, new List<string>(), 0);
- //});
- }
- private void OnLoadBUILoading()
- {
- PanelHelper.Instance.ShowPanel("BUI_Loading", (GameObject panel) =>
- {
- }, null, -1, null, "/CameraManager/UICamera");
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="go"></param>
- public void OnLoadBundleWindow(GameObject go)
- {
- if (this.bundleName == string.Empty)
- {
- return;
- }
- ResourceHelper.Instance.LoadAssetBundle(bundleName, ab =>
- {
- if (ab != null)
- {
- GameObject model = (GameObject)Instantiate(ab.LoadAsset(bundleName));
- Transform[] all = model.GetComponentsInChildren<Transform>();
- ///默认UI相机照射所有特效
- ///如果是bomb在敌人身上(3D)身上,则使用3D摄像机;
- foreach (Transform rc in all)
- {
- rc.gameObject.layer = LayerMask.NameToLayer("UI"); //指定Layer
- }
- if (mEffectPoint == null)
- {
- mEffectPoint = this.transform.Find("EffectPoint");
- }
- model.transform.SetParent(mEffectPoint);
- model.transform.position = Vector3.zero;
- model.transform.rotation = Quaternion.identity;
- model.transform.localScale = new Vector3(1, 1, 1);
- }
- }
- );
- }
- }
- }
|