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); }
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 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); } }
void OnDestroy() { DCLog.Log("end main"); mChannel.DisposeRes(); mChannel.Close(); mServer.DisposeRes(); mServer.Close(); }
void Start() { var asset1 = Resources.Load <TextAsset>("test"); //not null var asset2 = Resources.Load <TextAsset>("test.txt"); //null DCLog.Log("end"); // Resources.Load<Texture2D>(""); }
public static void Test() { var asset1 = AssetDatabase.LoadAssetAtPath <TextAsset>("Assets/DCMMO/Resources/test"); //null var asset2 = AssetDatabase.LoadAssetAtPath <TextAsset>("Assets/DCMMO/Resources/test.txt"); //not null //asset bundle need extension DCLog.Log("end"); }
public static void RemoveNormal(DCBaseTimer timer) { if (null == Instance) { return; } DCLog.Log("add to remove"); Instance.mToDelTimerSet.Add(timer); }
public void ReleaseId(int id) { var index = id - base_index; if (index < 0 || index >= mIdPool.Length) { DCLog.Log("out range id: " + id); return; } mIdPool[index] = 0; }
public void AddSys(BaseSys sys) { if (mTypeToSys.ContainsKey(sys.GetType())) { DCLog.Err("duplicated sys: " + sys); return; } mTypeToSys.Add(sys.GetType(), sys); mSysList.Add(sys); }
void OnAddRoleRes(int id, ProtoPacket proto) { //yeah , let's go to the game world DCLog.Log("yeah , let's go to the game world!"); Close(); MsgSys.Send(PlayerEvt.close_select_role_ui); var sceneId = ParamsCfgMgr.Instance.GetInt((int)PParamsConfig.BeginnerScene); LoadScene(sceneId); }
void LoadScene(int sceneId) { var mapCfg = MapCfgMgr.Instance.GetMapConfigByID(sceneId); if (null != mapCfg) { SceneManager.LoadScene(System.IO.Path.GetFileNameWithoutExtension(mapCfg.AssetPath)); } else { DCLog.Err("can not load level with id : {0}", sceneId); } }
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); } }
public void Destroy() { DCLog.Log("Destroy 1"); if (mDestroyed) { return; } mDestroyed = true; DCLog.Log("Destroy 2"); if (mPhysic) { DCTimer.RemovePhysic(this); } else { DCTimer.RemoveNormal(this); } }
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(); } }
public Dictionary <string, string> BuildAssetExtensionMap(string root) { var allFile = Directory.GetFiles(root, "*.*", SearchOption.AllDirectories).Where((item) => !item.EndsWith("meta")).ToList(); DCLog.Log(allFile.Count.ToString()); var dic = new Dictionary <string, string>(); foreach (var aFile in allFile) { var unixFilePath = aFile.Replace('\\', '/'); var assetPath = unixFilePath.Replace(Application.dataPath, "Assets"); var point = assetPath.LastIndexOf('.'); var pathWithOutExt = assetPath.Substring(0, point); var ext = assetPath.Substring(point); dic.Add(pathWithOutExt, ext); } return(dic); }
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 OnLoginSvrComplete(int id, ProtoPacket proto) { DCLog.Log("to game world"); Close(); }
void OnReceive(Packet packet) { DCLog.LogEx("from server: ", Encoding.UTF8.GetString(packet.Bytes, 0, packet.Length)); }