public static void InitGame(string logPath, string dataPath) { s_IsInited = true; s_LogicLogger.Init(logPath); HomePath.CurHomePath = dataPath; GlobalVariables.Instance.IsClient = true; GlobalVariables.Instance.IsDebug = false; FileReaderProxy.RegisterReadFileHandler((string filePath) => { byte[] buffer = null; try { using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { buffer = new byte[fs.Length]; fs.Read(buffer, 0, (int)fs.Length); fs.Close(); } } catch (Exception e) { GfxSystem.GfxLog("Exception:{0}\n{1}", e.Message, e.StackTrace); return(null); } return(buffer); }); LogSystem.OnOutput = (Log_Type type, string msg) => { GfxSystem.GfxLog("{0}", msg); s_LogicLogger.Log("{0}", msg); }; GfxSystem.GfxLog("GameControler.InitGame"); _InitSystems(); }
public static void ReleaseGame() { GfxSystem.GfxLog("GameControler.ReleaseGame"); WorldSystem.Instance.Release(); EntityManager.Instance.Release(); NetworkSystem.Instance.Release(); GfxSystem.Release(); s_LogicLogger.Dispose(); }
private void FlushToFile(Queue <string> logQueue) { lock (m_LogQueueLock) { GfxSystem.GfxLog("LogicLogger.FlushToFile, count {0}.", logQueue.Count); while (logQueue.Count > 0) { string msg = logQueue.Dequeue(); m_LogStream.WriteLine(msg); } } }
public void Tick() { #if !USE_DISK_LOG long curTime = TimeUtility.GetLocalMilliseconds(); if (m_LastFlushTime + 10000 < curTime) { m_LastFlushTime = curTime; RequestFlush(); GfxSystem.GfxLog("LogicLogger.Tick."); } #endif }
public void Init(int resId) { m_SceneResId = resId; LoadSceneData(resId); WorldSystem.Instance.SceneContext.SceneResId = resId; m_IsWaitSceneLoad = true; Data_Unit unit = m_SceneStaticData.ExtractData(DataMap_Type.DT_Unit, GlobalVariables.GetUnitIdByCampId(NetworkSystem.Instance.CampId)) as Data_Unit; if (null != unit) { m_CameraLookAtHeight = unit.m_Pos.Y; } GfxSystem.GfxLog("SceneResource.Init {0}", resId); }
private bool LoadSceneData(int sceneResId) { bool result = true; m_SceneResId = sceneResId; // 加载场景配置数据 m_SceneConfig = SceneConfigProvider.Instance.GetSceneConfigById(m_SceneResId); if (null == m_SceneConfig) { GfxSystem.GfxLog("LoadSceneData {0} failed!", sceneResId); } // 加载本场景xml数据 m_SceneStaticData = SceneConfigProvider.Instance.GetMapDataBySceneResId(m_SceneResId); GfxSystem.LoadScene(m_SceneConfig.m_ClientSceneFile, OnLoadFinish); return(result); }
private void OnLoadFinish() { if (WorldSystem.Instance.IsObserver) { UserInfo myself = WorldSystem.Instance.CreatePlayerSelf(0x0ffffffe, 1); if (null != myself)//观战客户端创建一个虚拟玩家(不关联view,血量不要为0,主要目的是为了适应客户端代码里对主角的判断) { myself.SetLevel(16); myself.SetHp(Operate_Type.OT_Absolute, 999999); } NotifyUserEnter(); } if (WorldSystem.Instance.IsObserver) { DashFireMessage.Msg_CR_Observer build = new DashFireMessage.Msg_CR_Observer(); NetworkSystem.Instance.SendMessage(build); LogSystem.Debug("send Msg_CR_Observer to roomserver"); } else if (WorldSystem.Instance.IsPveScene()) { //单机游戏逻辑启动 WorldSystem.Instance.StartGame(); NotifyUserEnter(); } else { DashFireMessage.Msg_CRC_Create build = new DashFireMessage.Msg_CRC_Create(); NetworkSystem.Instance.SendMessage(build); LogSystem.Debug("send Msg_CRC_Create to roomserver"); } GfxSystem.GfxLog("SceneResource.OnLoadFinish"); m_IsWaitSceneLoad = false; GfxSystem.PublishGfxEvent("ge_loading_finish", "ui"); }
protected override void OnTick() { //这里是在逻辑线程执行的tick,渲染线程的在GameControler.cs:TickGame里。 try { TimeUtility.SampleClientTick(); long curTime = TimeUtility.GetLocalMilliseconds(); if (m_LastLogTime + 10000 < curTime) { m_LastLogTime = curTime; GfxSystem.GfxLog("LogicThread.Tick actionNum {0}", this.CurActionNum); } NetworkSystem.Instance.Tick(); LobbyNetworkSystem.Instance.Tick(); PlayerControl.Instance.Tick(); WorldSystem.Instance.Tick(); GameControler.LogicLoggerInstance.Tick(); } catch (Exception ex) { GfxSystem.GfxLog("GameLogicThread.Tick throw Exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
/** * @brief 逻辑循环 */ public void Tick() { TimeSnapshot.Start(); TimeSnapshot.DoCheckPoint(); if (m_CurScene == null || !m_CurScene.IsSuccessEnter) { return; } m_Profiler.sceneTickTime = TimeSnapshot.DoCheckPoint(); EntityManager.Instance.Tick(); m_Profiler.entityMgrTickTime = TimeSnapshot.DoCheckPoint(); ControlSystem.Instance.Tick(); m_Profiler.controlSystemTickTime = TimeSnapshot.DoCheckPoint(); m_Profiler.movementSystemTickTime = TimeSnapshot.DoCheckPoint(); m_SpatialSystem.Tick(); m_Profiler.spatialSystemTickTime = TimeSnapshot.DoCheckPoint(); if (m_Profiler.spatialSystemTickTime > 50000) { LogSystem.Warn("*** SpatialSystem tick time is {0}", m_Profiler.spatialSystemTickTime); for (LinkedListNode <UserInfo> node = UserManager.Users.FirstValue; null != node; node = node.Next) { UserInfo userInfo = node.Value; if (null != userInfo) { LogSystem.Warn("===>User:{0} Pos:{1}", userInfo.GetId(), userInfo.GetMovementStateInfo().GetPosition3D().ToString()); } } for (LinkedListNode <NpcInfo> node = NpcManager.Npcs.FirstValue; null != node; node = node.Next) { NpcInfo npcInfo = node.Value; if (null != npcInfo) { LogSystem.Warn("===>Npc:{0} Pos:{1}", npcInfo.GetId(), npcInfo.GetMovementStateInfo().GetPosition3D().ToString()); } } } m_AiSystem.Tick(); m_Profiler.aiSystemTickTime = TimeSnapshot.DoCheckPoint(); //obj特殊逻辑处理 TickUsers(); m_Profiler.usersTickTime = TimeSnapshot.DoCheckPoint(); TickNpcs(); m_Profiler.npcsTickTime = TimeSnapshot.DoCheckPoint(); try { TickSystemByCharacters(); } catch (Exception e) { GfxSystem.GfxLog("Exception:{0}\n{1}", e.Message, e.StackTrace); } m_Profiler.combatSystemTickTime = TimeSnapshot.DoCheckPoint(); if (IsPveScene()) { TickPve(); } long tickTime = TimeSnapshot.End(); if (tickTime > 100000) { LogSystem.Debug("*** PerformanceWarning: {0}", m_Profiler.GenerateLogString(tickTime)); } }
public void NotifyUserEnter() { m_IsSuccessEnter = true; GfxSystem.GfxLog("SceneResource.NotifyUserEnter"); }
public void Release() { GfxSystem.GfxLog("SceneResource.Release"); }
public static void StopGame() { GfxSystem.GfxLog("GameControler.StopGame"); s_LogicThread.Stop(); }