コード例 #1
0
        internal override void Update(GameTime gameTime)
        {
            _playerVisible = GameboyInputs.SelectDown();

            if (!_playerVisible)
            {
                _nestFlickerDelay--;
                if (_nestFlickerDelay == 0)
                {
                    _nestFlickerDelay = NEST_FLICKER_DELAY;
                    _nestsVisible     = !_nestsVisible;
                }
            }

            if (GameboyInputs.APressed() || GameboyInputs.BPressed())
            {
                Close();
            }

            if (GameboyInputs.RightPressed() && _index == 0 && Controller.ActivePlayer.VisitedKanto)
            {
                _index = 1;
                LoadMapEntries();
            }
            else if (GameboyInputs.LeftPressed() && _index == 1)
            {
                _index = 0;
                LoadMapEntries();
            }
        }
コード例 #2
0
        internal override void Update(GameTime gameTime)
        {
            if (GameboyInputs.RightPressed())
            {
                _pageIndex++;
                if (_pageIndex == PAGE_COUNT)
                {
                    _pageIndex = 0;
                }
            }
            else if (GameboyInputs.LeftPressed())
            {
                _pageIndex--;
                if (_pageIndex == -1)
                {
                    _pageIndex = PAGE_COUNT - 1;
                }
            }
            else if (GameboyInputs.UpPressed())
            {
                var newPokemon = _previousPokemon();
                if (newPokemon != null)
                {
                    _pokemon = newPokemon;
                }
            }
            else if (GameboyInputs.DownPressed())
            {
                var newPokemon = _nextPokemon();
                if (newPokemon != null)
                {
                    _pokemon = newPokemon;
                }
            }

            if (GameboyInputs.APressed())
            {
                if (_pageIndex < PAGE_COUNT - 1)
                {
                    _pageIndex++;
                }
                else
                {
                    Close();
                }
            }
            else if (GameboyInputs.BPressed())
            {
                Close();
            }
        }
コード例 #3
0
        public void Update()
        {
            if (Visible)
            {
                if (GameboyInputs.UpPressed())
                {
                    _current++;
                    if (_current > _max)
                    {
                        _current = 1;
                    }
                }
                else if (GameboyInputs.DownPressed())
                {
                    _current--;
                    if (_current == 0)
                    {
                        _current = _max;
                    }
                }
                else if (GameboyInputs.RightPressed())
                {
                    _current += 10;
                    if (_current > _max)
                    {
                        _current = _max;
                    }
                }
                else if (GameboyInputs.LeftPressed())
                {
                    _current -= 10;
                    if (_current <= 0)
                    {
                        _current = 1;
                    }
                }

                if (GameboyInputs.APressed())
                {
                    AmountSelected?.Invoke(_current);
                    Close();
                }
                else if (GameboyInputs.BPressed())
                {
                    Dismissed?.Invoke();
                    Close();
                }
            }
        }
コード例 #4
0
        internal override void Update(GameTime gameTime)
        {
            if (GameboyInputs.RightPressed() && _index < Controller.ActivePlayer.UnownsCaught.Length - 1)
            {
                _index++;
            }
            else if (GameboyInputs.LeftPressed() && _index > 0)
            {
                _index--;
            }

            if (GameboyInputs.APressed() || GameboyInputs.BPressed())
            {
                Close();
            }
        }
コード例 #5
0
        internal override void Update(GameTime gameTime)
        {
            _timeColonDelay--;
            if (_timeColonDelay == 0)
            {
                _timeColonDelay   = TIME_COLON_SWITCH_DELAY;
                _timeColonVisible = !_timeColonVisible;
            }

            _badgeFlipDelay--;
            if (_badgeFlipDelay == 0)
            {
                _badgeFlipDelay = BADGE_FLIP_DELAY;
                _badgeFlipIndex++;
                if (_badgeFlipIndex == 4)
                {
                    _badgeFlipIndex = 0;
                }
            }

            if (GameboyInputs.APressed())
            {
                if (_pageIndex == 0)
                {
                    _pageIndex = 1;
                }
                else
                {
                    Close();
                }
            }
            else if (GameboyInputs.BPressed())
            {
                Close();
            }
            else if (_pageIndex == 0 && GameboyInputs.RightPressed())
            {
                _pageIndex = 1;
            }
            else if (_pageIndex == 1 && GameboyInputs.LeftPressed())
            {
                _pageIndex = 0;
            }
        }
コード例 #6
0
        internal override void Update(GameTime gameTime)
        {
            if (GameboyInputs.RightPressed())
            {
                ChangeOption(1);
                _optionsText = GetOptionsText();
            }
            else if (GameboyInputs.LeftPressed())
            {
                ChangeOption(-1);
                _optionsText = GetOptionsText();
            }

            if (GameboyInputs.DownPressed())
            {
                _index++;
                if (_index == OPTIONS_COUNT)
                {
                    _index = 0;
                }
                _optionsText = GetOptionsText();
            }
            if (GameboyInputs.UpPressed())
            {
                _index--;
                if (_index == -1)
                {
                    _index = OPTIONS_COUNT - 1;
                }
                _optionsText = GetOptionsText();
            }

            if (GameboyInputs.StartPressed() || GameboyInputs.BPressed() || (GameboyInputs.APressed() && _index == OPTIONS_COUNT - 1))
            {
                Close();
            }
        }
コード例 #7
0
 private void UpdateChangePage()
 {
     if (GameboyInputs.RightPressed())
     {
         _pageIndex++;
         if ((_pageIndex == 1 && !Controller.ActivePlayer.HasMapModule) ||
             (_pageIndex == 3 && !Controller.ActivePlayer.HasRadioModule))
         {
             _pageIndex = 2;
         }
         else if (_pageIndex == 4)
         {
             _pageIndex = 3;
         }
     }
     else if (GameboyInputs.LeftPressed())
     {
         _pageIndex--;
         if (_pageIndex == -1 || (_pageIndex == 1 && !Controller.ActivePlayer.HasMapModule))
         {
             _pageIndex = 0;
         }
     }
 }
コード例 #8
0
        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;
                }
            }
        }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
ファイル: MovesScreen.cs プロジェクト: nilllzz/pokemon-redux
        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();
                }
            }
        }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
        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;
                }
            }
        }
コード例 #13
0
        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();
            }
        }
コード例 #14
0
        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);
            }
        }