Ejemplo n.º 1
0
    /// <summary>
    /// get damage and add effect (if skill has one)
    /// </summary>
    public void GetDamage(SkillModel skill, PokemonModel pokemonWhoAttack, out string efficiencyText)
    {
        int random   = Random.Range(0, 100);
        int accuracy = Mathf.Min(CurrentMaxAccuracy, skill.skillData.Accuracy);

        //try to hit enemy
        if (random < accuracy)
        {
            //get attack and defense, based to the skill if special or physics
            float attack  = skill.skillData.IsSpecial ? pokemonWhoAttack.SpecialAttack : pokemonWhoAttack.PhysicsAttack;
            float defense = skill.skillData.IsSpecial ? SpecialDefense : PhysicsDefense;

            //get multipliers -> out efficiencyText
            float efficiencyMultiplier = skill.EfficiencyMultiplier(pokemonData.PokemonType, out efficiencyText);
            float stab    = skill.STAB(pokemonWhoAttack.pokemonData.PokemonType);
            float nRandom = skill.NRandom();

            //((( (2 * Livello Pokemon + 10) * Attacco Pokemon * Potenza Mossa ) / (250 * Difesa Fisica o Difesa Speciale del Nemico)) +2 ) * Efficacia * STAB * N
            float damage = ((((2 * pokemonWhoAttack.CurrentLevel + 10) * attack * skill.skillData.Power) / (250 * defense)) + 2) * efficiencyMultiplier * stab * nRandom;

            //if the skill has one, add effect to the list
            AddEffect(skill.skillData.Effect);

            //apply effective damage
            CurrentHealth -= damage;
            return;
        }

        //else miss
        efficiencyText = "Ups, mancato!";
    }