Пример #1
0
        /// <summary>
        /// 动态初始化
        /// </summary>
        /// <param name="data">英雄阵型序列化数据</param>
        /// <param name="XmlName">Xml地址</param>
        /// <param name="type">英雄阵型</param>
        /// <param name="speed">初始移动速度</param>
        public void Init(HeroPathDataObj data, HeroFormationType type, string PathXml)
        {
            //添加轨迹组件 动画组件 读取轨迹数据
            HeroPathdata = data;
            HeroPath     = this.gameObject.AddComponent <CameraPath>();
            HeroPathAnim = this.gameObject.AddComponent <CameraPathAnimator>();
            HeroPath.FromXML(PathXml);
            HeroPath.hermiteTension = data.Tension;
            //初始话战斗中心点和英雄中心点
            FightCenter = new GameObject("FightCenter");
            FightCenter.transform.parent   = this.transform;
            FightCenter.transform.position = data.InitPos;
            HerosCenter = new GameObject("HerosCenter");
            HerosCenter.transform.parent   = this.transform;
            HerosCenter.transform.position = data.InitPos;
            //初始化战斗摄像机 整队摄像机
            FightFollowCam = new GameObject("FightFollowCam");
            FightFollowCam.transform.parent        = FightCenter.transform;
            FightFollowCam.transform.localPosition = data.FightFollowCamPos;
            FightDefaultCam = new GameObject("FightDefaultCam");
            FightDefaultCam.transform.SetParent(FightCenter.transform);
            FightDefaultCam.transform.localPosition = data.FightDefaultCamPos;
            LineUpFollowCam = new GameObject("LineUpFollowCam");
            LineUpFollowCam.transform.parent        = HerosCenter.transform;
            LineUpFollowCam.transform.localPosition = data.LineUpFollowCamPos;
            //初始化队伍阵型
            GameObject objType = AssetLoader.Inst.GetAssetRes(type.ToString());

            FormationCenterObj = Instantiate(objType, data.InitPos, data.InitAngles) as GameObject;
            HeroFormationtype  = type;
            // FormationCenterObj.transform.parent = this.transform;
            FormationList = new List <GameObject>();
            for (int i = 0; i < FormationCenterObj.transform.childCount; i++)
            {
                FormationList.Add(FormationCenterObj.transform.GetChild(i).gameObject);
                //Debug.Log(FormationCenterObj.transform.GetChild(i).position);
            }
            FormationDic = new Dictionary <ObjectCreature, GameObject>();
            //初始化轨迹组件信息
            HeroPathAnim.animationObject = FormationCenterObj.transform;
            HeroPathAnim.pathSpeed       = 0;
            Heropathtype = HeroPathMoveType.Null;
            HeroPathPause();
            SetHeroPathIdle();
        }
Пример #2
0
 //本地初始化
 private void init()
 {
     HeroPathAnim = this.transform.FindChild("HerosPath").GetComponent <CameraPathAnimator>();
     HeroPath     = this.transform.FindChild("HerosPath").GetComponent <CameraPath>();
     //HeroPath.FromXML("Assets/CameraPath3/HerosPath.xml");
     FightCenter        = this.transform.FindChild("FightCenter").gameObject;
     HerosCenter        = this.transform.FindChild("HerosCenter").gameObject;
     FormationCenterObj = this.transform.FindChild("FormationCenter").gameObject;
     FormationList      = new List <GameObject>();
     for (int i = 0; i < FormationCenterObj.transform.childCount; i++)
     {
         FormationList.Add(FormationCenterObj.transform.GetChild(i).gameObject);
     }
     Heropathtype                 = HeroPathMoveType.Null;
     HeroFormationtype            = HeroFormationType.Formation133;
     HeroPathAnim.animationObject = FormationCenterObj.transform;
     HeroPathAnim.pathSpeed       = MoveSpeed = this.GetComponent <HeroPathData>().MoveSpeed;
     HeroPathPause();
 }
Пример #3
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();
        }