public void Fetch(string[] commandStrings) { // client déjà connecté, on laisse le choix au client sois de le deconnecter sois de se deconnecter sois même var result = MessageBox.Show(CommonCode.TranslateText(5), @"Connexion", MessageBoxButtons.YesNo, MessageBoxIcon.Question); var username = Manager.manager.mainForm.Controls.Find(@"username", false)[0] as TextBox; var password = Manager.manager.mainForm.Controls.Find(@"username", false)[0] as TextBox; var connexionBtn = Manager.manager.GfxObjList.Find(f => f.Name() == @"__ConnexionBtn") as Bmp; if (result == DialogResult.Yes) { // connexion en mode Replace qui prend la relève et deconnecte l'autre utilisateur var authentification = new AuthentificationRequestMessage(username.Text, password.Text, AuthentificationRequestMessage.OverridePreviousConnexion.Replace); authentification.Serialize(); authentification.Send(); // tester le remplacement d'un client deja connecté pour voir est se que ca va marcher } else { Debug.Assert(username != null, "username != null"); username.Enabled = true; Debug.Assert(password != null, "password != null"); password.Enabled = true; Debug.Assert(connexionBtn != null, "connexionBtn != null"); connexionBtn.visible = true; IGfx connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(true); } // fermeture de connexion Network.Shutdown(); } }
public void Fetch(string[] commandStrings) { Enums.Version.version version = (Enums.Version.version)Enum.Parse(typeof(Enums.Version.version), commandStrings[1], true); Txt connexion_stat = (Txt)Manager.manager.GfxObjList.Find(f => f.Name() == "__connexion_stat"); if (!Manager.manager.mainForm.Controls.Find("username", false).Any()) { return; } TextBox username = (TextBox)Manager.manager.mainForm.Controls.Find("username", false)[0]; if (!Manager.manager.mainForm.Controls.Find("password", false).Any()) { return; } TextBox password = (TextBox)Manager.manager.mainForm.Controls.Find("password", false)[0]; if (connexion_stat == null) { return; } // pas de differance entre MAJOR_LESS et REVISION_LESS puisque le client dois avoir la meme version avec le serveur switch (version) { case Enums.Version.version.MAJOR_LESS: // VersionResponseMessage•MAJOR_LESS•Network.downloadMajorLink break; case Enums.Version.version.REVISION_LESS: // VersionResponseMessage•REVISION_LESS•Network.downloadMajorLink break; default: throw new ArgumentOutOfRangeException("Enum " + version + " does'nt have it's handle in switch scoop"); } DialogResult result1 = MessageBox.Show(CommonCode.TranslateText(11), "Version Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { System.Diagnostics.Process.Start(commandStrings[2]); } Bmp ConnexionBtn = (Bmp)Manager.manager.GfxObjList.Find(f => f.Name() == "__ConnexionBtn"); username.Focus(); username.Enabled = true; password.Enabled = true; ConnexionBtn.visible = true; IGfx __connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (__connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(true); } Network.netClient.Shutdown("0x5"); }
public void Disconenct() { // deconnexion avec le serveur username.Enabled = true; password.Enabled = true; ConnexionBtn.visible = true; IGfx __connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (__connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(true); } }
private static void _MapDataObj_FreeChallenge_MouseOut(Bmp bmp, MouseEventArgs e) { #region //mouseout sur l'objet "bouclé" qui represente le combat sur le map CommonCode.CursorDefault_MouseOut(null, null); bmp.point.X += 2; TagedBattleForSpectators tagedBattleForSpectators = (TagedBattleForSpectators)bmp.tag; bmp.ChangeBmp(@"gfx\general\obj\3\challenge\" + BattleType.Type.FreeChallenge + ".dat", SpriteSheet.GetSpriteSheet(BattleType.Type.FreeChallenge.ToString(), 0)); IGfx mapDataObjFreeChallengeP2 = Manager.manager.GfxObjList.Find(f => f.GetType() == typeof(Bmp) && ((Bmp)f).name == "_MapDataObj_" + BattleType.Type.FreeChallenge && ((TagedBattleForSpectators)f.Tag()).IdBattle == tagedBattleForSpectators.IdBattle && ((TagedBattleForSpectators)f.Tag()).TeamSide == (tagedBattleForSpectators.TeamSide == Team.Side.A ? Team.Side.B : Team.Side.A)); ((Bmp)mapDataObjFreeChallengeP2).ChangeBmp(@"gfx\general\obj\3\challenge\" + BattleType.Type.FreeChallenge + ".dat", SpriteSheet.GetSpriteSheet(BattleType.Type.FreeChallenge.ToString(), 0)); #endregion }
public void Fetch(string[] commandStrings) { MessageBox.Show(CommonCode.TranslateText(106), "Identification", MessageBoxButtons.OK, MessageBoxIcon.Warning); _username.Enabled = true; _password.Enabled = true; _connexionBtn.visible = true; IGfx __connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (__connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(true); } // fermeture de connexion Network.Shutdown(); }
private static void Disconnect() { var username = (TextBox)Manager.manager.mainForm.Controls.Find("username", false)[0]; var password = (TextBox)Manager.manager.mainForm.Controls.Find("password", false)[0]; Bmp ConnexionBtn = Manager.manager.GfxObjList.FindLast(f => f.Name() == "__ConnexionBtn") as Bmp; // deconnexion avec le serveur username.Enabled = true; password.Enabled = true; ConnexionBtn.visible = true; IGfx __connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (__connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(true); } }
void ConnexionBtn_MouseClic() { username.Text = username.Text.ToLower(); if (username.Text == "") { connexion_stat.point = new Point(0, 306); connexion_stat.Text = CommonCode.TranslateText(0); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(0), connexion_stat.font).Width / 2); username.Focus(); } else if (password.Text == "") { connexion_stat.point = new Point(0, 306); connexion_stat.Text = CommonCode.TranslateText(1); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(1), connexion_stat.font).Width / 2); password.Focus(); } else if (username.Text.Length < 5) { connexion_stat.point = new Point(312, 306); connexion_stat.Text = CommonCode.TranslateText(6); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(6), connexion_stat.font).Width / 2); username.Focus(); } else if (password.Text.Length < 5) { connexion_stat.point = new Point(0, 306); connexion_stat.Text = CommonCode.TranslateText(7); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(7), connexion_stat.font).Width / 2); password.Focus(); } else if (username.Text.Length > 15) { connexion_stat.point = new Point(0, 306); connexion_stat.Text = CommonCode.TranslateText(21); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(21), connexion_stat.font).Width / 2); username.Focus(); } else if (password.Text.Length > 15) { connexion_stat.point = new Point(0, 306); connexion_stat.Text = CommonCode.TranslateText(22); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(22), connexion_stat.font).Width / 2); password.Focus(); } else if (!Security.check_valid_user(username.Text)) { MessageBox.Show(CommonCode.TranslateText(23), "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information); username.Focus(); } else if (!Security.check_valid_pwd(password.Text)) { connexion_stat.point = new Point(0, 306); connexion_stat.Text = CommonCode.TranslateText(31); connexion_stat.point.X = (ScreenManager.WindowWidth / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(31), connexion_stat.font).Width / 2); password.Focus(); } else { ///// desactivation du boutton connexion ////// ConnexionBtn.visible = false; username.Enabled = false; password.Enabled = false; IGfx __connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (__connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(false); } // 1ere étape de connexion connexion_stat.Text = string.Empty; if (Network.netClient.Status.ToString() == "NotRunning") { Network.Connect(Network.ip, Network.port); } } }
public void Init() { Bmp map = new Bmp(@"gfx\map\SelectPlayer\bg\1.dat", new Point(0, 0), "map1", Manager.TypeGfx.Bgr, true, 1); map.MouseMove += CommonCode.CursorDefault_MouseOut; Manager.manager.GfxBgrList.Add(map); // mise en cache des element du menu hud s'il a été préalablement affiché IGfx __StatsImg = Manager.manager.GfxTopList.Find(f => f.GetType() == typeof(Bmp) && (f as Bmp).name == "__StatsImg"); if (__StatsImg != null && (__StatsImg as Bmp).visible) { (__StatsImg as Bmp).visible = false; } for (int cnt = 0; cnt < 5; cnt++) { terrain[cnt] = new Bmp(@"gfx\map\SelectPlayer\obj\2.dat", new Point(0, 0), "terrain[" + cnt + "]", Manager.TypeGfx.Obj, true, 1); Manager.manager.GfxObjList.Add(terrain[cnt]); lPseudo[cnt] = new Txt(string.Empty, new Point(0, 0), "lPseudo[" + cnt + "]", Manager.TypeGfx.Obj, true, new Font("Verdana", 10, FontStyle.Regular), Brushes.Red); lLvlPlayer[cnt] = new Txt(string.Empty, new Point(0, 0), "lLvlPlayer[" + cnt + "]", Manager.TypeGfx.Obj, true, new Font("Verdana", 10, FontStyle.Regular), Brushes.CadetBlue); // image du personnage ibPlayers[cnt] = new Bmp { point = new Point(0, 0), name = "ibPlayers[" + cnt + "]", zindex = ZOrder.Obj(), visible = true }; ibPlayers[cnt].MouseDoubleClic += SelectPlayer_MouseDoubleClic; ibPlayers[cnt].MouseMove += CommonCode.CursorHand_MouseMove; ibPlayers[cnt].MouseOut += CommonCode.CursorDefault_MouseOut; ibPlayers[cnt].TypeGfx = Manager.TypeGfx.Obj; ibPlayers[cnt].Crypted = true; delete[cnt] = new Bmp(@"gfx\map\SelectPlayer\obj\delete.dat", new Point(0, 0), "delete." + cnt, Manager.TypeGfx.Obj, false, 1); delete[cnt].MouseOver += CommonCode.CursorHand_MouseMove; delete[cnt].MouseOut += CommonCode.CursorDefault_MouseOut; delete[cnt].MouseClic += Delete_Player_MouseClic; ibPlayers[cnt].Child.Add(delete[cnt]); lLvlSpirit[cnt] = new Txt(string.Empty, new Point(0, 0), "lLvlSpirit[" + cnt + "]", Manager.TypeGfx.Obj, true, new Font("Verdana", 10, FontStyle.Bold), Brushes.Red); } //// ombre terrain[0].point = new Point(172, 210); terrain[1].point = new Point(316, 310); terrain[2].point = new Point(460, 390); terrain[3].point = new Point(598, 310); terrain[4].point = new Point(720, 212); //// imagebox player ibPlayers[0].point = new Point(209, 170); ibPlayers[1].point = new Point(352, 268); ibPlayers[2].point = new Point(498, 350); ibPlayers[3].point = new Point(637, 270); ibPlayers[4].point = new Point(757, 174); ibCreatePlayer = new Bmp(@"gfx\general\obj\1\all1.dat", new Point(434, 466), "ibCreatePlayer", Manager.TypeGfx.Obj, true, 1, SpriteSheet.GetSpriteSheet("_Main_option", 9)); ibCreatePlayer.MouseDown += ibRetour_MouseDown; ibCreatePlayer.MouseUp += ibRetour_MouseUp; ibCreatePlayer.MouseOver += CommonCode.CursorHand_MouseMove; ibCreatePlayer.MouseOut += CommonCode.CursorDefault_MouseOut; ibCreatePlayer.EscapeGfxWhileMouseUp = true; Manager.manager.GfxObjList.Add(ibCreatePlayer); Txt CreatePlayer = new Txt(CommonCode.TranslateText(24), new Point(378, 470), "__CreatePlayer", Manager.TypeGfx.Obj, true, new Font("Verdana", 10, FontStyle.Regular), Brushes.Yellow); CreatePlayer.point.X = ibCreatePlayer.point.X + (ibCreatePlayer.rectangle.Width / 2) - (TextRenderer.MeasureText(CreatePlayer.Text, CreatePlayer.font).Width / 2); Manager.manager.GfxObjList.Add(CreatePlayer); ///////////////////// menu pour la supression du joueur rec1 = new Rec(Brushes.Beige, new Point((ScreenManager.WindowWidth / 2) - 150, (ScreenManager.WindowHeight / 2) - 100), new Size(300, 200), "rec1", Manager.TypeGfx.Top, false); Txt lqs = new Txt(CommonCode.TranslateText(60), new Point(0, 20), "lqs", Manager.TypeGfx.Top, true, new Font("Verdana", 9), Brushes.Black); lqs.point.X = (rec1.size.Width / 2) - (TextRenderer.MeasureText(CommonCode.TranslateText(60), lqs.font).Width / 2); rec1.Child.Add(lqs); secretQuestion = new Txt(string.Empty, new Point(0, 50), "qs", Manager.TypeGfx.Top, true, new Font("Verdana", 9), Brushes.Red); rec1.Child.Add(secretQuestion); secretQuestionTB = new TextBox { Width = 150 }; secretQuestionTB.Location = new Point((ScreenManager.WindowWidth - secretQuestionTB.Width) / 2 + 10, rec1.point.Y + 80); secretQuestionTB.Visible = false; secretQuestionTB.UseSystemPasswordChar = true; secretQuestionTB.Name = "secretQuestionTB"; Manager.manager.mainForm.Controls.Add(secretQuestionTB); Manager.manager.GfxCtrlList.Add(secretQuestionTB); envoyerBtn = new Button { Text = CommonCode.TranslateText(26), Visible = false, Location = new Point(440, 370), Name = "envoyerBtn" }; envoyerBtn.Click += envoyerBtn_Click; Manager.manager.GfxCtrlList.Add(envoyerBtn); Manager.manager.mainForm.Controls.Add(envoyerBtn); annulerBtn = new Button { Text = CommonCode.TranslateText(34), Visible = false, Location = new Point(520, 370), Name = "annulerBtn" }; annulerBtn.Click += annulerBtn_Click; Manager.manager.mainForm.Controls.Add(annulerBtn); Manager.manager.GfxCtrlList.Add(annulerBtn); Manager.manager.GfxTopList.Add(rec1); CommonCode.MyPlayerInfo.instance.map = "SelectPlayer"; //////////////////////////////////////////////////////// GrabingPlayersInformationRequestMessage grabingPlayersInformationRequestMessage = new GrabingPlayersInformationRequestMessage(); grabingPlayersInformationRequestMessage.Serialize(); grabingPlayersInformationRequestMessage.Send(); }
static void client_Disconnected(string reason) { Enums.DisconnectReason.disconnectReason disconnectReason; if (!Enum.TryParse(reason, true, out disconnectReason)) { disconnectReason = DisconnectReason.disconnectReason.OTHER; } else { disconnectReason = (Enums.DisconnectReason.disconnectReason) Enum.Parse(typeof(Enums.DisconnectReason.disconnectReason), reason, true); } switch (disconnectReason) { case Enums.DisconnectReason.disconnectReason.HOST_UNREACHABLE: MessageBox.Show(CommonCode.TranslateText(2) + Environment.NewLine + reason, "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); MainForm.DrawDisconnectImg(true); GameStates.GameStateManager.ChangeState(new GameStates.LoginMap()); GameStates.GameStateManager.CheckState(); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.USER_BANNED: DialogResult userBannedResult = MessageBox.Show(CommonCode.TranslateText(10), "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (userBannedResult == DialogResult.Yes) { System.Diagnostics.Process.Start(MainForm.url); } GameStates.GameStateManager.ChangeState(new GameStates.LoginMap()); GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.MAINTENANCE: MessageBox.Show(CommonCode.TranslateText(14), "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.RESTARTING: MessageBox.Show(CommonCode.TranslateText(15), "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.SHUTDOWN: MessageBox.Show(CommonCode.TranslateText(16), "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.WRONG_CREDENTIALS: MessageBox.Show(CommonCode.TranslateText(8), "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.IP_BANNED: DialogResult ipBannedResult = MessageBox.Show(CommonCode.TranslateText(17), "IP Banned", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (ipBannedResult == DialogResult.Yes) { System.Diagnostics.Process.Start(MainForm.url); } MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case Enums.DisconnectReason.disconnectReason.INVALID_TYPES: MessageBox.Show(CommonCode.TranslateText(31), "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); MainForm.DrawDisconnectImg(true); Disconnect(); break; case DisconnectReason.disconnectReason.ANOTHER_USER_OVERRIDE_CONNEXION: // il faut tester ce mode MessageBox.Show(CommonCode.TranslateText(13) + Environment.NewLine + reason, "Connexion Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); Shutdown(); break; case DisconnectReason.disconnectReason.TIME_OUT: MessageBox.Show(CommonCode.TranslateText(193) + Environment.NewLine + reason, "Connexion Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); break; case Enums.DisconnectReason.disconnectReason.OTHER: MessageBox.Show(CommonCode.TranslateText(4) + Environment.NewLine + reason, "Connexion Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); MMORPG.GameStates.GameStateManager.ChangeState(new MMORPG.GameStates.LoginMap()); MMORPG.GameStates.GameStateManager.CheckState(); Disconnect(); if (Manager.manager.mainForm.Controls.Find("username", false).Length == 0) { return; } TextBox username = Manager.manager.mainForm.Controls.Find("username", false)[0] as TextBox; username.Enabled = true; TextBox password = Manager.manager.mainForm.Controls.Find("password", false)[0] as TextBox; password.Enabled = true; Bmp ConnexionBtn = Manager.manager.GfxObjList.FindLast(f => f.Name() == "__ConnexionBtn") as Bmp; ConnexionBtn.visible = true; IGfx __connexionBtnLabel = Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel"); if (__connexionBtnLabel != null) { Manager.manager.GfxObjList.Find(f => f.Name() == "__connexionBtnLabel").Visible(true); } break; } Battle.Clear(); Shutdown(); }