public static bool InitializeEngine() { NetworkSocket.Initialize(); try { background = new EngineObject($"{Common.Configuration.GamePath}/Data/background.png", 1024, 768); background.Size = new Size2(1024, 768); background.SourceRect = new Rectangle(0, 0, 1024, 720); DataManager.Initialize(); WindowTalent.Initialize(); WindowSkill.Initialize(); WindowPin.Initialize(); WindowCash.Initialize(); WindowMail.Initialize(); WindowSelectedItem.Initialize(); WindowViewTalent.Initialize(); //Carrega os dados de classe. ClasseManager.Initialize(); //Carrega os dados de npc. NpcManager.OpenData(); //Carrega os dados de experiencia ExperienceManager.Read(); EngineFont.Initialize(); EngineMessageBox.Initialize(); EngineInputBox.Initialize(); EngineMultimedia.Initialize(); WindowLogin.Initialize(); WindowServer.Initialize(); WindowCharacter.Initialize(); WindowNewCharacter.Initialize(); WindowGame.Initialize(); WindowViewItem.Initialize(); // EngineMultimedia.PlayMusic(0, true); GameState = 1; return(true); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
public static void Render() { if (Device == null) { return; } Device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0); Device.BeginScene(); background.Draw(); if (GameState == 1) { // WindowTalent.Visible = true; // WindowTalent.Draw(); // WindowViewTalent.Draw(); WindowLogin.Draw(); } if (GameState == 2) { WindowServer.Draw(); } if (GameState == 3) { WindowCharacter.Draw(); WindowPin.Draw(); } if (GameState == 4) { WindowNewCharacter.Draw(); } if (GameState == 6) { WindowGame.Draw(); } EngineInputBox.Draw(); EngineMessageBox.Draw(); EngineFont.DrawText("FPS: " + FPS, 925, 0, Color.Coral, EngineFontStyle.Bold); EngineFont.DrawText("Ping: " + Common.Configuration.Latency, 5, 0, Color.Coral, EngineFontStyle.Bold); Device.EndScene(); Device.Present(); }
private void Device_KeyPress(object sender, KeyPressEventArgs e) { #region GameState 1 if (EngineCore.GameState == 1) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { WindowLogin.Login(); } if (e.KeyChar == Convert.ToChar(Keys.Tab)) { if (WindowLogin.textbox[0].CursorEnabled == true) { if (WindowLogin.textbox[0].Enabled == false) { return; } WindowLogin.textbox[0].CursorEnabled = false; WindowLogin.textbox[1].CursorEnabled = true; WindowLogin.textbox[1].CursorState = 0; } else { if (WindowLogin.textbox[1].Enabled == false) { return; } WindowLogin.textbox[0].CursorEnabled = true; WindowLogin.textbox[1].CursorEnabled = false; WindowLogin.textbox[0].CursorState = 0; } return; } if (WindowLogin.textbox[0].CursorEnabled == true) { if (WindowLogin.textbox[0].Enabled == false) { return; } //if (char.IsLetterOrDigit(e.KeyChar) || char.(e.KeyChar)) if (Convert.ToInt32(e.KeyChar) == 8) { if (WindowLogin.textbox[0].Text.Length > 0) { WindowLogin.textbox[0].RemoveText(); } } if (char.IsLetterOrDigit(e.KeyChar)) { if (WindowLogin.textbox[0].Text.Length <= 27) { //retorna se o ime estiver ativado if (ImeModeOn) { return; } WindowLogin.textbox[0].AddText(e.KeyChar); } } } if (WindowLogin.textbox[1].CursorEnabled == true) { if (WindowLogin.textbox[1].Enabled == false) { return; } if (Convert.ToInt32(e.KeyChar) == 8) { if (WindowLogin.textbox[1].Text.Length > 0) { WindowLogin.textbox[1].RemoveText(); } } if (char.IsLetterOrDigit(e.KeyChar)) { if (WindowLogin.textbox[1].Text.Length <= 27) { if (ImeModeOn) { return; } WindowLogin.textbox[1].AddText(e.KeyChar); } } } return; } #endregion #region GameState 3 if (EngineCore.GameState == 3) { if (!EngineInputBox.Visible) { return; } if (WindowPin.Visible) { if (e.KeyChar == Convert.ToChar(Keys.Tab)) { WindowPin.SelectTextbox(); } } if (EngineInputBox.TextBox.CursorEnabled == true) { if (EngineInputBox.TextBox.Enabled == false) { return; } if (Convert.ToInt32(e.KeyChar) == 8) { if (EngineInputBox.TextBox.Text.Length > 0) { EngineInputBox.TextBox.RemoveText(); } } if (ImeModeOn) { return; } if (char.IsDigit(e.KeyChar) || char.IsLetter(e.KeyChar)) { if (EngineInputBox.TextBox.Text.Length <= 12) { EngineInputBox.TextBox.AddText(e.KeyChar); } } } return; } #endregion #region GameState 4 if (EngineCore.GameState == 4) { if (WindowNewCharacter.textbox.CursorEnabled == true) { if (WindowNewCharacter.textbox.Enabled == false) { return; } if (Convert.ToInt32(e.KeyChar) == 8) { if (WindowNewCharacter.textbox.Text.Length > 0) { WindowNewCharacter.textbox.RemoveText(); } } if (ImeModeOn) { return; } if (char.IsDigit(e.KeyChar) || char.IsLetter(e.KeyChar)) { if (WindowNewCharacter.textbox.Text.Length <= 12) { WindowNewCharacter.textbox.AddText(e.KeyChar); } } } return; } #endregion #region GameState 6 if (EngineCore.GameState == 6) { if (WindowCash.BuyItemVisible) { if (WindowCash.textbox.CursorEnabled == true) { if (Convert.ToInt32(e.KeyChar) == 8) { if (WindowCash.textbox.Text.Length > 0) { WindowCash.textbox.RemoveText(); } return; } if (ImeModeOn) { return; } if (WindowCash.textbox.Text.Length <= 20) { WindowCash.textbox.AddText(e.KeyChar); } } return; } if (e.KeyChar == 13) { if (WindowChat.textbox.CursorEnabled) { //envia o texto if (WindowChat.textbox.Text.Length > 0) { WindowChat.SendChat(); } //limpa o texto e fecha WindowChat.textbox.Clear(); WindowChat.textbox.CursorEnabled = false; WindowChat.Transparency = 120; } else { WindowChat.textbox.Clear(); WindowChat.textbox.CursorEnabled = true; WindowChat.Transparency = 255; } } if (WindowChat.textbox.CursorEnabled == true) { if (Convert.ToInt32(e.KeyChar) == 8) { if (WindowChat.textbox.Text.Length > 0) { WindowChat.textbox.RemoveText(); } return; } if (ImeModeOn) { return; } if (WindowChat.textbox.Text.Length <= 30) { WindowChat.textbox.AddText(e.KeyChar); } } } #endregion }