internal override void Update(GameTime gameTime) { _selectorDelay--; if (_selectorDelay == 0) { _selectorDelay = SELECTOR_FLICKER_DELAY; _selectorVisible = !_selectorVisible; } if (_iconFrames > 1) { _iconFrameDelay--; if (_iconFrameDelay == 0) { _iconFrameDelay = ICON_ANIMATION_DELAY; _iconFrame++; if (_iconFrame == _iconFrames) { _iconFrame = 0; } } } if (GameboyInputs.RightPressed()) { if (_menuActive) { _menuIndex++; // wrap around to the beginning of the line if (_menuIndex == MENU_OPTIONS_COUNT) { _menuIndex = 0; } } else { _charX++; // wrap around to the beginning of the line if (_charX == CHARS_PER_LINE) { _charX = 0; } } } else if (GameboyInputs.LeftPressed()) { if (_menuActive) { _menuIndex--; // wrap around to the end of the line if (_menuIndex == -1) { _menuIndex = MENU_OPTIONS_COUNT - 1; } } else { _charX--; // wrap around to the end of the line if (_charX == -1) { _charX = CHARS_PER_LINE - 1; } } } else if (GameboyInputs.DownPressed()) { if (_menuActive) { _charY = 0; if (MenuColumn != _menuIndex) { _charX = _menuIndex * 3; } _menuActive = false; } else { _charY++; if (_charY == ActiveCharset.Length / CHARS_PER_LINE) { _menuActive = true; _menuIndex = MenuColumn; } } } else if (GameboyInputs.UpPressed()) { if (_menuActive) { _charY = ActiveCharset.Length / CHARS_PER_LINE - 1; if (MenuColumn != _menuIndex) { _charX = _menuIndex * 3; } _menuActive = false; } else { _charY--; if (_charY == -1) { _menuActive = true; _menuIndex = MenuColumn; } } } if (GameboyInputs.BPressed()) { BackspaceName(); } else if (GameboyInputs.APressed()) { if (_menuActive) { switch (_menuIndex) { case 0: // upper/lower switch _isLower = !_isLower; break; case 1: // DEL BackspaceName(); break; case 2: // END Close(); break; } } else { var nameLength = PokemonFontRenderer.PrintableCharAmount(_name); if (nameLength < _maxLength) { var activeChar = ActiveCharset[_charX + _charY * CHARS_PER_LINE]; _name += activeChar; nameLength = PokemonFontRenderer.PrintableCharAmount(_name); if (nameLength == _maxLength) { // select END button _menuActive = true; _menuIndex = 2; } } } } else if (GameboyInputs.StartPressed()) { // select END button _menuActive = true; _menuIndex = 2; } else if (GameboyInputs.SelectPressed()) { // switch upper/lower _isLower = !_isLower; } }
internal override void Update(GameTime gameTime) { if (_menuState == BattleMenuState.Main) { if (StartMultiTurnMove()) { return; } if (GameboyInputs.RightPressed() && _mainMenuIndex % 2 == 0) { _mainMenuIndex++; } else if (GameboyInputs.LeftPressed() && _mainMenuIndex % 2 == 1) { _mainMenuIndex--; } else if (GameboyInputs.DownPressed() && _mainMenuIndex < 2) { _mainMenuIndex += 2; } else if (GameboyInputs.UpPressed() && _mainMenuIndex > 1) { _mainMenuIndex -= 2; } if (GameboyInputs.APressed()) { switch (_mainMenuIndex) { case 0: // FIGHT // TODO: struggle _menuState = BattleMenuState.Fight; // after switching pokemon, the cursor for move selection might be in an invalid position if (_moveMenuIndex >= Battle.ActiveBattle.PlayerPokemon.Pokemon.Moves.Length) { _moveMenuIndex = 0; } break; case 1: // PKMN { var partyScreen = new PartyScreen(this, Battle.ActiveBattle.PlayerPokemon.Pokemon, false); partyScreen.LoadContent(); partyScreen.SelectedPokemon += SelectedPokemonForSwitch; GetComponent <ScreenManager>().SetScreen(partyScreen); } break; // TODO: inventory case 3: // RUN // TODO: trainer battles // TODO: trapping moves like BIND _menuState = BattleMenuState.Off; Battle.ActiveBattle.StartRound(new BattleAction { ActionType = BattleActionType.Run }); break; } } } else if (_menuState == BattleMenuState.Fight) { if (GameboyInputs.DownPressed()) { _moveMenuIndex++; if (_moveMenuIndex == Battle.ActiveBattle.PlayerPokemon.Pokemon.Moves.Length) { _moveMenuIndex = 0; } } else if (GameboyInputs.UpPressed()) { _moveMenuIndex--; if (_moveMenuIndex == -1) { _moveMenuIndex = Battle.ActiveBattle.PlayerPokemon.Pokemon.Moves.Length - 1; } } if (GameboyInputs.APressed()) { _menuState = BattleMenuState.Off; Battle.ActiveBattle.StartRound(new BattleAction { ActionType = BattleActionType.Move, MoveName = Battle.ActiveBattle.PlayerPokemon.Pokemon.Moves[_moveMenuIndex].name }); } else if (GameboyInputs.BPressed()) { _menuState = BattleMenuState.Main; } } else { if (!_keepTextboxOpen) { _battleTextbox.Update(); } else { if (_framesBeforeContinuing > 0) { _framesBeforeContinuing--; } } _enemyPokemonStatus.Update(); _playerPokemonStatus.Update(); _pokemonStats.Update(); lock (_animations) { foreach (var animation in _animations) { if (!animation.IsFinished) { if (animation.WaitDelay > 0) { animation.WaitDelay--; } else { animation.Update(); } } } } } if (_fadeOut) { _fadeOutProgress += FADE_OUT_SPEED; if (_fadeOutProgress >= 1f) { _fadeOutProgress = 1f; } } }
private void UpdatePhonePage() { if (!_phoneOptionsBox.Visible && !_deleteNumberOptionsBox.Visible) { if (GameboyInputs.DownPressed()) { if (_phoneIndex < CONTACTS_VISIBLE - 1) { _phoneIndex++; } else if (_phoneScroll < MAX_PHONE_CONTACTS - CONTACTS_VISIBLE) { _phoneScroll++; } } else if (GameboyInputs.UpPressed()) { if (_phoneIndex > 0) { _phoneIndex--; } else if (_phoneScroll > 0) { _phoneScroll--; } } if (GameboyInputs.APressed()) { if (Controller.ActivePlayer.Contacts.Length > _phoneIndex + _phoneScroll) { var contact = _phonebook.GetContact(Controller.ActivePlayer.Contacts[_phoneIndex + _phoneScroll]); if (contact.important) { _phoneOptionsBox.Show(new[] { "CALL", "CANCEL" }); } else { _phoneOptionsBox.Show(new[] { "CALL", "DELETE", "CANCEL" }); } _phoneOptionsBox.OptionSelected += CallOptionsSelected; } } else if (GameboyInputs.BPressed()) { Close(); } else { UpdateChangePage(); } } else if (_deleteNumberOptionsBox.Visible) { _deleteNumberOptionsBox.Update(); } else if (_phoneOptionsBox.Visible) { _phoneOptionsBox.Update(); } }
internal override void Update(GameTime gameTime) { _selectorFlickerDelay--; if (_selectorFlickerDelay == 0) { _selectorFlickerDelay = SELECTOR_FLICKER_DELAY; _selectorVisible = !_selectorVisible; } if (GameboyInputs.DownPressed() && _index < _options.Length - 1) { _index++; } else if (GameboyInputs.UpPressed() && _index > 0) { _index--; } if (GameboyInputs.BPressed()) { // return to previous screen without change GetComponent <ScreenManager>().SetScreen(_prePokedexScreen); } else if (GameboyInputs.APressed()) { var newListMode = (PokedexListMode)_index; if (newListMode == _prePokedexScreen.ListMode) // no change to list mode { // return to previous screen without change GetComponent <ScreenManager>().SetScreen(_prePokedexScreen); } else { // change loaded regional screen instead of setting a new one: if (newListMode == PokedexListMode.Regional && _prePokedexScreen.ListMode == PokedexListMode.AtoZ) { (_prePokedexScreen as RegionalPokedexListScreen).SetListMode(PokedexListMode.Regional); GetComponent <ScreenManager>().SetScreen(_prePokedexScreen); } else if (newListMode == PokedexListMode.AtoZ && _prePokedexScreen.ListMode == PokedexListMode.Regional) { (_prePokedexScreen as RegionalPokedexListScreen).SetListMode(PokedexListMode.AtoZ); GetComponent <ScreenManager>().SetScreen(_prePokedexScreen); } else { // load new screen Screen newScreen = null; switch (newListMode) { case PokedexListMode.Regional: newScreen = new RegionalPokedexListScreen(_preScreen, PokedexListMode.Regional); break; case PokedexListMode.National: newScreen = new NationalPokedexListScreen(_preScreen); break; case PokedexListMode.AtoZ: newScreen = new RegionalPokedexListScreen(_preScreen, PokedexListMode.AtoZ); break; case PokedexListMode.Unown: newScreen = new PokedexUnownScreen(this); break; } newScreen.LoadContent(); GetComponent <ScreenManager>().SetScreen(newScreen); } } } }
internal override void Update(GameTime gameTime) { _animationDelay--; if (_animationDelay == 0) { _animationDelay = ANIMATION_DELAY; _animationIndex++; if (_animationIndex == 2) { _animationIndex = 0; } } if (GameboyInputs.LeftPressed() && !_isOrdering && _partyIndex > 0) { _partyIndex--; _moveIndex = 0; ChangedPartyIndex?.Invoke(_partyIndex); } else if (GameboyInputs.RightPressed() && !_isOrdering && _partyIndex < Controller.ActivePlayer.PartyPokemon.Length - 1) { _partyIndex++; _moveIndex = 0; ChangedPartyIndex?.Invoke(_partyIndex); } else if (GameboyInputs.UpPressed() && _moveIndex > 0) { _moveIndex--; } else if (GameboyInputs.DownPressed() && _moveIndex < Pokemon.Moves.Length - 1) { _moveIndex++; } if (GameboyInputs.APressed()) { if (_isOrdering) { if (_orderMoveIndex != _moveIndex) { Pokemon.SwapMoves(_moveIndex, _orderMoveIndex); } _isOrdering = false; } else { _isOrdering = true; _orderMoveIndex = _moveIndex; } } else if (GameboyInputs.BPressed()) { if (_isOrdering) { _isOrdering = false; } else { Close(); } } }
internal override void Update(GameTime gameTime) { _selectorFlickerDelay--; if (_selectorFlickerDelay == 0) { _selectorFlickerDelay = SELECTOR_FLICKER_DELAY; _selectorVisible = !_selectorVisible; } if (GameboyInputs.RightPressed() && _cursorIndex + 1 < OPTIONS.Length) { _cursorIndex++; } else if (GameboyInputs.LeftPressed() && _cursorIndex > 0) { _cursorIndex--; } else if (GameboyInputs.UpPressed()) { var newEntry = _getPreviousEntry(); if (newEntry != null) { _entry = newEntry; _cursorIndex = 0; // set cursor to PAGE _pageIndex = 0; InitializeEntry(); } } else if (GameboyInputs.DownPressed()) { var newEntry = _getNextEntry(); if (newEntry != null) { _entry = newEntry; _cursorIndex = 0; // set cursor to PAGE _pageIndex = 0; InitializeEntry(); } } if (GameboyInputs.APressed()) { switch (_cursorIndex) { case 0: // PAGE _pageIndex++; if (_pageIndex == _pages.Length) { _pageIndex = 0; } break; case 1: // AREA var nestScreen = new PokedexNestScreen(this, _entry); nestScreen.LoadContent(); GetComponent <ScreenManager>().SetScreen(nestScreen); break; case 2: // CRY // TODO: play cry break; case 3: // BACK Close(); break; } } else if (GameboyInputs.BPressed()) { Close(); } }
internal override void Update(GameTime gameTime) { // when visible, only update the no results message if (_noResultsDelay > 0) { _noResultsDelay--; return; } _selectorFlickerDelay--; if (_selectorFlickerDelay == 0) { _selectorFlickerDelay = SELECTOR_FLICKER_DELAY; _selectorVisible = !_selectorVisible; } if (GameboyInputs.DownPressed() && _index < 3) { _index++; } else if (GameboyInputs.UpPressed() && _index > 0) { _index--; } else if (GameboyInputs.RightPressed()) { switch (_index) { case 0: _type1Index++; if (_type1Index == _type1Options.Length) { _type1Index = 0; } break; case 1: _type2Index++; if (_type2Index == _type2Options.Length) { _type2Index = 0; } break; } } else if (GameboyInputs.LeftPressed()) { switch (_index) { case 0: _type1Index--; if (_type1Index == -1) { _type1Index = _type1Options.Length - 1; } break; case 1: _type2Index--; if (_type2Index == -1) { _type2Index = _type2Options.Length - 1; } break; } } if (GameboyInputs.BPressed()) { GetComponent <ScreenManager>().SetScreen(_prePokedexScreen); } else if (GameboyInputs.APressed()) { switch (_index) { case 0: _type1Index++; if (_type1Index == _type1Options.Length) { _type1Index = 0; } break; case 1: _type2Index++; if (_type2Index == _type2Options.Length) { _type2Index = 0; } break; case 2: ConfirmSearch(); break; case 3: GetComponent <ScreenManager>().SetScreen(_prePokedexScreen); break; } } }
internal override void Update(GameTime gameTime) { // wait for message to disappear if (_messageDelay > 0) { _messageDelay--; if (_messageDelay == 0) { MessageFinished?.Invoke(); } return; } if (!DialogVisible) { if (GameboyInputs.DownPressed() && _index + _scrollIndex < _pokemon.Length) { _index++; if (_index == VISIBLE_POKEMON) { _index--; _scrollIndex++; if (_scrollIndex + _index == _pokemon.Length + 1) // +1 because 'cancel' { _scrollIndex--; } } } else if (GameboyInputs.UpPressed() && _index + _scrollIndex > 0) { _index--; if (_index == -1) { _index++; _scrollIndex--; if (_scrollIndex == -1) { _scrollIndex++; } } } else if (GameboyInputs.LeftPressed()) { LeftPressed(); } else if (GameboyInputs.RightPressed()) { RightPressed(); } if (GameboyInputs.APressed()) { if (_isMoving) { ConfirmMovePokemon(); } else { if (_pokemon.Length > _index + _scrollIndex) { _message = MESSAGE_WHATSUP; OpenOptionsMenu(); } else { // cancel option Close(); } } } else if (GameboyInputs.BPressed()) { if (_isMoving) { CancelMovePokemon(); } else { Close(); } } } else if (_confirmationBox.Visible) { _confirmationBox.Update(); } else if (_optionsBox.Visible) { _optionsBox.Update(); } }
internal override void Update(GameTime gameTime) { if (GameboyInputs.DownPressed()) { if (_index + _scrollIndex + 1 < _entries.Length) { if (_index < VisibleEntries - 1) { _index++; } else { _scrollIndex++; } } } else if (GameboyInputs.UpPressed()) { if (_index > 0) { _index--; } else if (_scrollIndex > 0) { _scrollIndex--; } } else if (GameboyInputs.LeftPressed()) { _scrollIndex -= 7; if (_scrollIndex < 0) { _scrollIndex = 0; } } else if (GameboyInputs.RightPressed()) { _scrollIndex += 7; if (_scrollIndex + VisibleEntries > _entries.Length) { _scrollIndex = _entries.Length - VisibleEntries; } } var stackEntryIsComplete = false; for (var i = 0; i < _entryStack.Count; i++) { _spriteAnimationStack[i] += 0.2; if (_spriteAnimationStack[i] >= 1.0) { if (stackEntryIsComplete) { _spriteAnimationStack.RemoveAt(i); _entryStack.RemoveAt(i); i--; } else { stackEntryIsComplete = true; _spriteAnimationStack[i] = 1.0; } } } if (GameboyInputs.APressed()) { var selectedEntry = _entries[_scrollIndex + _index]; if (selectedEntry.IsKnown) { // open details screen var screenManager = GetComponent <ScreenManager>(); var detailsScreen = new PokedexDetailsScreen(this, selectedEntry, GetNextEntry, GetPreviousEntry); detailsScreen.LoadContent(); screenManager.SetScreen(detailsScreen); } } else if (GameboyInputs.BPressed()) { Close(); } else if (GameboyInputs.SelectPressed()) { // open options screen var screenManager = GetComponent <ScreenManager>(); var optionsScreen = new PokedexOptionScreen(_preScreen, this); optionsScreen.LoadContent(); screenManager.SetScreen(optionsScreen); } else if (GameboyInputs.StartPressed()) { // open search screen var screenManager = GetComponent <ScreenManager>(); var searchScreen = new PokedexSearchScreen(_preScreen, this, ListMode); searchScreen.LoadContent(); screenManager.SetScreen(searchScreen); } }