public bool LoadFromBinary(string file) { long t1 = TimeUtility.GetElapsedTimeUs(); bool result = true; BinaryTable table = new BinaryTable(); table.Load(HomePath.GetAbsolutePath(file)); long t2 = TimeUtility.GetElapsedTimeUs(); long t3 = TimeUtility.GetElapsedTimeUs(); for (int index = 0; index < table.Records.Count; ++index) { try { TData data = new TData(); bool ret = data.ReadFromBinary(table, index); string info = string.Format("DataTableMgr.CollectDataFromBinary collectData Row:{0} failed!", index); LogSystem.Assert(ret, info); if (ret) { m_DataContainer.Add(data); } else { result = false; } } catch (System.Exception ex) { LogSystem.Error("CollectData failed. file:{0} rowIndex:{1}\nException:{2}\n{3}", file, index, ex.Message, ex.StackTrace); } } long t4 = TimeUtility.GetElapsedTimeUs(); LogSystem.Info("binary load {0} parse {1}, file {2}", t2 - t1, t4 - t3, file); return(result); }
public void Tick() { if (0 == m_LastTickTime) { m_LastTickTime = TimeUtility.GetLocalMilliseconds(); LogSystem.Info("MovementSystem LastTickTime:{0}", m_LastTickTime); } else { long delta = TimeUtility.GetLocalMilliseconds() - m_LastTickTime; m_LastTickTime = TimeUtility.GetLocalMilliseconds(); if (delta > 1000) { delta = 1000; } if (null != m_EntityMgr) { for (LinkedListNode <EntityInfo> node = m_EntityMgr.Entities.FirstNode; null != node; node = node.Next) { EntityInfo npc = node.Value; if (null != npc) { MoveNpc(npc, delta); } } } } }
public void Publish(string ev_name, string group, params object[] parameters) { try { LogSystem.Info("Publish {0} {1}", ev_name, group); Delegate d; string key = group + '#' + ev_name; if (subscribers_.TryGetValue(key, out d)) { if (null == d) { LogSystem.Error("Publish {0} {1}, Subscriber is null, Remove it", ev_name, group); subscribers_.Remove(key); } else { d.DynamicInvoke(parameters); } } } catch (Exception ex) { if (null != ex.InnerException) { ex = ex.InnerException; } LogSystem.Error("PublishSubscribe.Publish({0},{1}) exception:{2}\n{3}", ev_name, group, ex.Message, ex.StackTrace); } }
private void OnAiSkill(EntityInfo npc, int skillId) { Scene scene = npc.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || !skillInfo.IsSkillActivated) { SkillInfo curSkillInfo = npc.GetSkillStateInfo().GetSkillInfoById(skillId); if (null != curSkillInfo) { long curTime = TimeUtility.GetLocalMilliseconds(); if (!curSkillInfo.IsInCd(curTime)) { if (scene.SkillSystem.StartSkill(npc.GetId(), curSkillInfo.ConfigData, 0)) { Msg_RC_NpcSkill skillBuilder = DataSyncUtility.BuildNpcSkillMessage(npc, skillId); LogSystem.Info("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}", npc.GetId(), skillId); scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcSkill, skillBuilder); } } } } } }
public static void LogCallStack(bool useErrorLog) { if (useErrorLog) { LogSystem.Error("LogCallStack:\n{0}\n", Environment.StackTrace); } else { LogSystem.Info("LogCallStack:\n{0}\n", Environment.StackTrace); } }
public void StartStory(string storyId, string _namespace, params string[] overloadFiles) { StoryInstance inst = NewStoryInstance(storyId, _namespace, true, overloadFiles); if (null != inst) { m_StoryLogicInfos.Add(inst); inst.Context = m_UserThread; inst.GlobalVariables = m_GlobalVariables; inst.Start(); LogSystem.Info("StartStory {0}", storyId); } }
private static void SendMessageImpl(string objname, string msg, object arg, bool needReceiver) { GameObject obj = GameObject.Find(objname); if (null != obj) { try { obj.SendMessage(msg, arg, needReceiver ? SendMessageOptions.RequireReceiver : SendMessageOptions.DontRequireReceiver); if (msg.CompareTo("LogToConsole") != 0) { LogSystem.Info("SendMessage {0} {1} {2} {3}", objname, msg, arg, needReceiver); } } catch (Exception ex) { LogSystem.Error("SendMessage({0} {1} {2} {3}) Exception {4}\n{5}", objname, msg, arg, needReceiver, ex.Message, ex.StackTrace); } } }
private static void SendMessageWithTagImpl(string objtag, string msg, object arg, bool needReceiver) { GameObject[] objs = GameObject.FindGameObjectsWithTag(objtag); if (null != objs) { for (int i = 0; i < objs.Length; i++) { try { objs[i].SendMessage(msg, arg, needReceiver ? SendMessageOptions.RequireReceiver : SendMessageOptions.DontRequireReceiver); if (msg.CompareTo("LogToConsole") != 0) { LogSystem.Info("SendMessageWithTag {0} {1} {2} {3}", objtag, msg, arg, needReceiver); } } catch (Exception ex) { LogSystem.Error("SendMessageWithTag({0} {1} {2} {3}) Exception {4}\n{5}", objtag, msg, arg, needReceiver, ex.Message, ex.StackTrace); } } } }
private void OnAiStopSkill(EntityInfo npc) { Scene scene = npc.SceneContext.CustomData as Scene; if (null != scene) { SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo(); if (null == skillInfo || skillInfo.IsSkillActivated) { scene.SkillSystem.StopAllSkill(npc.GetId(), true); } Msg_RC_NpcStopSkill skillBuilder = DataSyncUtility.BuildNpcStopSkillMessage(npc); LogSystem.Info("Send Msg_RC_NpcStopSkill, EntityId={0}", npc.GetId()); scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcStopSkill, skillBuilder); } }
public void StartStories(string storyId, string _namespace) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } foreach (var pair in m_StoryInstancePool) { var info = pair.Value; if (IsMatch(info.StoryId, storyId)) { StopStory(info.StoryId); m_StoryLogicInfos.Add(info); info.Context = m_UserThread; info.GlobalVariables = m_GlobalVariables; info.Start(); LogSystem.Info("StartStory {0}", info.StoryId); } } }
public void StartStories(string storyId, string _namespace) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } int ct = m_StoryLogicInfos.Count; for (int i = ct - 1; i >= 0; --i) { var info = m_StoryLogicInfos[i]; if (IsMatch(info.StoryId, storyId)) { info.Context = null; info.GlobalVariables = m_GlobalVariables; info.Start(); LogSystem.Info("StartStory {0}", info.StoryId); } } }
public void StartStory(string storyId, string _namespace, params string[] overloadFiles) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } StoryInstance inst = GetStoryInstance(storyId); if (null != inst) { m_StoryLogicInfos.Add(inst); inst.Context = m_UserThread; inst.GlobalVariables = m_GlobalVariables; inst.Start(); LogSystem.Info("StartStory {0}", storyId); } else { LogSystem.Error("Can't find story, story:{0} !", storyId); } }
public void StartStory(string storyId, string _namespace) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } StoryInstance inst = GetStoryInstance(storyId); if (null != inst) { StopStory(storyId); m_StoryLogicInfos.Add(inst); inst.Context = m_Scene; inst.GlobalVariables = m_GlobalVariables; inst.Start(); LogSystem.Info("StartStory {0}", storyId); } else { LogSystem.Error("Can't find story, story:{0} scene:{1} !", storyId, m_Scene.SceneResId); } }