Esempio n. 1
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (!other.gameObject.CompareTag("Player"))
     {
         if (isBouncy <= 0)
         {
             if (other.gameObject.CompareTag("skeletonfs"))
             {
                 SkeletonFS enemy = other.gameObject.GetComponent <SkeletonFS>();
                 if (isPoison)
                 {
                     enemy.StartCoroutine(enemy.Poison(poisonTime, poisonDPS));
                 }
                 if (isWeakness)
                 {
                     enemy.StartCoroutine(enemy.Weakness(weaknessTime));
                 }
                 if (isSlowness)
                 {
                     enemy.StartCoroutine(enemy.Slowness(slownessTime, slownessEffect));
                 }
                 if (isFreeze)
                 {
                     enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                 }
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             else if (other.gameObject.CompareTag("skeletonmage"))
             {
                 SkeletonMage enemy = other.gameObject.GetComponent <SkeletonMage>();
                 if (isPoison)
                 {
                     enemy.StartCoroutine(enemy.Poison(poisonTime, poisonDPS));
                 }
                 if (isWeakness)
                 {
                     enemy.StartCoroutine(enemy.Weakness(weaknessTime));
                 }
                 if (isSlowness)
                 {
                     enemy.StartCoroutine(enemy.Slowness(slownessTime, slownessEffect));
                 }
                 if (isFreeze)
                 {
                     enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                 }
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             else if (other.gameObject.CompareTag("skeletontank"))
             {
                 SkeletonTank enemy = other.gameObject.GetComponent <SkeletonTank>();
                 if (isPoison)
                 {
                     enemy.StartCoroutine(enemy.Poison(poisonTime, poisonDPS));
                 }
                 if (isWeakness)
                 {
                     enemy.StartCoroutine(enemy.Weakness(weaknessTime));
                 }
                 if (isSlowness)
                 {
                     enemy.StartCoroutine(enemy.Slowness(slownessTime, slownessEffect));
                 }
                 if (isFreeze)
                 {
                     enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                 }
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             else if (other.gameObject.CompareTag("angelboss"))
             {
                 AngelBoss enemy = other.gameObject.GetComponent <AngelBoss>();
                 if (isPoison)
                 {
                     enemy.StartCoroutine(enemy.Poison(poisonTime, poisonDPS));
                 }
                 if (isWeakness)
                 {
                     enemy.StartCoroutine(enemy.Weakness(weaknessTime));
                 }
                 if (isSlowness)
                 {
                     enemy.StartCoroutine(enemy.Slowness(slownessTime, slownessEffect));
                 }
                 if (isFreeze)
                 {
                     enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                 }
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             Destroy(gameObject);
         }
         else
         {
             FindObjectOfType <AudioManager>().PlaySound("Bounce");
             transform.rotation = Quaternion.Euler(new Vector3(0, 0, 225));
             if (other.gameObject.CompareTag("skeletonfs"))
             {
                 SkeletonFS enemy = other.gameObject.GetComponent <SkeletonFS>();
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             else if (other.gameObject.CompareTag("skeletonmage"))
             {
                 SkeletonMage enemy = other.gameObject.GetComponent <SkeletonMage>();
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             else if (other.gameObject.CompareTag("skeletontank"))
             {
                 SkeletonTank enemy = other.gameObject.GetComponent <SkeletonTank>();
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             else if (other.gameObject.CompareTag("angelboss"))
             {
                 AngelBoss enemy = other.gameObject.GetComponent <AngelBoss>();
                 damage *= damageMultiplier;
                 enemy.TakeDamage(damage);
             }
             isBouncy--;
             Vector2 inDirection = rigidbody2d.velocity;
             Vector2 inNormal    = other.contacts[0].normal;
             Vector2 newVelocity = Vector2.Reflect(inDirection, inNormal - new Vector2(0, -5));
             rigidbody2d.AddForce(newVelocity);
         }
     }
 }
Esempio n. 2
0
    private IEnumerator OnTriggerEnter2D(Collider2D other)
    {
        if (!other.isTrigger)
        {
            enemyLeft = false;
            if (other.gameObject.CompareTag("skeletonfs"))
            {
                SkeletonFS enemy = other.gameObject.GetComponent <SkeletonFS>();
                if (isStun)
                {
                    enemy.StartCoroutine(enemy.Stun(stunTime));
                }
                if (isFreeze)
                {
                    enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                }
                if (isBlind)
                {
                    enemy.StartCoroutine(enemy.Blind(blindTime));
                }

                if (isPillar)
                {
                    while (!enemyLeft)
                    {
                        GetComponent <Animator>().SetBool("isAttack", true);
                        enemy.TakeDamage(damage);
                        yield return(new WaitForSecondsRealtime(0.75f));
                    }
                    GetComponent <Animator>().SetBool("isAttack", false);
                }

                if (damage > 0)
                {
                    damage *= damageMultiplier;
                    enemy.TakeDamage(damage);
                }
            }
            else if ((other.gameObject.CompareTag("skeletonmage")))
            {
                SkeletonMage enemy = other.gameObject.GetComponent <SkeletonMage>();
                if (isStun)
                {
                    enemy.StartCoroutine(enemy.Stun(stunTime));
                }
                if (isFreeze)
                {
                    enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                }
                if (isBlind)
                {
                    enemy.StartCoroutine(enemy.Blind(blindTime));
                }

                if (isPillar)
                {
                    while (!enemyLeft)
                    {
                        enemy.TakeDamage(damage);
                        yield return(new WaitForSecondsRealtime(0.75f));
                    }
                }

                if (damage > 0)
                {
                    damage *= damageMultiplier;
                    enemy.TakeDamage(damage);
                }
            }
            else if ((other.gameObject.CompareTag("skeletontank")))
            {
                SkeletonTank enemy = other.gameObject.GetComponent <SkeletonTank>();
                if (isStun)
                {
                    enemy.StartCoroutine(enemy.Stun(stunTime));
                }
                if (isFreeze)
                {
                    enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                }
                if (isBlind)
                {
                    enemy.StartCoroutine(enemy.Blind(blindTime));
                }

                if (isPillar)
                {
                    while (!enemyLeft)
                    {
                        enemy.TakeDamage(damage);
                        yield return(new WaitForSecondsRealtime(0.75f));
                    }
                }

                if (damage > 0)
                {
                    damage *= damageMultiplier;
                    enemy.TakeDamage(damage);
                }
            }
            else if (other.gameObject.CompareTag("angelboss"))
            {
                AngelBoss enemy = other.gameObject.GetComponent <AngelBoss>();
                if (isStun)
                {
                    enemy.StartCoroutine(enemy.Stun(stunTime));
                }
                if (isFreeze)
                {
                    enemy.StartCoroutine(enemy.Freeze(freezeTime, freezeWeakness));
                }
                if (isBlind)
                {
                    enemy.StartCoroutine(enemy.Blind(blindTime));
                }

                if (isPillar)
                {
                    while (!enemyLeft)
                    {
                        enemy.TakeDamage(damage);
                        yield return(new WaitForSecondsRealtime(0.75f));
                    }
                }

                if (damage > 0)
                {
                    damage *= damageMultiplier;
                    enemy.TakeDamage(damage);
                }
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }