private void HandleMouseInput() { if (Xin.CheckMouseReleased(MouseButton.Left)) { Point mouse = Xin.MouseAsPoint; if (leftSide.Contains(mouse)) { selectedItem--; if (selectedItem < 0) { selectedItem = this.Items.Count - 1; } OnSelectionChanged(); } if (rightSide.Contains(mouse)) { selectedItem++; if (selectedItem >= items.Count) { selectedItem = 0; } OnSelectionChanged(); } } }
public override void Update(GameTime gameTime) { menuComponent.Update(gameTime); if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || (menuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left))) { if (menuComponent.SelectedIndex == 0) { Xin.FlushInput(); GameRef.GamePlayState.SetUpNewGame(); GameRef.GamePlayState.StartGame(); manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (menuComponent.SelectedIndex == 1) { Xin.FlushInput(); GameRef.GamePlayState.LoadExistingGame(); GameRef.GamePlayState.StartGame(); manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (menuComponent.SelectedIndex == 2) { Xin.FlushInput(); } else if (menuComponent.SelectedIndex == 3) { Game.Exit(); } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { menu.Update(gameTime); if (menu.MouseOver && Xin.CheckMouseReleased(MouseButton.Left)) { switch (menu.SelectedIndex) { case 0: IGamePlayState gamePlayState = (IGamePlayState)Game.Services.GetService( typeof(IGamePlayState)); gamePlayState.SetupNewGame(); manager.PushState((GameState)gamePlayState); break; case 1: break; case 2: manager.PushState(GameRef.OptionState); break; case 3: break; case 4: GameRef.Exit(); break; } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if ((Xin.CheckMouseReleased(MouseButton.Left) && mouseOver) || Xin.CheckKeyRelease(Keys.Enter)) { manager.ChangeState(GameRef.MainMenuState); } base.Update(gameTime); }
public override void Update(GameTime gameTime) { PlayerIndex?index = null; elapsed += gameTime.ElapsedGameTime; if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || Xin.CheckMouseReleased(MouseButtons.Left)) { manager.ChangeState((MainMenuState)GameRef.StartMenuState, index); } base.Update(gameTime); }
public override void Update(GameTime gameTime) { _elapsed += gameTime.ElapsedGameTime; if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || Xin.CheckMouseReleased(MouseButtons.Left)) { Manager.ChangeState(GameRef.StartMenuState, null); } base.Update(gameTime); }
public override void HandleInput() { Point position = Xin.MouseAsPoint; Vector2 scale = new Vector2( Settings.Resolution.X / 1280, Settings.Resolution.Y / 720); Rectangle destination = new Rectangle( (int)position.X, (int)position.Y, background.Width, background.Height).Scale(scale); if (destination.Contains(position) && Xin.CheckMouseReleased(MouseButton.Left)) { OnClick(); } }
public void Update(GameTime gameTime) { usernameInput.Update(gameTime); passwordInput.Update(gameTime); if (Xin.CheckKeyReleased(Keys.Tab)) { if (!usernameInput.IsFocussed && !passwordInput.IsFocussed) { usernameInput.IsFocussed = true; } else { bool tempUserFocussed = usernameInput.IsFocussed; usernameInput.IsFocussed = passwordInput.IsFocussed; passwordInput.IsFocussed = tempUserFocussed; } } else if (Xin.CheckMouseReleased(MouseButtons.Left) || Xin.CheckKeyReleased(Keys.Enter)) { usernameInput.IsFocussed = false; passwordInput.IsFocussed = false; if (usernameInput.Text.Length == 0 || passwordInput.Text.Length == 0) { errorMessage = "Please fill in your credentials."; } else { errorMessage = ""; GameRef.GameSocketClient.LoginMessageReceived += GameSocketClient_Login; GameRef.GameSocketClient.SendMessage(new ClassLibrary.Packets.Client.cLogin() { Username = usernameInput.Text, Password = passwordInput.Text }); } } }
public override void Update(GameTime gameTime) { _menuComponent.Update(gameTime); if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || (_menuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left))) { switch (_menuComponent.SelectedIndex) { case 0: Xin.FlushInput(); GameRef.GamePlayState.SetUpNewGame(); GameRef.GamePlayState.StartGame(); Manager.PushState(GameRef.GamePlayState, PlayerIndexInControl); break; case 1: Xin.FlushInput(); GameRef.GamePlayState.LoadExistingGame(); GameRef.GamePlayState.StartGame(); Manager.PushState(GameRef.GamePlayState, PlayerIndexInControl); break; case 2: Xin.FlushInput(); break; case 3: Game.Exit(); break; } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { switch (connectionState) { case ConnectionState.SERVER_SELECT: serverSelectionMenuComponent.Update(gameTime); if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || (serverSelectionMenuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left))) { if (serverSelectionMenuComponent.SelectedIndex == 0) { Xin.FlushInput(); ConnectToServer(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2013)); //GameRef.GamePlayState.SetUpNewGame(); //GameRef.GamePlayState.StartGame(); //manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (serverSelectionMenuComponent.SelectedIndex == 1) { Xin.FlushInput(); GameRef.SetWindowResolution(400, 300); //ConnectToServer(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2014)); //GameRef.GamePlayState.LoadExistingGame(); //GameRef.GamePlayState.StartGame(); //manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (serverSelectionMenuComponent.SelectedIndex == 2) { Game.Exit(); } } break; case ConnectionState.LOGIN: loginComponent.Update(gameTime); break; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { PlayerIndex index = PlayerIndex.One; // TODO elapsed += gameTime.ElapsedGameTime; menuComponent.Update(gameTime, index); this.player1pad = GamePad.GetState(PlayerIndex.One); if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || (menuComponent.MouseOver && Xin.CheckMouseReleased(MouseButtons.Left)) || this.player1pad.IsButtonDown(Buttons.A)) { buttonSelect.Play(); if (menuComponent.SelectedIndex == 0) // new single player game { Xin.FlushInput(); this.gameOptions.GameType = GameType.SinglePlayer; GameRef.GamePlayState.SetUpNewGame(this.gameOptions); GameRef.GamePlayState.StartGame(); manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (menuComponent.SelectedIndex == 1) // new 2 player cooperative game { Xin.FlushInput(); this.gameOptions.GameType = GameType.TwoPlayerCooperative; GameRef.GamePlayState.SetUpNewGame(this.gameOptions); GameRef.GamePlayState.StartGame(); manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (menuComponent.SelectedIndex == 2) // new 2 player deathmatch game { Xin.FlushInput(); this.gameOptions.GameType = GameType.TwoPlayerDeathmatch; GameRef.GamePlayState.SetUpNewGame(this.gameOptions); GameRef.GamePlayState.StartGame(); manager.PushState((GamePlayState)GameRef.GamePlayState, PlayerIndexInControl); } else if (menuComponent.SelectedIndex == 3) { Game.Exit(); } } base.Update(gameTime); }
public override void Update(GameTime gameTime) { PlayerIndex index = PlayerIndex.One; int i = 0; switch (_mode) { case MerchantMode.Talk: _conversation.Update(gameTime); if (Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index) || Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index)) { if (_conversation.CurrentScene.OptionAction.Action == ActionType.Buy) { _mode = MerchantMode.Buy; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.Sell) { _mode = MerchantMode.Sell; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.End) { _manager.PopState(); } } else if (Xin.CheckMouseReleased(MouseButton.Left) && _conversation.CurrentScene.IsMouseOver) { if (_conversation.CurrentScene.OptionAction.Action == ActionType.Buy) { _mode = MerchantMode.Buy; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.Sell) { _mode = MerchantMode.Sell; } if (_conversation.CurrentScene.OptionAction.Action == ActionType.End) { _manager.PopState(); } } break; case MerchantMode.Buy: if (Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index) || (Xin.CheckMouseReleased(MouseButton.Left) && mouseOver)) { if (_inventoryManager.ItemList[_selectedItem].Cost <= player.Gold) { player.AddItem(_selectedItem); player.UpdateGold(_inventoryManager.ItemList[_selectedItem].Cost * -1); player.Character.AddItem(_inventoryManager.ItemList[_selectedItem]); _inventory.RemoveItem(_selectedItem); foreach (string s in player.ActiveQuests.Keys) { if (player.ActiveQuests[s].CurrentStep.QuestStepType == QuestStepType.Buy && player.ActiveQuests[s].CurrentStep.Target == Enum.GetName(typeof(ItemCategory), _inventoryManager.ItemList[_selectedItem].ItemType)) { player.ActiveQuests[s].CurrentStep.Finish(); player.ActiveQuests[s].UpdateQuestStep(); } } } else { // show that the offer was refused } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.Back, Keys.Escape, out index) || Xin.CheckMouseReleased(MouseButton.Right)) { _mode = MerchantMode.Talk; } else if (!mouseOver) { if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickUp, Keys.Up, out index)) { _selectedIndex--; if (_selectedIndex < 0) { _selectedIndex = _inventory.Inventory.Count - 1; } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickDown, Keys.Down, out index)) { _selectedIndex++; if (_selectedIndex >= _inventory.Inventory.Count) { _selectedIndex = 0; } } } foreach (string s in _inventory.Inventory.Keys) { if (_selectedIndex == i) { _selectedItem = s; break; } i++; } break; case MerchantMode.Sell: if (Xin.WasReleased(PlayerIndexInControl, Buttons.A, Keys.Space, out index) || (Xin.CheckMouseReleased(MouseButton.Left) && mouseOver)) { player.RemoveItem(_selectedItem); player.UpdateGold(_inventoryManager.ItemList[_selectedItem].Cost / 2); _inventory.AddItem(_selectedItem); foreach (string s in player.ActiveQuests.Keys) { if (player.ActiveQuests[s].CurrentStep.QuestStepType == QuestStepType.Sell && player.ActiveQuests[s].CurrentStep.Target == Enum.GetName(typeof(ItemCategory), _inventoryManager.ItemList[_selectedItem].ItemType)) { player.ActiveQuests[s].CurrentStep.Finish(); player.ActiveQuests[s].UpdateQuestStep(); } } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.Back, Keys.Escape, out index) || Xin.CheckMouseReleased(MouseButton.Right)) { _mode = MerchantMode.Talk; } else if (!mouseOver) { if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickUp, Keys.Up, out index)) { _selectedIndex--; if (_selectedIndex < 0) { _selectedIndex = _inventory.Inventory.Count - 1; } } else if (Xin.WasReleased(PlayerIndexInControl, Buttons.LeftThumbstickDown, Keys.Down, out index)) { _selectedIndex++; if (_selectedIndex >= _inventory.Inventory.Count) { _selectedIndex = 0; } } } foreach (string s in player.Backpack.Keys) { if (_selectedIndex == i) { _selectedItem = s; break; } i++; } break; } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (!this.doneOnce) { Song song = GameRef.ContentBank.GetSong(Content.ContentItem.Sounds_Song_Level); MediaPlayer.Volume = 0.8f; MediaPlayer.IsRepeating = false; MediaPlayer.Play(song); this.doneOnce = true; } PlayerIndex?index = null; elapsed += gameTime.ElapsedGameTime; if (Xin.CheckKeyReleased(Keys.Space) || Xin.CheckKeyReleased(Keys.Enter) || Xin.CheckMouseReleased(MouseButtons.Left)) { manager.ChangeState((MainMenuState)GameRef.StartMenuState, index); } base.Update(gameTime); }