Esempio n. 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();
            }
        }
Esempio n. 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();
        }
Esempio n. 3
0
 public void Init(string filename)
 {
     if (!FileReaderProxy.Exists(filename))
     {
         return;
     }
     try
     {
         float w = 1, h = 1;
         using (MemoryStream fs = FileReaderProxy.ReadFileAsMemoryStream(filename))
         {
             using (BinaryReader br = new BinaryReader(fs))
             {
                 w = (float)br.ReadDouble();
                 h = (float)br.ReadDouble();
                 br.Close();
             }
         }
         Init(w, h);
     }
     catch (Exception e)
     {
         LogSystem.Error("{0}\n{1}", e.Message, e.StackTrace);
     }
 }
Esempio n. 4
0
        public static void AddWayPoint()
        {
            FileReaderProxy.MakeSureAllHandlerRegistered();

            GameObject newNpc = AddEmptyObject("WayPoint");

            newNpc.AddComponent <EditorIndicator_WayPoint>();
        }
Esempio n. 5
0
        public static void AddRevivePoint()
        {
            FileReaderProxy.MakeSureAllHandlerRegistered();

            GameObject newRevivePoint = AddEmptyObject("RevivePoint");

            newRevivePoint.AddComponent <EditorIndicator_RevivePoint>();
        }
Esempio n. 6
0
        public static void BeginEdit()
        {
            EditModeState = !EditModeState;
            Menu.SetChecked(EditModeMenuItem, EditModeState);

            FileReaderProxy.MakeSureAllHandlerRegistered();

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

            ShowNotifyOrLog(EditModeState ? "BeginEdit" : "EndEdit");
        }
Esempio n. 7
0
        /**
         * @brief 载入文件
         *
         * @param path
         *
         * @return
         */
        public bool Load(string path)
        {
            bool ret = false;

            if (path == "" || !FileReaderProxy.Exists(path))
            {
                return(ret);
            }

            Stream       ms = null;
            StreamReader sr = null;

            try
            {
                ms = FileReaderProxy.ReadFileAsMemoryStream(path);
                if (ms == null)
                {
                    LogSystem.Debug("DBC, Warning, Load file error or file is empty: {0}", path);
                    return(false);
                }

                m_FileName = path;
                ms.Seek(0, SeekOrigin.Begin);
                m_FileSize = ms.Length;
                if (m_FileSize <= 0 || m_FileSize >= int.MaxValue)
                {
                    return(ret);
                }

                System.Text.Encoding encoding = System.Text.Encoding.UTF8;
                sr = new StreamReader(ms, encoding);

                ret = LoadFromStream(sr);
                ret = true;
            }
            catch (Exception e)
            {
                string err = "Exception:" + e.Message + "\n" + e.StackTrace + "\n";
                System.Diagnostics.Debug.WriteLine(err);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
                if (ms != null)
                {
                    ms.Close();
                }
            }

            return(ret);
        }
Esempio n. 8
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.");
        }