コード例 #1
0
 /// <summary>
 /// 初始化关卡动画数据
 /// 是否
 /// </summary>
 /// <param name="Storydata">关卡动画数据组</param>
 public void Init(StoryAnimDataObj Storydata, bool isLocal, MonsterGroupDataObjMgr monsterdata = null, EM_SCENE_TYPE sceneType = EM_SCENE_TYPE.NORMAL, int beginFightCount = 1)
 {
     IsLocal          = isLocal;
     Monstersdata     = monsterdata;
     mSceneType       = sceneType;
     mBeginFightCount = beginFightCount;
     if (Monstersdata != null)
     {
         CurrentMonsterGroupCount = monsterdata.Count;
     }
     if (Storydata == null)
     {
         return;
     }
     if (isLocal)
     {
         StoryCamAnimsObj = GameObject.Find(Storydata.StoryCamAnimsName);
         StoryCamAnim     = StoryCamAnimsObj.GetComponent <Animation>();
     }
     else
     {
         Object objType = AssetLoader.Inst.GetEditorAssetRes(Storydata.StoryCamAnimsName);
         StoryCamAnimsObj = Instantiate(objType) as GameObject;
         StoryCamAnimsObj.transform.parent = this.transform;
         StoryCamAnim = StoryCamAnimsObj.GetComponent <Animation>();
     }
     Dic_StoryAnim = new Dictionary <int, StoryAnimGroup>();
     for (int i = 0; i < Storydata.StoryAnimGroupList.Count; ++i)
     {
         Dic_StoryAnim.Add(Storydata.StoryAnimGroupList[i].ID, Storydata.StoryAnimGroupList[i]);
     }
 }
コード例 #2
0
//        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();
        }