void FixedUpdate() { //delete first if (mToDelPhysicTimerSet.Count > 0) { mPhysicTimerSet.RemoveWhere(MatchForFixedUpdate); mToDelPhysicTimerSet.Clear(); } if (mPhysicTimerSet.Count > 0) { mPhysicTimersToInvoke.AddRange(mPhysicTimerSet); DCLog.LogEx("physic timer count ", mPhysicTimersToInvoke.Count); foreach (var timer in mPhysicTimersToInvoke) { timer.Update(); } mPhysicTimersToInvoke.Clear(); } //avoid执行中添加新action mNextFixedUpdateToInvokes.AddRange(mNextFixedUpdate); mNextFixedUpdate.Clear(); foreach (var action in mNextFixedUpdateToInvokes) { if (action != null) { action(); } } mNextFixedUpdateToInvokes.Clear(); }
public BaseUI ShowUi(string uiName, params object[] param) { var baseUi = mKeyToUi.GetValEx(uiName); if (null != baseUi) { baseUi.OnShow(); return(baseUi); } var assetPath = GetAssetPath(uiName); var prefab = ResourceSys.Instance.Load <GameObject>(assetPath); if (prefab == null) { DCLog.LogEx("null asset ", assetPath, uiName); return(null); } var instance = UnityEngine.Object.Instantiate(prefab, UiRoot); baseUi = instance.GetComponent <BaseUI>(); baseUi.Init(param); mKeyToUi.Add(uiName, baseUi); mUiStack.Push(baseUi); return(baseUi); }
public void Dispatch(ClientHandler clientHandler, int id, ProtoPacket packet) { DCLog.LogEx("handle req ", id); if (mIdToDelegates.TryGetValue(id, out var handler)) { handler.DynamicInvoke(clientHandler, id, packet); } }
private void OnRoleRes(int id, ProtoPacket protoPkt) { if (DCGameProtocol.CheckError(id, protoPkt) != ErrorCode.UNIVERSAL) { var errorRes = protoPkt.GetError(); DCLog.LogEx(errorRes.No, errorRes.OpCode, errorRes.Msg); return; } var roleRes = (PRoleRes)protoPkt.ProtoObj; mRoleList.Clear(); mRoleList.AddRange(roleRes.Infos); }
public void OnReceive(Packet packet) { var protoPacket = ProtoPacket.FromRecvBuf(packet.Bytes, 0, packet.Length); var id = protoPacket.protoId; DCLog.LogEx("receive protoId ", id); if (id > 0) { mIdToRecord.Remove(id); //长期监听的先执行 Invoke(id, protoPacket, mIdToNormalHandler); Invoke(id, protoPacket, mIdToOnceHandler); mIdToOnceHandler.Remove(id); } }
void Update() { //update 类型的timer //delete first if (mToDelTimerSet.Count > 0) { mTimerSet.RemoveWhere(MatchForUpdate); mToDelTimerSet.Clear(); } if (mTimerSet.Count > 0) { mTimersToInvoke.AddRange(mTimerSet); DCLog.LogEx("timer count ", mTimersToInvoke.Count); foreach (var timer in mTimersToInvoke) { timer.Update(); } mTimersToInvoke.Clear(); } //延时执行部分 foreach (var actionRecord in mActionRecords) { actionRecord.Update(); if (actionRecord.IsComplete()) { mActionRecordsToDel.Add(actionRecord); } } //防止action update的时候有往集合里面增加的操作 if (mActionRecordsToDel.Count > 0) { mActionRecords.RemoveWhere(MatchDelRecord); foreach (var record in mActionRecordsToDel) { record.Notify(); } mActionRecordsToDel.Clear(); } }
void OnLoginComplete(int code, string result) { if (code == 1) { var jsonNode = JSON.Parse(result); int svrCode = jsonNode["result"]; if (svrCode == 1) { var token = jsonNode["token"]; DCLog.Log(token); PlayerDataMgr.Instance.UserToken = token; //to login game svr var svrCfg = GameServerDataMgr.Instance.GetLastLoginSvr(); RequestRoleData(svrCfg); } } else if (code == 2) { DCLog.LogEx("net or http error ", result); } }
void OnReceive(Packet packet) { DCLog.LogEx("from server: ", Encoding.UTF8.GetString(packet.Bytes, 0, packet.Length)); }