public void Update(GameMenu menu) { //TODO: Esc bug меню if (menu.IsShown) { return; } if (IsLoginState) { if (LogIn.Update(MasterNI) == 1) { IsLoginState = false; PlayerName.Text = LogIn.PlayerName; PlayerMoney.Text = LogIn.PlayerMoney.ToString(); } } else { if (Home.Update() == ButtonStates.CLICKED) { if (State != MenuState.HOME) { if (RollingBack.Position != RollingBack.DownPosition) { RollingBack.SetDown(); } if (State == MenuState.COLLECTION) { collection.Hide(); } else if (State == MenuState.PLAY) { play.Hide(); } State = MenuState.HOME; } } if (Play.Update() == ButtonStates.CLICKED) { if (State != MenuState.PLAY) { RollingBack.SetUp(); if (State == MenuState.COLLECTION) { collection.Hide(); } State = MenuState.PLAY; } } if (Collection.Update() == ButtonStates.CLICKED) { if (State != MenuState.COLLECTION) { if (State == MenuState.PLAY) { play.Hide(); } RollingBack.SetUp(); State = MenuState.COLLECTION; } } if (OpenCardPack.Update() == ButtonStates.CLICKED) { // RollingBack.SetUp(); // if (State == MenuState.COLLECTION) // collection.Hide(); } if (Options.Update() == ButtonStates.CLICKED) { menu.Show(null, null, this); if (State == MenuState.COLLECTION) { collection.Hide(); } else if (State == MenuState.PLAY) { play.Hide(); } } if (State == MenuState.COLLECTION) { if (!RollingBack.IsMoving && !collection.IsShown) { collection.Show(1, true); } } if (State == MenuState.PLAY) { if (!RollingBack.IsMoving && !play.IsShown) { play.Show(); } } } RollingBack.Update(); collection.Update(); play.Update(); if (State == MenuState.CONNECTING) { play.Update(); if (!GameNI.IsConnected) { GameNI.ConnectTo(GameIP); } if (GameNI.IsConnected) { Log.SendMessage("Подключено"); CommandParser.InitGameServer(GameNI); State = MenuState.HOME; play.IsSearchState = false; play.ShowCancelButton(); Parent.CreateGame(GameNI); } } string[] CN; CommandParser.UpdateMasterServer(out CN); if (CN != null) { if (CN[0] == "CONNECT") { GameNI = new NetworkInterface(); State = MenuState.CONNECTING; GameIP = CN[1]; play.HideCancelButton(); } } }
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); }