private void CheckUserLoginPassword(TmParameter parameter) { Console.WriteLine(TmTimerTool.CurrentTime() + " to TmUserHandler 30 " + parameter.ElevenCode.ToString()); string name = TmParameterTool.GetValue <string>(parameter, "Username"); string word = TmParameterTool.GetValue <string>(parameter, "Password"); Console.WriteLine(TmTimerTool.CurrentTime() + " Username:"******" Password:"******" this.User:"******" this.User:"******" this.User.Phone:" + this.User.Phone); if (this.User != null) { if (User.Password == word) { TmParameterTool.AddParameter(parameter, parameter.ElevenCode.ToString(), this.User.Id); parameter.ElevenCode = ElevenCode.GetRolers; Parent.GetComponent <TmEngineerHandler>().OnTransferParameter(this, parameter); Console.WriteLine(TmTimerTool.CurrentTime() + " Username:"******" Password:"******"密码不正确"); } } else { Console.WriteLine("帐号不存在"); } }
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; } } }
public override void OnTransferParameter(object sender, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.Engineer): Console.WriteLine(TmTimerTool.CurrentTime() + " TmStatusSyncHandler: " + elevenCode); RolerStatusSync(parameter); break; case (ElevenCode.Teacher): Console.WriteLine(TmTimerTool.CurrentTime() + " TmStatusSyncHandler: " + elevenCode); RolerStatusSync(parameter); break; case (ElevenCode.Booker): Console.WriteLine(TmTimerTool.CurrentTime() + " TmStatusSyncHandler: " + elevenCode); RolerStatusSync(parameter); break; //case (ElevenCode.Souler): // Console.WriteLine(TmTimerTool.CurrentTime() + " TmStatusSyncHandler: " + elevenCode); // RolerStatusSync(parameter); // break; case (ElevenCode.None): break; default: break; } }
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; } } }
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; } } }
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; } } }
public override void OnTransferParameter(object obj, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.Get): Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerHandler: " + elevenCode); break; case (ElevenCode.GetRolers): Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerHandler: " + elevenCode); break; case (ElevenCode.EngineerLogin): Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerHandler: " + elevenCode); break; //case (ElevenCode.StatusSync): // Console.WriteLine(TmTimerTool.CurrentTime() + " TmStatusSyncHandler: " + elevenCode); // Parent.GetComponent<TmStatusSyncHandler>().OnTransferParameter(this, parameter); // break; case (ElevenCode.None): break; default: 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; } } }
void ConnectToServer() { if (!TmClient.IsRunning) { //TmClient.Init("127.0.0.1", 8115); TmClient.Init("172.17.16.15", 8115); TmClient.StartConnect(); Console.WriteLine(TmTimerTool.CurrentTime() + " Connecting..."); } }
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); } }
} = 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); }
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); } }
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 GetSoulerDBs() { Dictionary<int, TmSoulerDB> dbs = GetTmSoulerDBsDict(); if (dbs.Count > 0 && !isYes) { TmObjects.Bookers = dbs; isYes = true; Console.WriteLine(TmTimerTool.CurrentTime() + " TmBookerMysql-Bookers: " + TmObjects.Bookers.Count); } else { Console.WriteLine(TmTimerTool.CurrentTime() + " 没有角色"); } }
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 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 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() + " 没有角色"); } }
public override void OnTransferParameter(object obj, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.Register): Console.WriteLine(TmTimerTool.CurrentTime() + " TmUserController: " + elevenCode); break; default: break; } }
//程序启动入口 static void Main(string[] args) { Console.WriteLine(TmTimerTool.CurrentTime() + " ... "); Thread.Sleep(1); TmSenceInit(); TmSystemManager(); TmGame.TmSystemMananger.AddComponent(new ServerTest()); ///测试用 Thread.CurrentThread.Name = "TumoWorld"; Console.WriteLine(TmTimerTool.CurrentTime() + " ThreadName:" + Thread.CurrentThread.Name); Console.WriteLine(TmTimerTool.CurrentTime() + " ThreadId:" + Thread.CurrentThread.ManagedThreadId); Console.ReadKey(); 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() + " 没有角色"); } }
static void Main(string[] args) { Console.WriteLine(TmTimerTool.CurrentTime() + " ... "); Thread.Sleep(4000); TmGameSenceInit(); TmGame.TmSence.AddComponent(new TmTest()); ///客户端加载组件 : 测试组件1 TmGame.TmSence.AddComponent(new SyncTest()); ///客户端加载组件 : 测试组件2 Thread.CurrentThread.Name = "TumoWorld"; Console.WriteLine(TmTimerTool.CurrentTime() + " ThreadName:" + Thread.CurrentThread.Name); Console.WriteLine(TmTimerTool.CurrentTime() + " ThreadId:" + Thread.CurrentThread.ManagedThreadId); Console.ReadKey(); Console.WriteLine(TmTimerTool.CurrentTime() + " 退出联接,并关闭程序。"); }
void GetRolersByUersId(object sender, TmParameter parameter) { int userId = TmParameterTool.GetValue <int>(parameter, ElevenCode.UserLogin.ToString()); Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerMysql,userId:" + userId); List <TmSoulerDB> dbs = GetTmSoulerdbsByUserId(userId); Console.WriteLine(TmTimerTool.CurrentTime() + " dbs:" + dbs.Count); if (dbs.Count > 0) { (sender as TmEngineerHandler).EngineerDbs.Add(userId, dbs); } else { Console.WriteLine(TmTimerTool.CurrentTime() + " 没有角色"); } }
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); } }
public override void OnTransferParameter(object sender, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.GetSkills): Console.WriteLine(TmTimerTool.CurrentTime() + " TmBuffMysql: " + elevenCode); GetDbsByRolerId(sender, parameter); break; case (ElevenCode.None): break; default: break; } }
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; //} }
void ResTimeGet() { time += 1; if (time == resTime) { GetStartGoal2(); SoulerItem.GetComponent <TmAstarComponent>().isCan = true; Console.WriteLine(TmTimerTool.CurrentTime() + " ServerTest53: " + SoulerItem.GetComponent <TmAstarComponent>().isCan); } if (time == resTime * 2) { GetStartGoal(); SoulerItem.GetComponent <TmAstarComponent>().isCan = true; Console.WriteLine(TmTimerTool.CurrentTime() + " ServerTest59: " + SoulerItem.GetComponent <TmAstarComponent>().isCan); time = 0; } }
public override void OnTransferParameter(object obj, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.UserLogin): Console.WriteLine(TmTimerTool.CurrentTime() + " TmUser: " + elevenCode); CheckUserLoginPassword(parameter); break; case (ElevenCode.None): break; default: break; } }
public override void OnTransferParameter(object sender, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.Map): Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerMysql: " + elevenCode); GetGridMap(this, parameter); break; case (ElevenCode.None): break; default: break; } }
///连接到数据库 public void StartConnectToMysql() { if (!IsConnecting || Connection == null || Connection.State.ToString() != "Open") { try { string connectionString = string.Format("Server = {0}; Database = {1}; User ID = {2}; Password = {3};", localhost, database, root, password); Connection = new MySqlConnection(connectionString); Connection.Open(); IsConnecting = true; Console.WriteLine(TmTimerTool.CurrentTime() + " 连接MySql数据库成功,版本号:{0},地址:{1} ", Connection.ServerVersion, localhost); } catch (Exception ex) { IsConnecting = false; Console.WriteLine(TmTimerTool.CurrentTime() + " 连接MySql数据库,异常:{0} ", ex.Message); } Console.WriteLine(TmTimerTool.CurrentTime() + " IsConnecting:" + IsConnecting + " State:" + Connection.State); } }
public override void OnTransferParameter(object sender, TmParameter parameter) { ElevenCode elevenCode = parameter.ElevenCode; switch (elevenCode) { case (ElevenCode.GetRolers): Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerMysql: " + elevenCode); GetRolersByUersId(sender, parameter); break; case (ElevenCode.EngineerLogin): Console.WriteLine(TmTimerTool.CurrentTime() + " TmEngineerMysql: " + elevenCode); GetdbofEngineerLogin(sender, parameter); break; case (ElevenCode.None): break; default: break; } }