//        private IEnumerator LoadAssetbundle()
//        {

//            int CurStageID = ObjectSelf.GetInstance().GetCurCampaignID();
//            CurStage = (StageTemplate)DataTemplate.GetInstance().m_StageTable.m_Data[CurStageID];
//            Monstersdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[0]) as MonsterGroupDataObj;
//            HeroPathdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[1]) as HeroPathDataObj;
//            Camdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[2]) as CameraDataObj;
//            StoryAnimdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[3]) as StoryAnimDataObj;
//            MonstersAssetbundle = new WWW("file:///" + AppManager.Inst.readAndWritePath + CurStage.m_stageevent[0] + ".enc");
//            HeroPathAssetbundle = new WWW("file:///" + AppManager.Inst.readAndWritePath + CurStage.m_stageevent[1] + ".enc");
//            CamAssetbundle = new WWW("file:///" + AppManager.Inst.readAndWritePath + CurStage.m_stageevent[2] + ".enc");
//            StoryAnimAssetbundle = new WWW("file:///" + AppManager.Inst.readAndWritePath + CurStage.m_stageevent[3] + ".enc");
//            yield return CamAssetbundle;
//            if (CamAssetbundle.error != null || HeroPathAssetbundle.error != null || MonstersAssetbundle.error != null || StoryAnimAssetbundle.error!=null)
//            {
//                Debug.Log(CamAssetbundle.error);
//                Debug.Log(HeroPathAssetbundle.error);
//                Debug.Log(MonstersAssetbundle.error);
//                Debug.Log(StoryAnimAssetbundle.error);
//            }
//            if (CamAssetbundle.isDone && HeroPathAssetbundle.isDone && MonstersAssetbundle.isDone&&StoryAnimAssetbundle.isDone)
//            {
////                LogManager.Log(CamAssetbundle);
//                //解密
//                byte[] decryptedData1 = AssetManager.Inst.ExecuteDecrypt(name, CamAssetbundle.bytes);
//                AssetBundleCreateRequest acr1 = AssetBundle.CreateFromMemory(decryptedData1);
//                yield return acr1;
//                AssetBundle Cambundle = acr1.assetBundle;

//                byte[] decryptedData2 = AssetManager.Inst.ExecuteDecrypt(name, HeroPathAssetbundle.bytes);
//                AssetBundleCreateRequest acr2 = AssetBundle.CreateFromMemory(decryptedData2);
//                yield return acr2;
//                AssetBundle HeroPathbundle = acr2.assetBundle;

//                byte[] decryptedData3 = AssetManager.Inst.ExecuteDecrypt(name, MonstersAssetbundle.bytes);
//                AssetBundleCreateRequest acr3 = AssetBundle.CreateFromMemory(decryptedData3);
//                yield return acr3;
//                AssetBundle MonsterGroupbundle = acr3.assetBundle;

//                byte[] decryptedData4 = AssetManager.Inst.ExecuteDecrypt(name, StoryAnimAssetbundle.bytes);
//                AssetBundleCreateRequest acr4 = AssetBundle.CreateFromMemory(decryptedData4);
//                yield return acr4;
//                AssetBundle StoryAnimbundle = acr4.assetBundle;

//                //转换资源
//                Camdata = Cambundle.mainAsset as CameraDataObj;
//               // HeroPathdata = HeroPathbundle.mainAsset as HeroPathDataObj;
//                Monstersdata = MonsterGroupbundle.mainAsset as MonsterGroupDataObj;
//                StoryAnimdata = StoryAnimbundle.mainAsset as StoryAnimDataObj;
//                LoadFightEditor();

//                Cambundle.Unload(false);
//                HeroPathbundle.Unload(false);
//                MonsterGroupbundle.Unload(false);
//                StoryAnimbundle.Unload(false);
//            }
//            else
//            {
//                LogManager.Log("加载失败");
//            }
//        }

        //加载场景编辑器数据
        private void LoadFightEditor()
        {
            //加载场景回调事件
            PathEvent = new GameObject("PathEvent");
            PathEvent.transform.parent = this.transform;
            PathEvent.AddComponent <PathEvent>();
            //加载场景路线
            HeroPath = new GameObject("HeroPathtContrler");
            HeroPath.transform.parent = this.transform;
            //XmlDocument xml = new XmlDocument();
            // XMLHelper.LoadXML(AppManager.Inst.readOnlyPath + "Data/HeroPathXml/" + CurStage.m_stageevent[1] + ".xml", ref xml);
            string str = File.ReadAllText(@AppManager.Inst.readOnlyPath + "Data/HeroPathXml/" + CurStage.m_stageevent[1] + ".xml", Encoding.UTF8);
            //XMLHelper.LoadXML(AppManager.Inst.readOnlyPath + "Data/HeroPathXml/" + CurStage.m_stageevent[1] + ".xml", ref xml);
            HeroFormationType type = ObjectSelf.GetInstance().Teams.GetFormation();;

            //HeroPath.AddComponent<HeroPathtContrler>().Init(HeroPathdata, type, xml);
            HeroPath.AddComponent <HeroPathtContrler>().Init(HeroPathdata, type, str);
            //加载过场动画组件
            StoryAnimContrler = new GameObject("StoryAnimEditorContrler");
            StoryAnimContrler.transform.parent = this.transform;
            StoryAnimEditorContrler storyControler = StoryAnimContrler.AddComponent <StoryAnimEditorContrler>();
            EM_SCENE_TYPE           sceneType      = ObjectSelf.GetInstance().IsLimitFight ? EM_SCENE_TYPE.JIXIANSHILIAN : EM_SCENE_TYPE.NORMAL;
            int beginRound = sceneType == EM_SCENE_TYPE.JIXIANSHILIAN ? ObjectSelf.GetInstance().LimitFightMgr.m_BeginRoundNum : 1;

            storyControler.Init(StoryAnimdata, false, Monstersdata, sceneType, beginRound);
            //加载摄像机组件
            Cameracontrler = new GameObject("CameraContrler");
            Cameracontrler.transform.parent = this.transform;
            Cameracontrler.AddComponent <CameraContrler>().Init(Camdata, StoryAnimdata);

            //创建一个跟踪HeroCenter的物体;
            HeroCenterObj = new GameObject("HeroCenterObj");
            HeroCenterObj.transform.SetParent(this.transform);

            //初始化人物灯光;
            InitSpotLight();

            //初始化人物阴影;
            InitHeroShadow();
        }
 private EM_SCENE_TYPE mSceneType = EM_SCENE_TYPE.NORMAL;            //怪物组基数;
 protected override void InitData()
 {
     Inst = this;
     //监听场景动画事件
     GameEventDispatcher.Inst.addEventListener(GameEventID.SE_StoryEnter, OnStoryStart);
     //监听开场动画事件
     GameEventDispatcher.Inst.addEventListener(GameEventID.SE_StoryCameraEnter, OnStoryStart);
     //监听创建怪物事件
     GameEventDispatcher.Inst.addEventListener(GameEventID.SE_PrepareEnemy, OnPrepareEnemy);
     //监听战斗开始事件
     GameEventDispatcher.Inst.addEventListener(GameEventID.SE_StopMonsterBirth, OnStopMonsterBirth);
     //监听战斗结束事件
     GameEventDispatcher.Inst.addEventListener(GameEventID.F_BattleRoundOver, OnRoundOver);
     //监听怪物死亡事件
     GameEventDispatcher.Inst.addEventListener(GameEventID.F_EnemyOnDie, OnEnemyOnDie);
     //初始化怪物编辑器数组
     MonsterObjList  = new List <GameObject>();
     Dic_GameobjList = new List <GameObject>();
     CurrentMomentMonsterdataList = new List <Monsterdata>();
     CurrentAllMonsterdataList    = new List <Monsterdata>();
     CurrentMonsterDieCount       = 0;
 }
 //############################################过场动画接口############################################
 public GameObject GetStoryCamAnimsObj()
 {
     return(StoryAnimEditorContrler.GetInst().GetStoryCamAnimsObj());
 }
 /// <summary>
 /// 设置初始当前战斗回合数;
 /// </summary>
 /// <param name="count"></param>
 public void SetBeginFightCount(int count)
 {
     StoryAnimEditorContrler.GetInst().SetBeginFightCount(count);
 }
 /// <summary>
 /// 开启出生怪物行为
 /// </summary>
 /// <param name="obj">怪物Obj</param>
 /// <param name="data">怪物数据</param>
 /// <param name="isLocal">是否本地加载</param>
 public void SetMonsterBirthState(GameObject obj, Monsterdata data, bool isLocal, int DynamicID = 0)
 {
     StoryAnimEditorContrler.GetInst().SetMonsterBirthState(obj, data, isLocal, DynamicID);
     StoryAnimEditorContrler.GetInst().GetMonsterObjList().Add(obj);
 }
 public List <Monsterdata> GetMonsterGroupEditorData(int i)
 {
     return(StoryAnimEditorContrler.GetInst().GetMonsterGroupEditorData(i));
 }
 /// <summary>
 /// 设置怪物阵型状态1-前2后3;2-前3后2;
 /// </summary>
 /// <param name="type"></param>
 public void SetMonsterTroopType(int type)
 {
     StoryAnimEditorContrler.GetInst().SetMonsterTroopType(1);
 }
 /// <summary>
 /// 当前波数怪物是否有支援怪物
 /// </summary>
 /// <returns></returns>
 public bool IsFightOver()
 {
     return(StoryAnimEditorContrler.GetInst().IsFightOver());
 }
 /// <summary>
 /// 获取当前波数是否有支援的怪物
 /// </summary>
 /// <returns></returns>
 public bool GetisSupport()
 {
     return(StoryAnimEditorContrler.GetInst().GetisSupport());
 }
 /// <summary>
 /// 获取当前战斗的总波数
 /// </summary>
 /// <returns></returns>
 public int GetMonsterGroupCount()
 {
     return(StoryAnimEditorContrler.GetInst().GetMonsterGroupCount());
 }
 protected override void DestroyData()
 {
     Inst = null;
     GameEventDispatcher.Inst.clearEvents();
 }