Exemplo n.º 1
0
        private void LoadAssetbundle()
        {
            int CurStageID = 0;

            if (ObjectSelf.GetInstance().GetIsPrompt())
            {
                CurStageID = ObjectSelf.GetInstance().GetPromptCurCampaignID();
            }
            else
            {
                CurStageID = ObjectSelf.GetInstance().GetCurCampaignID();
            }
            CurStage = (StageTemplate)DataTemplate.GetInstance().m_StageTable.getTableData(CurStageID);
            FightControler.isOpeningAnimation = CurStage.m_iskcdh != -1;

            if (CurStage.m_stageevent[0] != "-1")
            {
                Monstersdata = new MonsterGroupDataObjMgr(AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[0]) as MonsterGroupDataObj);
            }
            if (CurStage.m_stageevent[1] != "-1")
            {
                HeroPathdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[1]) as HeroPathDataObj;
                //测试用的;
                HeroPathdata.MoveDistance -= 4f;
            }
            if (CurStage.m_stageevent[2] != "-1")
            {
                Camdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[2]) as CameraDataObj;
            }
            if (CurStage.m_stageevent[3] != "-1")
            {
                StoryAnimdata = AssetLoader.Inst.GetEditorAssetRes(CurStage.m_stageevent[3]) as StoryAnimDataObj;
            }
            LoadFightEditor();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        //生成数据
        private void ExportData()
        {
            HeroPathDataObj HeroPathdata = ScriptableObject.CreateInstance <HeroPathDataObj>();

            //添加数据给HeroPathdata
            HeroPathdata.InitPos            = Heropathtcontrler.GetComponentInChildren <CameraPath>().GetPoint(0).worldPosition;
            HeroPathdata.Tension            = Heropathtcontrler.GetComponentInChildren <CameraPath>().hermiteTension;
            HeroPathdata.HeroPathWaitTime   = Heropathtcontrler.Waittime;
            HeroPathdata.LineUpFollowCamPos = GameObject.Find("LineUpFollowCam").transform.localPosition;
            HeroPathdata.FightFollowCamPos  = GameObject.Find("FightFollowCam").transform.localPosition;
            //  HeroPathdata.FightDefaultCamPos = GameObject.Find("FightDefaultCam").transform.localPosition;
            HeroPathdata.InitAngles   = GameObject.Find("FormationCenter").transform.rotation;
            HeroPathdata.MoveDistance = Heropathtcontrler.MoveDistance;
#if UNITY_ANDROID
            Debug.Log("这里是安卓设备^_^");
            string saveurl = "Assets/StreamingAssets/ScenceEditor/" + "Android/" + Heropathtcontrler.SceneName + "/Path/";
            if (Directory.Exists(saveurl) == false)
            {
                Directory.CreateDirectory(saveurl);
            }
            string name = saveurl + Heropathtcontrler.SceneName + "Path" + ".asset";
            AssetDatabase.CreateAsset(HeroPathdata, name);
            Object o = AssetDatabase.LoadAssetAtPath(name, typeof(HeroPathDataObj));
            BuildPipeline.BuildAssetBundle(o, null, saveurl + Heropathtcontrler.SceneName + "Path" + ".assetbundle",
                                           BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.Android);

            BuildPipeline.BuildAssetBundle(o, null, "Assets/StreamingAssets/AssetBundle/Android/" + Heropathtcontrler.SceneName + "Path" + ".assetbundle",
                                           BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.Android);
#endif

#if UNITY_IPHONE
            Debug.Log("这里是苹果设备>_<");
            string saveurl = "Assets/StreamingAssets/ScenceEditor/" + "IPhonePlayer/" + Heropathtcontrler.SceneName + "/Path/";
            if (Directory.Exists(saveurl) == false)
            {
                Directory.CreateDirectory(saveurl);
            }
            string name = saveurl + Heropathtcontrler.SceneName + "Path" + ".asset";
            AssetDatabase.CreateAsset(HeroPathdata, name);
            Object o = AssetDatabase.LoadAssetAtPath(name, typeof(HeroPathDataObj));
            BuildPipeline.BuildAssetBundle(o, null, saveurl + Heropathtcontrler.SceneName + "Path" + ".assetbundle",
                                           BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.iPhone);

            BuildPipeline.BuildAssetBundle(o, null, "Assets/StreamingAssets/AssetBundle/IOS/" + Heropathtcontrler.SceneName + "Path" + ".assetbundle",
                                           BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.iPhone);
#endif

#if UNITY_STANDALONE_WIN
            Debug.Log("我是从Windows的电脑上运行的T_T");
            string saveurl = "Assets/StreamingAssets/ScenceEditor/" + "WindowsEditor/" + Heropathtcontrler.SceneName + "/Path/";
            if (Directory.Exists(saveurl) == false)
            {
                Directory.CreateDirectory(saveurl);
            }
            string name = saveurl + Heropathtcontrler.SceneName + "Path" + ".asset";
            AssetDatabase.CreateAsset(HeroPathdata, name);
            Object o = AssetDatabase.LoadAssetAtPath(name, typeof(HeroPathDataObj));
            BuildPipeline.BuildAssetBundle(o, null, saveurl + Heropathtcontrler.SceneName + "Path" + ".assetbundle",
                                           BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.StandaloneWindows);

            BuildPipeline.BuildAssetBundle(o, null, "Assets/StreamingAssets/AssetBundle/PC/" + Heropathtcontrler.SceneName + "Path" + ".assetbundle",
                                           BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.StandaloneWindows);
#endif
            string SavePath = "Assets/CEHUAYONG/ScenesPreb/" + Heropathtcontrler.SceneName + "/";
            if (Directory.Exists(SavePath) == false)
            {
                Directory.CreateDirectory(SavePath);
            }
            PrefabUtility.CreatePrefab(SavePath + Heropathtcontrler.name + ".prefab", Heropathtcontrler.gameObject);
            AssetDatabase.Refresh();
            EditorUtility.DisplayDialog("", "保存完成", "OK");
            //删除面板上的临时对象
            //AssetDatabase.DeleteAsset(name);
        }