示例#1
0
        public static void ExportWayPoint()
        {
            FileReaderProxy.MakeSureAllHandlerRegistered();

            ReloadSceneConfig();

            string sceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;

            CurrentSceneConfig = FindSceneConfig(sceneName);
            if (CurrentSceneConfig == null)
            {
                UnityEngine.Debug.LogError("Missing scene config info. scene = " + sceneName);
                return;
            }

            int sceneId = CurrentSceneConfig.m_Id;

            List <GameObject> Objects = CollectAllWayPointsInCurrentScene();

            string path = EditorUtility.SaveFilePanel("Save", "", sceneId.ToString(), "wp");

            if (path != null)
            {
                StreamWriter wf = new StreamWriter(path, false, Encoding.UTF8);

                foreach (GameObject go in Objects)
                {
                    wf.Write(String.Format("{0}\t{1}\t{2}\r\n", go.transform.position.x, go.transform.position.y, go.transform.position.z));
                }

                wf.Close();
            }
        }
示例#2
0
        public static void Init(string logPath, string dataPath)
        {
            s_IsInited = true;
            s_LogicLogger.Init(logPath);
            HomePath.CurHomePath             = dataPath;
            GlobalVariables.Instance.IsDebug = false;

            FileReaderProxy.MakeSureAllHandlerRegistered();

            LogSystem.OnOutput = (Log_Type type, string msg) =>
            {
                s_LogicLogger.Log("{0}", msg);
            };

            // GfxSystem
            GfxSystem.Init();
            GfxSystem.SetLogicInvoker(s_LogicThread);
            GfxSystem.SetLogicLogCallback((bool isError, string format, object[] args) =>
            {
                if (isError)
                {
                    LogSystem.Error(format, args);
                }
                else
                {
                    LogSystem.Info(format, args);
                }
            });

            LogicSystem.LogFromGfx("GameControler.Init");

            GfxSystem.SetGameLogicNotification(GameLogicNotification.Instance);
            GfxModule.Skill.GfxSkillSystem.Instance.Init();
        }
示例#3
0
        public static void AddWayPoint()
        {
            FileReaderProxy.MakeSureAllHandlerRegistered();

            GameObject newNpc = AddEmptyObject("WayPoint");

            newNpc.AddComponent <EditorIndicator_WayPoint>();
        }
示例#4
0
        public static void AddRevivePoint()
        {
            FileReaderProxy.MakeSureAllHandlerRegistered();

            GameObject newRevivePoint = AddEmptyObject("RevivePoint");

            newRevivePoint.AddComponent <EditorIndicator_RevivePoint>();
        }
示例#5
0
        public static void BeginEdit()
        {
            EditModeState = !EditModeState;
            Menu.SetChecked(EditModeMenuItem, EditModeState);

            FileReaderProxy.MakeSureAllHandlerRegistered();

            // UnityEditor.SceneManagement.EditorSceneManager.sceneOpened += OnSceneOpenedCallback;

            ShowNotifyOrLog(EditModeState ? "BeginEdit" : "EndEdit");
        }
示例#6
0
        public static void ExportAllNPC()
        {
            FileReaderProxy.MakeSureAllHandlerRegistered();

            ReloadSceneConfig();

            string sceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;

            CurrentSceneConfig = FindSceneConfig(sceneName);
            if (CurrentSceneConfig == null)
            {
                UnityEngine.Debug.LogError("Missing scene config info. scene = " + sceneName);
                return;
            }

            string unitFilePath = Application.dataPath + "/StreamingAssets/" + CurrentSceneConfig.m_UnitFile;

            if (!File.Exists(unitFilePath))
            {
                UnityEngine.Debug.LogError("Missing unit file. file = " + unitFilePath);
                return;
            }

            List <GameObject> allNPCs = CollectAllNPCInCurrentScene();

            if (allNPCs == null || allNPCs.Count == 0)
            {
                return;
            }

            GameObject revivePoint = CollectRevivePointInCurrentScene();

            StringBuilder builder = new StringBuilder();

            // append revive point
            if (revivePoint != null)
            {
                UnityEngine.Vector3 pos = revivePoint.transform.position;
                float rot = revivePoint.transform.rotation.eulerAngles.y;
                builder.AppendFormat("{0}\t{1}\t{2}\t{3} {4} {5}\t\t{6}\t{7}\t\t{8}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n", 20001, 0, 3, pos.x, pos.y, pos.z, rot, "FALSE", 0);
            }

            int baseId = 1001;

            foreach (var npc in allNPCs)
            {
                // Id
                int id = baseId++;
                // LinkId
                int linkId = GetLinkIdByObject(npc);
                // CampId
                int campId = GetCampIdByObject(npc);
                // Position
                UnityEngine.Vector3 pos = npc.transform.position;
                // RotAngle
                float rot = npc.transform.rotation.eulerAngles.y;
                // idle animation set
                string idleAnimSet = GetIdleAnimSetByObject(npc);
                // AI logic
                int aiLogic = GetAILogicByObject(npc);

                builder.AppendFormat("{0}\t{1}\t{2}\t{3} {4} {5}\t\t{6}\t{7}\t{8}\t{9}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n", id, linkId, campId, pos.x, pos.y, pos.z, rot, "FALSE", idleAnimSet, aiLogic);
            }

            StreamReader rf = new StreamReader(unitFilePath);

            if (rf == null)
            {
                UnityEngine.Debug.LogError("unit file not found.");
                return;
            }

            // header
            string finalUnitFile = rf.ReadLine();

            finalUnitFile += "\n";

            if (revivePoint == null)
            {
                // initial vive point
                finalUnitFile += rf.ReadLine();
                // revive point
                finalUnitFile += rf.ReadLine();
            }

            rf.Close();

            StreamWriter wf = new StreamWriter(unitFilePath, false, Encoding.UTF8);

            wf.Write(finalUnitFile);
            wf.Write(builder.ToString());
            wf.Close();

            UnityEngine.Debug.Log("NPC table flushed success.");
        }