コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: ReqDispatcher.cs プロジェクト: chunwaizung/DCMMO
 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);
     }
 }
コード例 #4
0
ファイル: DemoSvrAndClient.cs プロジェクト: chunwaizung/DCMMO
 void OnDestroy()
 {
     DCLog.Log("end main");
     mChannel.DisposeRes();
     mChannel.Close();
     mServer.DisposeRes();
     mServer.Close();
 }
コード例 #5
0
ファイル: ResourceSysTest.cs プロジェクト: chunwaizung/DCMMO
        void Start()
        {
            var asset1 = Resources.Load <TextAsset>("test");     //not null
            var asset2 = Resources.Load <TextAsset>("test.txt"); //null

            DCLog.Log("end");

//            Resources.Load<Texture2D>("");
        }
コード例 #6
0
        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");
        }
コード例 #7
0
 public static void RemoveNormal(DCBaseTimer timer)
 {
     if (null == Instance)
     {
         return;
     }
     DCLog.Log("add to remove");
     Instance.mToDelTimerSet.Add(timer);
 }
コード例 #8
0
ファイル: NPCSys.cs プロジェクト: chunwaizung/DCMMO
        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;
        }
コード例 #9
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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
            }
        }
コード例 #12
0
ファイル: PlayerDataMgr.cs プロジェクト: chunwaizung/DCMMO
        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);
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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();
            }
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: LoginUI.cs プロジェクト: chunwaizung/DCMMO
        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);
            }
        }
コード例 #18
0
ファイル: SelectRoleUI.cs プロジェクト: chunwaizung/DCMMO
        void OnLoginSvrComplete(int id, ProtoPacket proto)
        {
            DCLog.Log("to game world");

            Close();
        }
コード例 #19
0
ファイル: DemoSvrAndClient.cs プロジェクト: chunwaizung/DCMMO
 void OnReceive(Packet packet)
 {
     DCLog.LogEx("from server: ", Encoding.UTF8.GetString(packet.Bytes, 0, packet.Length));
 }