Пример #1
0
    private IEnumerator WaterPulseAction(Pokemon attacker, Pokemon defensor)
    {
        Transform effectTransform = Instantiate(waterPulseEffect).transform;

        effectTransform.localScale = Vector2.zero;
        effectTransform.position   = transform.position;
        Destroy(effectTransform.gameObject, 3f);

        AudioSource audioSource = GetComponent <AudioSource>();

        audioSource.PlayOneShot(waterPulseSound);

        attacker.StopAnimation();

        for (float timer = 0f; timer < 1.5f; timer += Time.deltaTime)
        {
            effectTransform.localScale += new Vector3(Time.deltaTime / 2f, Time.deltaTime / 2f);
            effectTransform.position    = Vector2.Lerp(attacker.transform.position, attacker.uiTransform.position, timer / 1f);

            yield return(null);
        }

        for (float timer = 0f; timer < 0.5f; timer += Time.deltaTime)
        {
            Vector2 destionation = (defensor.transform.position + defensor.uiTransform.position) / 2f;
            effectTransform.position = Vector2.Lerp(attacker.uiTransform.position, destionation, timer / 0.5f);

            yield return(null);
        }

        Destroy(effectTransform.gameObject);
        audioSource.PlayOneShot(hitSound);
        defensor.Hit(DamageCalculator.CalculateSkillDamage(attacker, defensor, baseDamage, PokemonType.Water), attacker);
        EndSkill(attacker);
    }
Пример #2
0
    private IEnumerator VoltTackleAction(Pokemon attacker, Pokemon defensor)
    {
        attacker.StopAnimation();
        Material    previousMetrial = attacker.spriteRenderer.material;
        AudioSource audioSource     = GetComponent <AudioSource>();

        audioSource.PlayOneShot(chargeSound);

        attacker.spriteRenderer.color *= new Color(1f, 1f, 0f);

        yield return(new WaitForSeconds(0.5f));

        attacker.spriteRenderer.material = paintWhite;
        yield return(new WaitForSeconds(0.1f));

        attacker.spriteRenderer.material = previousMetrial;
        yield return(new WaitForSeconds(0.5f));

        attacker.spriteRenderer.material = paintWhite;
        yield return(new WaitForSeconds(0.1f));

        attacker.spriteRenderer.material = previousMetrial;
        yield return(new WaitForSeconds(0.3f));

        attacker.spriteRenderer.material = paintWhite;
        yield return(new WaitForSeconds(0.1f));

        attacker.spriteRenderer.material = previousMetrial;
        yield return(new WaitForSeconds(0.2f));

        attacker.spriteRenderer.material = paintWhite;

        Vector3 startPosition = attacker.transform.position;

        for (float timer = 0; timer < 0.1f; timer += Time.deltaTime)
        {
            attacker.transform.position = Vector3.Lerp(startPosition, defensor.transform.position, timer / 0.1f);

            yield return(null);
        }

        audioSource.PlayOneShot(hitSound);
        int damage = DamageCalculator.CalculateSkillDamage(attacker, defensor, 120, PokemonType.Electric, AttackType.Physical);

        defensor.Hit(damage, attacker, AttackType.Physical);

        if (Random.Range(0, 1f) < 0.1f)
        {
            defensor.SetStatus(PokemonStatus.Paralysis, 6f);
        }
        for (float timer = 0f; timer < 0.1f; timer += Time.deltaTime)
        {
            attacker.transform.position = Vector3.Lerp(defensor.transform.position, startPosition, timer / 0.1f);

            yield return(null);
        }

        attacker.spriteRenderer.color    = new Color(1f, 1f, 1f);
        attacker.spriteRenderer.material = previousMetrial;

        if (defensor.isAlive)
        {
            attacker.currentHp -= damage / 3;
            if (attacker.currentHp <= 0)
            {
                attacker.currentHp = 1;
            }
        }
        EndSkill(attacker);
    }