/// <summary> /// 加载 /// </summary> public void Load() { Player player = UnitManager.Instance.GetUnitByIdx(m_char_idx) as Player; if (player == null) { return; } //查询和自己相关的事件 SQLDBEventHandle.QueryDBEvent(m_char_idx, player.db_id, OnLoadedEvent); m_last_load_time = Time.timeSinceStartup; }
public void Start() { DataManager.Instance.LoadAll(); DBManager.Instance.Start(ServerConfig.db_info.db_list); ServerNetManager.Instance.Connect2WorldServer(ServerConfig.net_info.ws_ip, ServerConfig.net_info.ws_port); DBID db_id = new DBID(); db_id.game_id = 100; DBEventInfo e_info = new DBEventInfo(); e_info.target_char_idx = 10000000002; e_info.source_char_idx = 10000000003; e_info.event_type = eDBEventType.Test; e_info.bin_content.bin_normal_content.data = "测试了"; SQLDBEventHandle.InsertDBEvent(e_info, db_id); Framework.Instance.MainLoop(); }
private void OnLoadedEvent(List <DBEventInfo> list) { if (list.Count == 0 || m_char_idx == 0) { return; } Player player = UnitManager.Instance.GetUnitByIdx(m_char_idx) as Player; if (player == null) { return; } for (int i = list.Count - 1; i >= 0; --i) { if (m_events.ContainsKey(list[i].event_idx)) { list.RemoveAt(i); } } if (list.Count == 0) { return; } //执行所有事件 List <long> list_dels = new List <long>(); foreach (var obj in list) { player.HandleDBEvent(obj); list_dels.Add(obj.event_idx); } //目前的做法是直接删除,后期可以根据HandleDBEvent的返回值确定是否删除 if (list_dels.Count > 0) { SQLDBEventHandle.DeleteDBEvent(list_dels, player.db_id); } }