/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (Window.ClientBounds.Width != ScreenWidth || Window.ClientBounds.Height != ScreenHeight) { ScreenWidth = Window.ClientBounds.Width; // TODO: ON RESIZE ScreenHeight = Window.ClientBounds.Height; if (gameState != null) { gameState.Resize(ScreenWidth, ScreenHeight); } } MouseControl.Update(); KeyBindings.Update(); if (mainMenu != null && _GlobalState == GlobalGameState.MainMenu) { Menu.Update(null, null, mainMenu); mainMenu.Update(Menu); } if (gameState != null && _GlobalState == GlobalGameState.Game) { Menu.Update(gameState.UI, gameState, mainMenu); gameState.Update(Menu); } else { Menu.Update(null, gameState, mainMenu); } //Window.Title = gameState.watch.Elapsed.ToString() + "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y) + "|ZOOM|" + gameState.cam.Zoom.ToString() + "|POS|" + gameState.cam.Position.ToString(); Window.Title = "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y); LoadingBr.UpdateAnims(); if (IsLoadToGame) { LoadingIterations++; if (LoadingIterations == 60) { _GlobalState = GlobalGameState.Game; LoadingBr.ScreenBrUp(); } if (LoadingIterations == 120) { IsLoadToGame = false; } } if (IsLoadToMenu) { LoadingIterations++; if (LoadingIterations == 60) { _GlobalState = GlobalGameState.MainMenu; mainMenu.ReturnFromGame(); gameState = null; LoadingBr.ScreenBrUp(); } if (LoadingIterations == 120) { IsLoadToMenu = false; } } base.Update(gameTime); }
public int Update(NetworkInterface MasterNI) { NameEdit.Update(); PassEdit.Update(); Br.UpdateAnims(); if (Login.Update() == ButtonStates.CLICKED) { //DONE: Запрос на сервер IsRegistration = false; IsRequestSended = false; MasterNI.ConnectTo(Config.ServerIP); Log.SendMessage("Подключение к мастер-серверу"); ShowConnectingState(); } else if (Register.Update() == ButtonStates.CLICKED) { //DONE: Запрос на сервер IsRegistration = true; IsRequestSended = false; MasterNI.ConnectTo(Config.ServerIP); Log.SendMessage("Подключение к мастер-серверу"); ShowConnectingState(); } if (IsConnectingState) { Connecting_Icon.RotateOn(0.01f); if (MasterNI.IsConnected) { if (IsRequestSended) { string[] command = null; CommandParser.UpdateMasterServer(out command); if (command != null) { IsRequestSended = false; if (command[0] == "OK") { if (IsRegistration) { SetText("Успешно зарегестрирован"); ShowNormalState(); MasterNI.Disconnect(); } else { ShowNormalState(); _PlayerName = command[1]; _PlayerMoney = Convert.ToInt32(command[2]); Hide(true); return(1); } } else if (command[0] == "ERROR") { SetErrorText(Convert.ToInt32(command[1])); ShowNormalState(); MasterNI.Disconnect(); } } } else { IsRequestSended = true; if (IsRegistration) { CommandParser.SendCommandToMasterServer(new string[] { "REGISTER", NameEdit.Text, PassEdit.Text }); } else { CommandParser.SendCommandToMasterServer(new string[] { "LOGIN", NameEdit.Text, PassEdit.Text }); } } } else { if (MasterNI.IsError) { SetErrorText(ServerErrors.Length - 1); IsRequestSended = false; ShowNormalState(); MasterNI.Disconnect(); } } } return(0); }