public void UpdateBar(PokemonInstance pmon)
 => UpdateBar(
     pmon.GetLevel() < 100
             ? Mathf.InverseLerp(
         a: GrowthTypeData.GetMinimumExperienceForLevel(pmon.GetLevel(), pmon.growthType),
         b: GrowthTypeData.GetMinimumExperienceForLevel((byte)(pmon.GetLevel() + 1), pmon.growthType),
         value: pmon.experience
         )
             : 1
     );
        public void UpdateExperienceBar(PokemonInstance pokemon)
        {
            if (pokemon.GetLevel() < 100)
            {
                int pokemonCurrentLevelExperience = GrowthTypeData.GetMinimumExperienceForLevel(pokemon.GetLevel(), pokemon.growthType);
                int pokemonNextLevelExperience    = GrowthTypeData.GetMinimumExperienceForLevel((byte)(pokemon.GetLevel() + 1), pokemon.growthType);

                UpdateExperienceBar(pokemon.experience, pokemonCurrentLevelExperience, pokemonNextLevelExperience);
            }
            else
            {
                UpdateExperienceBar(1);
            }
        }
Example #3
0
        public override void RefreshDetails(PokemonInstance pokemon)
        {
            evHex.values = new float[]
            {
                (float)pokemon.effortValues.attack / PokemonInstance.maximumEffortValue,
                (float)pokemon.effortValues.defense / PokemonInstance.maximumEffortValue,
                (float)pokemon.effortValues.specialAttack / PokemonInstance.maximumEffortValue,
                (float)pokemon.effortValues.specialDefense / PokemonInstance.maximumEffortValue,
                (float)pokemon.effortValues.speed / PokemonInstance.maximumEffortValue,
                (float)pokemon.effortValues.health / PokemonInstance.maximumEffortValue
            };

            ivHex.values = new float[]
            {
                (float)pokemon.individualValues.attack / PokemonInstance.maximumIndividualValue,
                (float)pokemon.individualValues.defense / PokemonInstance.maximumIndividualValue,
                (float)pokemon.individualValues.specialAttack / PokemonInstance.maximumIndividualValue,
                (float)pokemon.individualValues.specialDefense / PokemonInstance.maximumIndividualValue,
                (float)pokemon.individualValues.speed / PokemonInstance.maximumIndividualValue,
                (float)pokemon.individualValues.health / PokemonInstance.maximumIndividualValue
            };

            textAttackValue.text         = pokemon.GetStats().attack.ToString();
            textDefenseValue.text        = pokemon.GetStats().defense.ToString();
            textSpecialAttackValue.text  = pokemon.GetStats().specialAttack.ToString();
            textSpecialDefenseValue.text = pokemon.GetStats().specialDefense.ToString();
            textSpeedValue.text          = pokemon.GetStats().speed.ToString();
            textHealthValue.text         = pokemon.health + "/" + pokemon.GetStats().health;

            byte pokemonLevel = pokemon.GetLevel();

            textExperience.text = pokemon.experience.ToString();

            if (pokemonLevel < 100)
            {
                textExperienceToNextLevel.text = (GrowthTypeData.GetMinimumExperienceForLevel((byte)(pokemonLevel + 1), pokemon.species.growthType) - pokemon.experience).ToString();
            }
            else
            {
                textExperienceToNextLevel.text = "-";
            }

            experienceBar.UpdateBar(pokemon);
        }