private void GetSkill(TmParameter parameter)
        {
            bool yes   = false;
            int  count = 0;

            while (!yes)
            {
                if (Skills.Count > 0)
                {
                    TmParameter response = TmParameterTool.ToJsonParameter <Dictionary <int, TmSkill> >(TenCode.Buff, ElevenCode.Get, ElevenCode.Get.ToString(), Skills);
                    response.Keys.Add(parameter.Keys[0]);
                    TmTcpSocket.Instance.Send(response);
                    yes = true;
                }
                else
                {
                    TmMysqlHandler.Instance.GetComponent <TmBuffMysql>().OnTransferParameter(this, parameter);
                    Console.WriteLine(TmTimerTool.CurrentTime() + " this.Skills:" + this.Skills.Count);
                    count += 1;
                }
                if (count > 4)
                {
                    yes = true;
                    break;
                }
            }
        }
        private void GetSkillsByRolerId(TmParameter parameter)
        {
            int rolerid = TmParameterTool.GetJsonValue <int>(parameter, ElevenCode.EngineerLogin.ToString());
            Dictionary <int, TmSkillDB> skillDBs;
            bool yes   = false;
            int  count = 0;

            while (!yes)
            {
                yes = Buffs.TryGetValue(rolerid, out skillDBs);
                if (yes)
                {
                    TmParameter response = TmParameterTool.ToJsonParameter <Dictionary <int, TmSkillDB> >(TenCode.Buff, ElevenCode.GetSkills, ElevenCode.GetSkills.ToString(), skillDBs);
                    TmParameterTool.AddJsonParameter(response, "RolerId", rolerid);
                    response.Keys.Add(parameter.Keys[0]);
                    TmTcpSocket.Instance.Send(response);
                    yes = true;
                    break;
                }
                else
                {
                    TmMysqlHandler.Instance.GetComponent <TmBuffMysql>().OnTransferParameter(this, parameter);
                    Console.WriteLine(TmTimerTool.CurrentTime() + " this.Buffs:" + this.Buffs.Count);
                    count += 1;
                }
                if (count > 4)
                {
                    yes = true;
                    break;
                }
            }
        }
        private void GetRolersByUersId(TmParameter parameter)
        {
            List <TmSoulerDB> Engineers = null;
            int  userId = TmParameterTool.GetValue <int>(parameter, ElevenCode.UserLogin.ToString());
            bool yes    = false;
            int  count  = 0;

            while (!yes)
            {
                if (EngineerDbs.Count > 0)
                {
                    yes = EngineerDbs.TryGetValue(userId, out Engineers);
                }
                if (yes)
                {
                    TmParameter response = TmParameterTool.ToJsonParameter <List <TmSoulerDB> >(TenCode.Engineer, ElevenCode.GetRolers, ElevenCode.GetRolers.ToString(), Engineers);
                    response.Keys.Add(parameter.Keys[0]);
                    TmTcpSocket.Instance.Send(response);
                    break;
                }
                else
                {
                    TmMysqlHandler.Instance.GetComponent <TmEngineerMysql>().OnTransferParameter(this, parameter);
                    Console.WriteLine(TmTimerTool.CurrentTime() + " this.EngineerDbs:" + EngineerDbs.Count);
                    count += 1;
                }
                if (count > 3)
                {
                    yes = true;
                }
            }
        }
Exemple #4
0
        void GetRolersByRolerId(TmParameter parameter)
        {
            bool yes   = false;
            int  count = 0;

            while (!yes)
            {
                if (this.Bookers != null)
                {
                    TmParameter response = TmParameterTool.ToJsonParameter(TenCode.Booker, ElevenCode.GetRolers, ElevenCode.GetRolers.ToString(), this.Bookers);
                    response.Keys.Add(parameter.Keys[0]);
                    TmTcpSocket.Instance.Send(response);
                    yes = true;
                }
                else
                {
                    TmMysqlHandler.Instance.GetComponent <TmBookerMysql>().OnTransferParameter(this, parameter);
                    Console.WriteLine(TmTimerTool.CurrentTime() + " Bookers:" + Bookers.Count);
                    count += 1;
                }
                if (count > 4)
                {
                    yes = true;
                    break;
                }
            }
        }
Exemple #5
0
        void SetTeachers(TmEntity entity)
        {
            TmSession session = entity.GetComponent <TmSession>();

            if (TmObjects.Teachers.Count > 0 && session.IsLogin)
            {
                TmParameter response = TmParameterTool.ToJsonParameter(TenCode.Teacher, ElevenCode.SetSoulerDBs, ElevenCode.SetSoulerDBs.ToString(), TmObjects.Teachers);
                response.Keys.Add(entity.EcsId);
                TmTcpSocket.Instance.Send(response);
                Console.WriteLine(TmTimerTool.CurrentTime() + " TmTeacherDBSystem-Teachers: " + TmObjects.Teachers.Count);
            }
        }
        } = new Dictionary <int, List <TmSoulerDB> >();                                                                        //角色列表字典,ByUersId
        private void GetSoulers(TmParameter parameter)
        {
            if (Soulers == null)
            {
                TmMysqlHandler.Instance.GetComponent <TmEngineerMysql>().OnTransferParameter(this, parameter);
                Console.WriteLine(TmTimerTool.CurrentTime() + " this.Soulers:" + this.Soulers.Count);
            }
            TmParameter response = TmParameterTool.ToJsonParameter <Dictionary <int, TmSouler> >(TenCode.Engineer, ElevenCode.Get, ElevenCode.Get.ToString(), Soulers);

            response.Keys.Add(parameter.Keys[0]);
            TmTcpSocket.Instance.Send(response);
        }
        private void EngineerLogin(TmParameter parameter)
        {
            TmSoulerDB Engineer = null;
            int        rolerId  = TmParameterTool.GetJsonValue <int>(parameter, parameter.ElevenCode.ToString());
            bool       yes      = false;
            int        count    = 0;

            while (!yes)
            {
                if (Engineers.Count > 0)
                {
                    yes = Engineers.TryGetValue(rolerId, out Engineer);
                }
                if (yes)
                {
                    TmParameter response = TmParameterTool.ToJsonParameter <TmSoulerDB>(TenCode.Engineer, ElevenCode.GetRoler, ElevenCode.GetRoler.ToString(), Engineer);
                    response.Keys.Add(parameter.Keys[0]);
                    TmTcpSocket.Instance.Send(response);

                    TmSoulerDB tem;
                    TmObjects.Engineers.TryGetValue(Engineer.Id, out tem);
                    if (tem != null)
                    {
                        TmObjects.Engineers.Remove(Engineer.Id);
                    }
                    TmObjects.Engineers.Add(Engineer.Id, Engineer);  //将engineer 集中管理 放在 全局变量字典中,之前几行是检查有没有注册,如有先删除,再重新注册(因为数据更新了)。

                    if (TmTcpSocket.Instance.TPeers[parameter.Keys[0]] != null)
                    {
                        TmTcpSocket.Instance.TPeers[parameter.Keys[0]].GetComponent <TmSession>().Engineer = Engineer;             //给TmTcpSession赋值Engineer-SoulerDB
                        //TmTcpSocket.Instance.TPeers[parameter.Keys[0]].GetComponent<TmSession>().Engineers = GetEngineersByMyself(Engineer, TmObjects.Engineers);  //给TmTcpSession赋值Engineer-SoulerDB
                        TmTcpSocket.Instance.TPeers[parameter.Keys[0]].GetComponent <TmSession>().Engineers = TmObjects.Engineers; //给TmTcpSession赋值Engineer-SoulerDB
                        TmTcpSocket.Instance.TPeers[parameter.Keys[0]].GetComponent <TmSession>().IsLogin   = true;                //给TmTcpSession赋值Engineer-SoulerDB
                    }
                    GetInventorysByRolerId(parameter);
                    GetSkillsByRolerId(parameter);
                }
                else
                {
                    TmMysqlHandler.Instance.GetComponent <TmEngineerMysql>().OnTransferParameter(this, parameter);
                    Console.WriteLine(TmTimerTool.CurrentTime() + " Engineers:" + Engineers.Count);
                    count += 1;
                }
                if (count > 3)
                {
                    yes = true;
                }
            }
        }
Exemple #8
0
 void SyncGrid()
 {
     time2 += 1;
     if (time2 > resTime2)
     {
         TmStatus status = new TmStatus();
         status.KeyId             = clientId;
         status.MyselfTmTransform = new TmTransform(10, 11, 12, 60);
         status.TargetTmTransform = new TmTransform(20, 21, 22, 84);
         //Console.WriteLine("clientId: " + clientId + " Send36: " + " px: " + status.MyselfTmTransform.px + " py: " + status.MyselfTmTransform.py + " pz: " + status.MyselfTmTransform.pz + " ay: " + status.MyselfTmTransform.ay);
         //Console.WriteLine("clientId: " + clientId + " Send37: " + " px: " + status.MyselfTmTransform.px + " py: " + status.MyselfTmTransform.py + " pz: " + status.MyselfTmTransform.pz + " ay: " + status.MyselfTmTransform.ay);
         TmParameter request = TmParameterTool.ToJsonParameter <TmStatus>(TenCode.StatusSync, ElevenCode.Roler, ElevenCode.Roler.ToString(), status);
         TmTcpSocket.Instance.Send(request);
         time2 = 0;
     }
 }
Exemple #9
0
        void SetInventoryDBs(TmEntity entity)
        {
            TmSession session = entity.GetComponent <TmSession>();

            if (session.InventoryDBs == null)
            {
                return;
            }
            if (session.inventorysChange != session.InventoryDBs.Count && session.InventoryDBs.Count > 0 && session.IsLogin)
            {
                TmParameter response = TmParameterTool.ToJsonParameter(TenCode.Knapsack, ElevenCode.SetIventoryDBs, ElevenCode.SetIventoryDBs.ToString(), session.InventoryDBs);
                response.Keys.Add(entity.EcsId);
                TmTcpSocket.Instance.Send(response);
                session.inventorysChange = session.InventoryDBs.Count;
                Console.WriteLine(TmTimerTool.CurrentTime() + " TmInventoryDBSystem-session.InventoryDBs:" + session.InventoryDBs.Count);
            }
        }
Exemple #10
0
        void SetEngineers(TmEntity entity)
        {
            TmSession session = entity.GetComponent <TmSession>();

            session.Engineers = GetEngineersByMyself(session.Engineer, TmObjects.Engineers);
            session.Engineers.Remove(session.Engineer.Id);
            Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerDBSystem-Id: " + session.Engineer.Id + " Engineers: " + session.Engineers.Count + "-" + TmObjects.Engineers.Count);
            if (session.Engineers.Count > 0 && session.IsLogin)
            {
                TmParameter response = TmParameterTool.ToJsonParameter(TenCode.Engineer, ElevenCode.SetSoulerDBs, ElevenCode.SetSoulerDBs.ToString(), session.Engineers);
                response.Keys.Add(entity.EcsId);
                TmTcpSocket.Instance.Send(response);
            }
            //if (session.engineersChange != session.Engineers.Count && session.IsLogin)
            //{
            //    session.engineersChange = session.Engineers.Count;
            //}
        }