Beispiel #1
0
    void Update()
    {
        playerSpeed = (float)player.GetActive().GetSpeed() / 1000;

        if (opponent.GetCurrentHitPoints() > 0)
        {
            count += Time.deltaTime;
        }
        if (count > cooldown - playerSpeed * 4)
        {
            AttackTarget(player, opponent);
            count = 0;
        }
    }
Beispiel #2
0
    private void AttackTarget(ActivePokemon attacker, ActivePokemon target)
    {
        UniquePokemon pokemonAttacker    = attacker.GetActive();
        UniquePokemon pokemonTarget      = target.GetActive();
        int           attackerLevel      = pokemonAttacker.GetLevel();
        int           attackerAttackStat = pokemonAttacker.GetAttack();
        int           targetDefenceStat  = pokemonTarget.GetDefence();

        int damage = CalculateDamage(attackerLevel, attackerAttackStat, targetDefenceStat);

        target.TakeDamage(damage);
        if (target.GetCurrentHitPoints() == 0)
        {
            target.Faint();
            if (attacker.IsPlayer())
            {
                pokemonAttacker.GainExp(pokemonTarget.CalculateExperienceReward());
                attacker.UpdateText();
            }
        }
    }