private void GetSkillsByRolerId(TmParameter parameter) { int rolerid = TmParameterTool.GetJsonValue <int>(parameter, ElevenCode.EngineerLogin.ToString()); List <TmSkillDB> skillDBs = new List <TmSkillDB>(); bool yes = false; int count = 0; while (!yes) { if (Abilities.Count > 0) { yes = Abilities.TryGetValue(rolerid, out skillDBs); } if (yes) { if (TmTcpSocket.Instance.TPeers[parameter.Keys[0]] != null) { TmTcpSocket.Instance.TPeers[parameter.Keys[0]].GetComponent <TmSession>().SkillDBs = skillDBs; //给TmTcpSession赋值Engineer-SoulerDB } yes = true; break; } else { TmMysqlHandler.Instance.GetComponent <TmAbilityMysql>().OnTransferParameter(this, parameter); Console.WriteLine(TmTimerTool.CurrentTime() + " this.Abilities:" + this.Abilities.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; } } }
void RolerStatusSync(TmParameter parameter) { TmStatus status = TmParameterTool.GetJsonValue <TmStatus>(parameter, parameter.ElevenCode.ToString()); if (status != null) { Console.WriteLine(" KeyId: " + status.KeyId + " Recv30: " + " px: " + status.MyselfTmTransform.px + " py: " + status.MyselfTmTransform.py + " pz: " + status.MyselfTmTransform.pz + " ay: " + status.MyselfTmTransform.ay); Console.WriteLine(" KeyId: " + status.KeyId + " Recv31: " + " px: " + status.TargetTmTransform.px + " py: " + status.TargetTmTransform.py + " pz: " + status.TargetTmTransform.pz + " ay: " + status.TargetTmTransform.ay); } }
void SetSoulerDBs(TmParameter parameter) { Dictionary <int, TmSoulerDB> bookers = TmParameterTool.GetJsonValue <Dictionary <int, TmSoulerDB> >(parameter, parameter.ElevenCode.ToString()); if (bookers.Count > 0) { TmObjects.Teachers = bookers; Console.WriteLine(TmTimerTool.CurrentTime() + " TmObjects.Teachers: " + TmObjects.Teachers.Count); } }
void DiethHandler(TmParameter parameter) { TmSoulerDB soulerDB = TmParameterTool.GetJsonValue <TmSoulerDB>(parameter, ElevenCode.Die.ToString()); parameter.ElevenCode = ElevenCode.RolerRemove; foreach (var tem in TmTcpSocket.Instance.TPeers.Keys) { parameter.Keys.Add(tem); } TmTcpSocket.Instance.Send(parameter); }
void GetEngineersByUserId(TmParameter tmp) { List <TmSoulerDB> engineers = TmParameterTool.GetJsonValue <List <TmSoulerDB> >(tmp, tmp.ElevenCode.ToString()); Console.WriteLine(TmTimerTool.CurrentTime() + " engineers: " + engineers.Count); Engineer = engineers[0]; for (int i = 0; i < engineers.Count; i++) { Console.WriteLine(TmTimerTool.CurrentTime() + " engineers: " + engineers.Count + " Id:" + engineers[i].Id + " Name:" + engineers[i].Name); TmConsoleLog.WriteLine(TmTimerTool.CurrentTime() + " engineers: " + engineers.Count + " Id:" + engineers[i].Id + " Name:" + engineers[i].Name); } EngineerLoginToServer(Engineer.Id); }
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; } } }
void GetDbsByRolerId(object sender, TmParameter parameter) { int rolerid = TmParameterTool.GetJsonValue <int>(parameter, ElevenCode.EngineerLogin.ToString()); Dictionary <int, TmSkillDB> dbs = GetSkilldbsByRolerId(rolerid); Console.WriteLine(TmTimerTool.CurrentTime() + " dbs:" + dbs.Count); if (dbs.Count > 0) { (sender as TmBuffHandler).Buffs.Add(rolerid, dbs); } else { Console.WriteLine(TmTimerTool.CurrentTime() + " 没有角色"); } }
void GetKnapsackByRolerId(object sender, TmParameter parameter) { int rolerid = TmParameterTool.GetJsonValue <int>(parameter, ElevenCode.EngineerLogin.ToString()); List <TmInventoryDB> dbs = GetInventorydbsByRolerId(rolerid); Console.WriteLine(TmTimerTool.CurrentTime() + " TmKnapsackMysql-dbs: " + dbs.Count); if (dbs.Count > 0) { (sender as TmKnapsackHandler).Knapsacks.Add(rolerid, dbs); } else { Console.WriteLine(TmTimerTool.CurrentTime() + " 没有角色"); } }
void GetdbofEngineerLogin(object sender, TmParameter parameter) { int rolerId = TmParameterTool.GetJsonValue <int>(parameter, ElevenCode.EngineerLogin.ToString()); Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerMysql,rolerId:" + rolerId); TmSoulerDB db = GetTmSoulerdbById(rolerId); Console.WriteLine(TmTimerTool.CurrentTime() + " db:" + db.Name); if (db != null) { (sender as TmEngineerHandler).Engineers.Add(rolerId, db); } else { Console.WriteLine(TmTimerTool.CurrentTime() + " 没有角色"); } }
void GetRoler(TmParameter tmp) { Engineer = TmParameterTool.GetJsonValue <TmSoulerDB>(tmp, tmp.ElevenCode.ToString()); Console.WriteLine(TmTimerTool.CurrentTime() + " engineer: " + Engineer.Name); }