コード例 #1
0
ファイル: Save.cs プロジェクト: Kermalis/PokemonGameEngine
        public void Debug_Create()
        {
            GameStats       = new GameStats();
            Pokedex         = new Pokedex();
            Flags           = new Flags();
            Vars            = new Vars();
            OT              = new OTInfo("Dawn", true);
            PlayerInventory = Inventory <InventorySlotNew> .CreatePlayerInventory();

            PlayerInventory.Add(ItemType.DuskBall, 995);
            PlayerInventory.Add(ItemType.RockyHelmet, 42);
            PlayerInventory.Add(ItemType.Leftovers, 473);
            PlayerInventory.Add(ItemType.Potion, 123);
            PlayerInventory.Add(ItemType.RedScarf, 230);
            PlayerInventory.Add(ItemType.PokeDoll, 130);
            PlayerInventory.Add(ItemType.XSpDef, 120);
            PlayerInventory.Add(ItemType.AirBalloon, 407);
            PlayerInventory.Add(ItemType.PokeBall, 73);
            PlayerInventory.Add(ItemType.DarkGem, 69);
            PlayerInventory.Add(ItemType.FluffyTail, 888);
            PlayerInventory.Add(ItemType.OvalCharm, 1);
            PlayerInventory.Add(ItemType.ShinyCharm, 1);
            ItemData.Debug_GiveAllTMHMs(PlayerInventory);
            Money = 473_123;
            InitPlayerWithDefaultLocation();
            PCBoxes = new PCBoxes();
            Daycare = new Daycare();
            Daycare.StorePokemon(PartyPokemon.CreatePlayerOwnedMon(PBESpecies.Blissey, 0, 47));
            Daycare.StorePokemon(PartyPokemon.CreatePlayerOwnedMon(PBESpecies.Ditto, 0, 82));
            PlayerParty = new Party();
            {
                // To test evolution
                var evomon = PartyPokemon.CreatePlayerOwnedMon(PBESpecies.Burmy, PBEForm.Burmy_Trash, 19);
                evomon.Item = ItemType.Leftovers;
                evomon.EXP  = PBEEXPTables.GetEXPRequired(BaseStats.Get(evomon.Species, evomon.Form, true).GrowthRate, 20) - 1;
                GivePokemon(evomon);
                // To pummel
                var victini = PartyPokemon.CreatePlayerOwnedMon(PBESpecies.Victini, 0, 67);
                victini.Ability         = PBEAbility.Compoundeyes;
                victini.Item            = ItemType.Leftovers;
                victini.Status1         = PBEStatus1.BadlyPoisoned;
                victini.Moveset[0].Move = PBEMove.Bounce;
                victini.Moveset[1].Move = PBEMove.ZenHeadbutt;
                victini.Moveset[2].Move = PBEMove.Surf;
                victini.Moveset[3].Move = PBEMove.VCreate;
                GivePokemon(victini);
            }
            for (int i = 0; i < 44; i++)
            {
                Debug_GiveRandomPokemon(i == 0 || i == 1 || i == 35);
            }

            Overworld.UpdateGiratinaForms(); // Not really necessary, including for debug though
        }
コード例 #2
0
        private void GivePokemonFormItemCommand()
        {
            PBESpecies species = ReadVarOrEnum <PBESpecies>();
            PBEForm    form    = ReadVarOrEnum <PBEForm>();
            byte       level   = (byte)ReadVarOrValue();
            ItemType   item    = ReadVarOrEnum <ItemType>();
            var        pkmn    = PartyPokemon.CreatePlayerOwnedMon(species, form, level);

            pkmn.Item = item;
            Game.Instance.Save.GivePokemon(pkmn);
        }
コード例 #3
0
ファイル: Save.cs プロジェクト: Tulu473/PokemonGameEngine
 public Save()
 {
     Flags          = new Flags();
     PlayerName     = "Dawn";
     PlayerIsFemale = true;
     PlayerParty    = new Party()
     {
         PartyPokemon.GetTestPokemon(PBESpecies.Skitty, 0, PBESettings.DefaultMaxLevel)
     };
     PlayerInventory = new PlayerInventory();
 }
コード例 #4
0
        private void GivePokemonFormItemCommand()
        {
            PBESpecies species = _reader.ReadEnum <PBESpecies>();
            PBEForm    form    = _reader.ReadEnum <PBEForm>();
            byte       level   = _reader.ReadByte();
            PBEItem    item    = _reader.ReadEnum <PBEItem>();
            var        pkmn    = PartyPokemon.GetTestPokemon(species, form, level);

            pkmn.Item = item;
            Game.Instance.Save.GivePokemon(pkmn);
        }
コード例 #5
0
 public unsafe EvolutionGUI(PartyPokemon pkmn, EvolutionData.EvoData evo)
 {
     _pkmn        = pkmn;
     _evo         = evo;
     _oldNickname = pkmn.Nickname;
     _canCancel   = Evolution.CanCancelEvolution(evo.Method);
     LoadPkmnImage();
     _state          = State.FadeIn;
     _fadeTransition = new FadeFromColorTransition(500, 0);
     Game.Instance.SetCallback(CB_Evolution);
     Game.Instance.SetRCallback(RCB_Evolution);
 }
コード例 #6
0
ファイル: Pokemon.cs プロジェクト: SamNilsson172/PokemonAPI
    public bool Attack(int move, PartyPokemon defender, float effectivness)
    {
        int?dmg = moves[move].Use();

        if (dmg != null) //if all the moves pp is used up
        {
            defender.CurrentHp -= ((float)dmg + CurrentAtk / defender.CurrentDef) * effectivness;
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #7
0
 public PartyGUIMember(PartyPokemon pkmn, SpriteList sprites)
 {
     _usePartyPkmn = true;
     _partyPkmn    = pkmn;
     _color        = GetColor();
     _mini         = new Sprite()
     {
         Image    = PokemonImageUtils.GetMini(pkmn.Species, pkmn.Form, pkmn.Gender, pkmn.Shiny, pkmn.IsEgg),
         Y        = Sprite_BounceDefY,
         Callback = Sprite_Bounce,
         Data     = new Sprite_BounceData()
     };
     sprites.Add(_mini);
     _background = new Image((UI.Program.RenderWidth / 2) - (UI.Program.RenderWidth / 20), (UI.Program.RenderHeight / 4) - (UI.Program.RenderHeight / 20));
     UpdateBackground();
 }
コード例 #8
0
        private void AddFieldMovesToActions(PartyPokemon pkmn, int index)
        {
            void Add(PBEMove move, Action command)
            {
                string str = PBELocalizedString.GetMoveName(move).English;

                _textChoices.Add(new TextGUIChoice(str, command, fontColors: Font.DefaultBlue_I));
            }

            Moveset moves = pkmn.Moveset;

            if (moves.Contains(PBEMove.Surf))
            {
                Add(PBEMove.Surf, () => Action_FieldSurf(index));
            }
        }
コード例 #9
0
 public void UpdateToParty(bool shouldCheckEvolution)
 {
     for (int i = 0; i < Party.Count; i++)
     {
         PartyPokemon pp       = Party[i];
         byte         oldLevel = pp.Level;
         pp.UpdateFromBattle(SpritedParty[i].Pkmn);
         if (shouldCheckEvolution && oldLevel != pp.Level)
         {
             EvolutionData.EvoData evo = Evolution.GetLevelUpEvolution(Party, pp);
             if (evo != null)
             {
                 Evolution.AddPendingEvolution(pp, evo);
             }
         }
     }
 }
コード例 #10
0
 public SpritedBattlePokemon(PBEBattlePokemon pkmn, PartyPokemon pPkmn, bool backImage, bool useKnownInfo, PkmnPosition wildPos)
 {
     PartyPkmn     = pPkmn;
     Pkmn          = pkmn;
     DisguisedPID  = pPkmn.PID; // By default, use our own PID (for example, wild disguised pkmn)
     _backImage    = backImage;
     _useKnownInfo = useKnownInfo;
     InfoBarImg    = new Image(100, useKnownInfo ? 30 : 42);
     UpdateInfoBar();
     UpdateSprites(wildPos, wildPos is null);
     UpdateAnimationSpeed(); // Ensure the proper speed is set upon entering battle
     if (wildPos != null)
     {
         wildPos.InfoVisible = false;
         wildPos.PkmnVisible = true;
         wildPos.SPkmn       = this;
     }
 }
コード例 #11
0
ファイル: Save.cs プロジェクト: Kermalis/PokemonGameEngine
        private void Debug_GiveRandomPokemon(bool egg)
        {
            (PBESpecies species, PBEForm form) = PBEDataProvider.GlobalRandom.RandomSpecies(true);
            PartyPokemon pkmn;

            if (egg)
            {
                pkmn = PartyPokemon.CreateDefaultEgg(species, form);
            }
            else
            {
                byte level = (byte)PBEDataProvider.GlobalRandom.RandomInt(PkmnConstants.MinLevel, PkmnConstants.MaxLevel);
                pkmn      = PartyPokemon.CreatePlayerOwnedMon(species, form, level);
                pkmn.Item = (ItemType)PBEDataProvider.GlobalRandom.RandomElement(PBEDataUtils.GetValidItems(pkmn.Species, pkmn.Form));
                pkmn.Debug_RandomizeMoves();
            }
            GivePokemon(pkmn);
        }
コード例 #12
0
        public static bool GetNonEggPartyMonWithMove(PBEMove move, out PartyPokemon pkmn, out int index)
        {
            Party party = Game.Instance.Save.PlayerParty;

            for (int i = 0; i < party.Count; i++)
            {
                PartyPokemon p = party[i];
                if (!p.IsEgg && p.Moveset.Contains(move))
                {
                    pkmn  = p;
                    index = i;
                    return(true);
                }
            }
            pkmn  = null;
            index = -1;
            return(false);
        }
コード例 #13
0
        private unsafe void DrawBackground(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            RenderUtils.OverwriteRectangle(bmpAddress, bmpWidth, bmpHeight, _color);
            // Shadow
            RenderUtils.FillEllipse_Points(bmpAddress, bmpWidth, bmpHeight, 3, 34, 29, 39, RenderUtils.Color(0, 0, 0, 100));
            // Nickname
            PartyPokemon p = _usePartyPkmn ? _partyPkmn : _battlePkmn.PartyPkmn;

            Font.DefaultSmall.DrawString(bmpAddress, bmpWidth, bmpHeight, 2, 3, p.Nickname, Font.DefaultWhite_I);
            if (p.IsEgg)
            {
                return;
            }
            PBEBattlePokemon bPkmn = _usePartyPkmn ? null : _battlePkmn.Pkmn;
            // Gender
            PBEGender gender = p.Gender;

            if (gender != PBEGender.Genderless)
            {
                Font.Default.DrawString(bmpAddress, bmpWidth, bmpHeight, 61, -2, gender.ToSymbol(), gender == PBEGender.Male ? Font.DefaultBlue_O : Font.DefaultRed_O);
            }
            // Level
            const int lvX = 72;

            Font.PartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, lvX, 3, "[LV]", Font.DefaultWhite_I);
            Font.PartyNumbers.DrawString(bmpAddress, bmpWidth, bmpHeight, lvX + 12, 3, (_usePartyPkmn ? p.Level : bPkmn.Level).ToString(), Font.DefaultWhite_I);
            // Status
            PBEStatus1 status = _usePartyPkmn ? p.Status1 : bPkmn.Status1;

            if (status != PBEStatus1.None)
            {
                Font.DefaultSmall.DrawString(bmpAddress, bmpWidth, bmpHeight, 61, 13, status.ToString(), Font.DefaultWhite_I);
            }
            // Item
            ItemType item = _usePartyPkmn ? p.Item : (ItemType)bPkmn.Item;

            if (item != ItemType.None)
            {
                Font.DefaultSmall.DrawString(bmpAddress, bmpWidth, bmpHeight, 61, 23, ItemData.GetItemName(item), Font.DefaultWhite_I);
            }
        }
コード例 #14
0
        private void PlayPkmnCry()
        {
            PBESpecies species;
            PBEForm    form;
            double     hpPercentage;

            if (_pPkmn is not null)
            {
                if (_pPkmn.IsEgg)
                {
                    return;
                }
                species      = _pPkmn.Species;
                form         = _pPkmn.Form;
                hpPercentage = _pPkmn.HP / _pPkmn.MaxHP;
            }
            else if (_pcPkmn is not null)
            {
                if (_pcPkmn.IsEgg)
                {
                    return;
                }
                species      = _pcPkmn.Species;
                form         = _pcPkmn.Form;
                hpPercentage = 1;
            }
            else
            {
                PartyPokemon pPkmn = _bPkmn.PartyPkmn;
                if (pPkmn.IsEgg)
                {
                    return;
                }
                PBEBattlePokemon bPkmn = _bPkmn.Pkmn;
                species      = pPkmn.Species;
                form         = bPkmn.RevertForm;
                hpPercentage = bPkmn.HPPercentage;
            }
            SoundControl.PlayCry(species, form, hpPercentage);
        }
コード例 #15
0
        private void LoadPkmnImage()
        {
            PBESpecies species;
            PBEForm    form;
            PBEGender  gender;
            bool       shiny;
            uint       pid;
            bool       egg;

            if (_pPkmn is not null)
            {
                species = _pPkmn.Species;
                form    = _pPkmn.Form;
                gender  = _pPkmn.Gender;
                shiny   = _pPkmn.Shiny;
                pid     = _pPkmn.PID;
                egg     = _pPkmn.IsEgg;
            }
            else if (_pcPkmn is not null)
            {
                species = _pcPkmn.Species;
                form    = _pcPkmn.Form;
                gender  = _pcPkmn.Gender;
                shiny   = _pcPkmn.Shiny;
                pid     = _pcPkmn.PID;
                egg     = _pcPkmn.IsEgg;
            }
            else
            {
                PartyPokemon     pPkmn = _bPkmn.PartyPkmn;
                PBEBattlePokemon bPkmn = _bPkmn.Pkmn;
                species = pPkmn.Species;
                form    = bPkmn.RevertForm;
                gender  = pPkmn.Gender;
                shiny   = pPkmn.Shiny;
                pid     = pPkmn.PID;
                egg     = pPkmn.IsEgg;
            }
            _pkmnImage = PokemonImageUtils.GetPokemonImage(species, form, gender, shiny, false, false, pid, egg);
        }
コード例 #16
0
    void Check()
    {
        state = (int)State.wait;
        float totOpponentHp = 0;

        foreach (PartyPokemon p in Party.opponentParty) //see if opponent has any pokemon with hp left
        {
            totOpponentHp += p.CurrentHp;
            if (p.CurrentHp > 0) //if it dose set active pokemon to it
            {
                opponentPokemon = p;
            }
        }
        if (totOpponentHp <= 0) //if not end fight
        {
            waitTime       = 1;
            eventText.text = "Player won";
            nextState      = (int)State.end;
        }

        float totPlayerHp = 0;

        foreach (PartyPokemon p in Party.playerParty)
        {
            totPlayerHp += p.CurrentHp;
            if (p.CurrentHp > 0)
            {
                playerPokemon = p;
            }
        }
        if (totPlayerHp <= 0)
        {
            waitTime       = 1;
            eventText.text = "Opponent won";
            nextState      = (int)State.end;
        }
        updateUI.UIUpdate(playerPokemon, opponentPokemon); //update UI here because it feels logical
    }
コード例 #17
0
ファイル: SaveGame.cs プロジェクト: JoNMii/Pokemon3D
        /// <summary>
        /// Loads required data once the <see cref="GameMode"/> is loaded.
        /// </summary>
        /// <param name="gameMode">The GameMode that this save game is linked to.</param>
        public void Load(GameMode gameMode)
        {
            _gameMode = gameMode;

            _loadedItems    = 0;
            _loadingCounter = 0;

            if (_dataModel.Pokemon == null)
            {
                _dataModel.Pokemon = new PokemonSaveModel[] { }
            }
            ;

            _loadingCounter += _dataModel.Pokemon.Length;

            foreach (var pokemon in _dataModel.Pokemon)
            {
                var p = _gameMode.PokemonFactory.GetPokemon(pokemon);
                _loadedItems++;
                PartyPokemon.Add(p);
            }
        }
    }
コード例 #18
0
        public unsafe SummaryGUI(object pkmn, Mode mode, Action onClosed, PBEMove learningMove = PBEMove.None)
        {
            _mode = mode;
            if (mode == Mode.LearnMove)
            {
                SetSelectionVar(-1);
                _page          = Page.Moves;
                _selectingMove = 0;
                _learningMove  = learningMove;
            }
            else
            {
                _page = Page.Info;
            }

            _pageImage = new Image((int)(Program.RenderWidth * PageImageWidth), (int)(Program.RenderHeight * PageImageHeight));

            if (pkmn is PartyPokemon pPkmn)
            {
                _pPkmn = pPkmn;
            }
            else if (pkmn is BoxPokemon pcPkmn)
            {
                _pcPkmn = pcPkmn;
            }
            else
            {
                _bPkmn = (SpritedBattlePokemon)pkmn;
            }
            LoadPkmnImage();
            UpdatePageImage();

            _onClosed       = onClosed;
            _fadeTransition = new FadeFromColorTransition(500, 0);
            Game.Instance.SetCallback(CB_FadeInSummary);
            Game.Instance.SetRCallback(RCB_Fading);
        }
コード例 #19
0
ファイル: Save.cs プロジェクト: Tulu473/PokemonGameEngine
 // TODO: If party is full, send to a box, if boxes are full, error
 public void GivePokemon(PartyPokemon pkmn)
 {
     PlayerParty.Add(pkmn);
 }
コード例 #20
0
        private unsafe void DrawStatsPage(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            const float winX            = 0.03f;
            const float winY            = 0.15f;
            const float winW            = 0.97f - winX;
            const float winH            = 0.995f - winY;
            const float leftColX        = winX + 0.02f;
            const float rightColX       = winX + 0.52f;
            const float rightColY       = winY + 0.02f;
            const float rightColW       = 0.95f - rightColX;
            const float rightColH       = 0.535f;
            const float rightColCenterX = rightColX + (rightColW / 2f);
            const float textStartY      = rightColY + 0.01f;
            const float textStart2Y     = rightColY + 0.13f;
            const float textSpacingY    = 0.08f;
            const float abilTextY       = textStart2Y + (5.5f * textSpacingY);
            const float abilDescX       = leftColX + 0.03f;
            const float abilDescY       = textStart2Y + (6.6f * textSpacingY);
            const float abilX           = winX + 0.18f;
            const float abilTextX       = abilX + 0.03f;
            const float abilY           = abilTextY;
            const float abilW           = 0.95f - abilX;
            const float abilH           = 0.075f;
            int         hpW             = (int)(bmpWidth * 0.3f);
            int         hpX             = RenderUtils.GetCoordinatesForCentering(bmpWidth, hpW, rightColCenterX);
            int         hpY             = (int)(bmpHeight * (rightColY + 0.09f));

            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, winX, winY, winX + winW, winY + winH, 12, RenderUtils.Color(135, 145, 250, 255));
            // Stats
            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, rightColX, rightColY, rightColX + rightColW, rightColY + rightColH, 8, RenderUtils.Color(210, 210, 210, 255));
            // Abil
            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, abilX, abilY, abilX + abilW, abilY + abilH, 5, RenderUtils.Color(210, 210, 210, 255));
            // Abil desc
            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, leftColX, abilDescY, 0.95f, 0.98f, 5, RenderUtils.Color(210, 210, 210, 255));

            Font leftColFont = Font.Default;

            uint[] leftColColors = Font.DefaultWhite_DarkerOutline_I;
            Font   rightColFont  = Font.Default;

            uint[] rightColColors = Font.DefaultBlack_I;
            uint[] boostedColors  = Font.DefaultRed_Lighter_O;
            uint[] dislikedColors = Font.DefaultCyan_O;

            void PlaceLeftCol(int i, string leftColStr, bool boosted, bool disliked)
            {
                float y;

                if (i == -1)
                {
                    y = abilTextY;
                }
                else if (i == -2)
                {
                    y = textStartY;
                }
                else
                {
                    y = textStart2Y + (i * textSpacingY);
                }
                uint[] colors;
                if (boosted)
                {
                    colors = boostedColors;
                }
                else if (disliked)
                {
                    colors = dislikedColors;
                }
                else
                {
                    colors = leftColColors;
                }
                leftColFont.DrawString(bmpAddress, bmpWidth, bmpHeight, leftColX, y, leftColStr, colors);
            }

            void PlaceRightCol(int i, string rightColStr, uint[] colors)
            {
                float y = i == -2 ? textStartY : textStart2Y + (i * textSpacingY);

                rightColFont.MeasureString(rightColStr, out int strW, out _);
                rightColFont.DrawString(bmpAddress, bmpWidth, bmpHeight,
                                        RenderUtils.GetCoordinatesForCentering(bmpWidth, strW, rightColCenterX), (int)(bmpHeight * y), rightColStr, colors);
            }

            BaseStats          bs;
            PBEAbility         abil;
            PBENature          nature;
            IPBEStatCollection evs;
            IVs    ivs;
            byte   level;
            ushort hp;
            ushort maxHP;

            if (_pPkmn is not null)
            {
                bs     = BaseStats.Get(_pPkmn.Species, _pPkmn.Form, true);
                abil   = _pPkmn.Ability;
                nature = _pPkmn.Nature;
                evs    = _pPkmn.EffortValues;
                ivs    = _pPkmn.IndividualValues;
                level  = _pPkmn.Level;
                hp     = _pPkmn.HP;
                maxHP  = _pPkmn.MaxHP;
            }
            else if (_pcPkmn is not null)
            {
                bs     = BaseStats.Get(_pcPkmn.Species, _pcPkmn.Form, true);
                abil   = _pcPkmn.Ability;
                nature = _pcPkmn.Nature;
                evs    = _pcPkmn.EffortValues;
                ivs    = _pcPkmn.IndividualValues;
                level  = _pcPkmn.Level;
                hp     = maxHP = PBEDataUtils.CalculateStat(bs, PBEStat.HP, nature, evs.GetStat(PBEStat.HP), ivs.HP, level, PkmnConstants.PBESettings);
            }
            else
            {
                PartyPokemon     pPkmn = _bPkmn.PartyPkmn;
                PBEBattlePokemon bPkmn = _bPkmn.Pkmn;
                bs     = BaseStats.Get(pPkmn.Species, bPkmn.RevertForm, true);
                abil   = pPkmn.Ability;
                nature = pPkmn.Nature;
                evs    = bPkmn.EffortValues;
                ivs    = pPkmn.IndividualValues;
                level  = bPkmn.Level;
                hp     = bPkmn.HP;
                maxHP  = bPkmn.MaxHP;
            }
            ushort  atk      = PBEDataUtils.CalculateStat(bs, PBEStat.Attack, nature, evs.GetStat(PBEStat.Attack), ivs.Attack, level, PkmnConstants.PBESettings);
            ushort  def      = PBEDataUtils.CalculateStat(bs, PBEStat.Defense, nature, evs.GetStat(PBEStat.Defense), ivs.Defense, level, PkmnConstants.PBESettings);
            ushort  spAtk    = PBEDataUtils.CalculateStat(bs, PBEStat.SpAttack, nature, evs.GetStat(PBEStat.SpAttack), ivs.SpAttack, level, PkmnConstants.PBESettings);
            ushort  spDef    = PBEDataUtils.CalculateStat(bs, PBEStat.SpDefense, nature, evs.GetStat(PBEStat.SpDefense), ivs.SpDefense, level, PkmnConstants.PBESettings);
            ushort  speed    = PBEDataUtils.CalculateStat(bs, PBEStat.Speed, nature, evs.GetStat(PBEStat.Speed), ivs.Speed, level, PkmnConstants.PBESettings);
            PBEStat?favored  = nature.GetLikedStat();
            PBEStat?disliked = nature.GetDislikedStat();

            PlaceLeftCol(-2, "HP", false, false);
            PlaceLeftCol(0, "Attack", favored == PBEStat.Attack, disliked == PBEStat.Attack);
            PlaceLeftCol(1, "Defense", favored == PBEStat.Defense, disliked == PBEStat.Defense);
            PlaceLeftCol(2, "Special Attack", favored == PBEStat.SpAttack, disliked == PBEStat.SpAttack);
            PlaceLeftCol(3, "Special Defense", favored == PBEStat.SpDefense, disliked == PBEStat.SpDefense);
            PlaceLeftCol(4, "Speed", favored == PBEStat.Speed, disliked == PBEStat.Speed);
            PlaceLeftCol(-1, "Ability", false, false);

            // HP
            string str = string.Format("{0}/{1}", hp, maxHP);

            PlaceRightCol(-2, str, rightColColors);
            double percent = (double)hp / maxHP;

            RenderUtils.HP_TripleLine(bmpAddress, bmpWidth, bmpHeight, hpX, hpY, hpW, percent);
            // Attack
            str = atk.ToString();
            PlaceRightCol(0, str, rightColColors);
            // Defense
            str = def.ToString();
            PlaceRightCol(1, str, rightColColors);
            // Sp. Attack
            str = spAtk.ToString();
            PlaceRightCol(2, str, rightColColors);
            // Sp. Defense
            str = spDef.ToString();
            PlaceRightCol(3, str, rightColColors);
            // Speed
            str = speed.ToString();
            PlaceRightCol(4, str, rightColColors);
            // Ability
            str = PBELocalizedString.GetAbilityName(abil).English;
            rightColFont.DrawString(bmpAddress, bmpWidth, bmpHeight, abilTextX, abilTextY, str, rightColColors);
            // Ability desc
            str = PBELocalizedString.GetAbilityDescription(abil).English;
            leftColFont.DrawString(bmpAddress, bmpWidth, bmpHeight, abilDescX, abilDescY, str, rightColColors);
        }
コード例 #21
0
        private unsafe void DrawPersonalPage(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            const float winX         = 0.08f;
            const float winY         = 0.15f;
            const float winW         = 0.75f - winX;
            const float winH         = 0.93f - winY;
            const float leftColX     = winX + 0.03f;
            const float textStartY   = winY + 0.05f;
            const float textSpacingY = 0.1f;

            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, winX, winY, winX + winW, winY + winH, 15, RenderUtils.Color(145, 225, 225, 255));

            Font leftColFont = Font.Default;

            uint[] leftColColors   = Font.DefaultBlack_I;
            uint[] highlightColors = Font.DefaultRed_I;

            void Place(int i, int xOff, string leftColStr, uint[] colors)
            {
                float y = textStartY + (i * textSpacingY);

                leftColFont.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * leftColX) + xOff, (int)(bmpHeight * y), leftColStr, colors);
            }

            PBENature  nature;
            DateTime   met;
            MapSection loc;
            byte       metLvl;
            uint       pid;
            IVs        ivs;

            if (_pPkmn is not null)
            {
                nature = _pPkmn.Nature;
                met    = _pPkmn.MetDate;
                loc    = _pPkmn.MetLocation;
                metLvl = _pPkmn.MetLevel;
                pid    = _pPkmn.PID;
                ivs    = _pPkmn.IndividualValues;
            }
            else if (_pcPkmn is not null)
            {
                nature = _pcPkmn.Nature;
                met    = _pcPkmn.MetDate;
                loc    = _pcPkmn.MetLocation;
                metLvl = _pcPkmn.MetLevel;
                pid    = _pcPkmn.PID;
                ivs    = _pcPkmn.IndividualValues;
            }
            else
            {
                PartyPokemon pPkmn = _bPkmn.PartyPkmn;
                nature = pPkmn.Nature;
                met    = pPkmn.MetDate;
                loc    = pPkmn.MetLocation;
                metLvl = pPkmn.MetLevel;
                pid    = pPkmn.PID;
                ivs    = pPkmn.IndividualValues;
            }

            string    characteristic = Characteristic.GetCharacteristic(pid, ivs) + '.';
            PBEFlavor?flavor         = PBEDataUtils.GetLikedFlavor(nature);

            // Nature
            string str = PBELocalizedString.GetNatureName(nature).English + ' ';

            Place(0, 0, str, highlightColors);
            leftColFont.MeasureString(str, out int strW, out _);
            str = "nature.";
            Place(0, strW, str, leftColColors);
            // Met date
            str = met.ToString("MMMM dd, yyyy");
            Place(1, 0, str, leftColColors);
            // Met location
            str = loc.ToString();
            Place(2, 0, str, highlightColors);
            // Met level
            str = string.Format("Met at Level {0}.", metLvl);
            Place(3, 0, str, leftColColors);
            // Characteristic
            str = characteristic;
            Place(5, 0, str, leftColColors);
            // Flavor
            if (flavor.HasValue)
            {
                str = "Likes ";
                Place(6, 0, str, leftColColors);
                leftColFont.MeasureString(str, out strW, out _);
                str = flavor.Value.ToString() + ' ';
                Place(6, strW, str, highlightColors);
                leftColFont.MeasureString(str, out int strW2, out _);
                str = "food.";
                Place(6, strW + strW2, str, leftColColors);
            }
            else
            {
                str = "Likes all food.";
                Place(6, 0, str, leftColColors);
            }
        }
コード例 #22
0
        private unsafe void DrawInfoPage(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            const float winX            = 0.03f;
            const float winY            = 0.15f;
            const float winW            = 0.97f - winX;
            const float winH            = 0.85f - winY;
            const float leftColX        = winX + 0.02f;
            const float rightColX       = winX + 0.52f;
            const float rightColY       = winY + 0.03f;
            const float rightColW       = 0.95f - rightColX;
            const float rightColH       = 0.82f - rightColY;
            const float rightColCenterX = rightColX + (rightColW / 2f);
            const float textStartY      = rightColY + 0.02f;
            const float textSpacingY    = 0.1f;
            int         xpW             = (int)(bmpWidth * 0.3f);
            int         xpX             = RenderUtils.GetCoordinatesForCentering(bmpWidth, xpW, rightColCenterX);
            int         xpY             = (int)(bmpHeight * (rightColY + 0.61f));

            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, winX, winY, winX + winW, winY + winH, 15, RenderUtils.Color(128, 215, 135, 255));
            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, rightColX, rightColY, rightColX + rightColW, rightColY + rightColH, 8, RenderUtils.Color(210, 210, 210, 255));

            Font leftColFont = Font.Default;

            uint[] leftColColors = Font.DefaultWhite_DarkerOutline_I;
            Font   rightColFont  = Font.Default;

            uint[] rightColColors = Font.DefaultBlack_I;

            void PlaceLeftCol(int i, string leftColStr)
            {
                float y = textStartY + (i * textSpacingY);

                leftColFont.DrawString(bmpAddress, bmpWidth, bmpHeight, leftColX, y, leftColStr, leftColColors);
            }

            void PlaceRightCol(int i, string rightColStr, uint[] colors)
            {
                float y = textStartY + (i * textSpacingY);

                rightColFont.MeasureString(rightColStr, out int strW, out _);
                rightColFont.DrawString(bmpAddress, bmpWidth, bmpHeight,
                                        RenderUtils.GetCoordinatesForCentering(bmpWidth, strW, rightColCenterX), (int)(bmpHeight * y), rightColStr, colors);
            }

            PlaceLeftCol(0, "Species");
            PlaceLeftCol(1, "Type(s)");
            PlaceLeftCol(2, "OT");
            PlaceLeftCol(3, "OT ID");
            PlaceLeftCol(4, "Exp. Points");
            PlaceLeftCol(5, "Exp. To Next Level");

            PBESpecies species;
            PBEForm    form;
            OTInfo     ot;
            byte       level;
            uint       exp;

            if (_pPkmn is not null)
            {
                species = _pPkmn.Species;
                form    = _pPkmn.Form;
                ot      = _pPkmn.OT;
                level   = _pPkmn.Level;
                exp     = _pPkmn.EXP;
            }
            else if (_pcPkmn is not null)
            {
                species = _pcPkmn.Species;
                form    = _pcPkmn.Form;
                ot      = _pcPkmn.OT;
                level   = _pcPkmn.Level;
                exp     = _pcPkmn.EXP;
            }
            else
            {
                PartyPokemon     pPkmn = _bPkmn.PartyPkmn;
                PBEBattlePokemon bPkmn = _bPkmn.Pkmn;
                species = pPkmn.Species;
                form    = bPkmn.RevertForm;
                ot      = pPkmn.OT;
                level   = bPkmn.Level;
                exp     = bPkmn.EXP;
            }

            var  bs = BaseStats.Get(species, form, true);
            uint toNextLvl;

            if (level >= PkmnConstants.MaxLevel)
            {
                toNextLvl = 0;
                RenderUtils.EXP_SingleLine(bmpAddress, bmpWidth, bmpHeight, xpX, xpY, xpW, 0);
            }
            else
            {
                PBEGrowthRate gr = bs.GrowthRate;
                toNextLvl = PBEEXPTables.GetEXPRequired(gr, (byte)(level + 1)) - exp;
                RenderUtils.EXP_SingleLine(bmpAddress, bmpWidth, bmpHeight, xpX, xpY, xpW, exp, level, gr);
            }

            // Species
            string str = PBELocalizedString.GetSpeciesName(species).English;

            PlaceRightCol(0, str, rightColColors);
            // Types
            str = PBELocalizedString.GetTypeName(bs.Type1).English;
            if (bs.Type2 != PBEType.None)
            {
                str += ' ' + PBELocalizedString.GetTypeName(bs.Type2).English;
            }
            PlaceRightCol(1, str, rightColColors);
            // OT
            str = ot.TrainerName;
            PlaceRightCol(2, str, ot.TrainerIsFemale ? Font.DefaultRed_I : Font.DefaultBlue_I);
            // OT ID
            str = ot.TrainerID.ToString();
            PlaceRightCol(3, str, rightColColors);
            // Exp
            str = exp.ToString();
            PlaceRightCol(4, str, rightColColors);
            // To next level
            str = toNextLvl.ToString();
            PlaceRightCol(5, str, rightColColors);
        }
コード例 #23
0
        // TODO: Biking lowers the rate by 20% according to gen 3, running does not affect (according to gen 3, maybe it does after)
        public static bool CheckForWildBattle(bool ignoreAbilityOrItem)
        {
            PlayerObj player = PlayerObj.Player;

            Map.Layout.Block block = player.GetBlock(out Map map);
            EncounterType    t;

            switch (block.BlocksetBlock.Behavior)
            {
            case BlocksetBlockBehavior.AllowElevationChange_Cave_Encounter:
            case BlocksetBlockBehavior.Cave_Encounter:
            case BlocksetBlockBehavior.Grass_Encounter: t = EncounterType.Default; break;

            case BlocksetBlockBehavior.Grass_SpecialEncounter: t = EncounterType.DarkGrass; break;

            case BlocksetBlockBehavior.Surf: t = EncounterType.Surf; break;

            default: return(false);
            }
            EncounterTable tbl = map.Encounters.GetEncounterTable(t);

            if (tbl is null)
            {
                return(false);
            }
            int chance = tbl.ChanceOfPhenomenon;

            // Some abilities affect the wild encounter rate
            // This is an option because some encounters (like rock smash) do not use the ability to modify the rate
            if (!ignoreAbilityOrItem)
            {
                PartyPokemon pkmn = Game.Instance.Save.PlayerParty[0];
                PBEAbility   abilityOfFirstInParty = pkmn.Ability;
                PBEItem      itemOfFirstInParty    = pkmn.Item;
                // TODO: CompoundEyes
                // TODO: CuteCharm
                // TODO: Hustle, Pressure, VitalSpirit
                // TODO: Intimidate, KeenEye
                // TODO: MagnetPull, Static
                // TODO: SandVeil, SnowCloak
                // TODO: StickyHold, SuctionCups
                // TODO: Synchronize
                switch (abilityOfFirstInParty)
                {
                case PBEAbility.ArenaTrap:
                case PBEAbility.Illuminate:
                case PBEAbility.NoGuard: chance *= 2; break;

                case PBEAbility.QuickFeet:
                case PBEAbility.Stench:
                case PBEAbility.WhiteSmoke: chance /= 2; break;
                }
                switch (itemOfFirstInParty)
                {
                case PBEItem.CleanseTag: chance = chance * 2 / 3; break;     // Reduce by 1/3
                }
            }
            if (!PBEUtils.GlobalRandom.RandomBool(chance, byte.MaxValue))
            {
                return(false);
            }
            ushort combinedChance = tbl.GetCombinedChance();

            if (combinedChance == 0)
            {
                return(false);
            }
            EncounterTable.Encounter encounter0 = RollEncounter(tbl, combinedChance);
            Game.Instance.TempCreateWildBattle(map, block, encounter0);
            return(true);
        }
コード例 #24
0
        private void UpdateFriendshipForLevelUp(PBEBattlePokemon pkmn)
        {
            PartyPokemon pp = SpritedParties[pkmn.Trainer.Id][pkmn].PartyPkmn;

            Friendship.AdjustFriendship(pkmn, pp, Friendship.Event.LevelUpBattle);
        }