Beispiel #1
0
    //called when something enters the collider of the boss
    void OnTriggerEnter(Collider other)
    {
        //ignore the collider of the boundary
        if (other.tag == "Boundary")
        {
            return;
        }

        //if the player collides with the boss, and they are not invincible, hurt them
        if (other.tag == "Player")
        {
            if (!playerController.ps.invincible)
            {
                playerController.TakeDamage();
            }
        }

        //if a bullet collides with the first boss, damage them and delete the bullet
        else if (boss1Controller != null)
        {
            boss1Controller.TakeDamage(playerController.ps.damage);
            Destroy(other.gameObject);
        }

        //same as above, for second boss
        else if (boss2Controller != null)
        {
            boss2Controller.TakeDamage(playerController.ps.damage);
            Destroy(other.gameObject);
        }
    }
Beispiel #2
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.gameObject.layer)
        {
        case 11:
            if (!myEnemyBase.incam || myEnemyBase.enemyState == EnemyBase.EnemyState.die)
            {
                return;
            }

            if (collision.tag == "bulletW5")
            {
                explobulletW5 = ObjectPoolerManager.Instance.exploBulletW5Pooler.GetPooledObject();
                explobulletW5.transform.position = collision.transform.position;
                explobulletW5.SetActive(true);
                SoundController.instance.PlaySound(soundGame.soundexplow6);
                collision.gameObject.SetActive(false);
            }
            else if (collision.tag == "bulletuav")
            {
                TakeDamage(GameController.instance.uav.damageBullet, false, false);
                myEnemyBase.TakeDamage(PlayerController.instance.damageBullet, false, false, false);
                collision.gameObject.SetActive(false);
            }
            else if (collision.tag == "bulletnpc")
            {
                TakeDamage(GameController.instance.uav.damageBullet / 3, false, false);
                myEnemyBase.TakeDamage(PlayerController.instance.damageBullet / 3, false, false, false);
                collision.gameObject.SetActive(false);
            }
            else
            {
                takecrithit = Random.Range(1, 100);
                if (takecrithit <= PlayerController.instance.critRate)
                {
                    if (collision.tag != "explobulletW5")
                    {
                        TakeDamage(PlayerController.instance.damageBullet + (PlayerController.instance.damageBullet / 100 * PlayerController.instance.critDamage), true, false);
                        myEnemyBase.TakeDamage(PlayerController.instance.damageBullet + (PlayerController.instance.damageBullet / 100 * PlayerController.instance.critDamage), true, true, false);
                    }
                    else
                    {
                        TakeDamage(PlayerController.instance.damageBullet + (PlayerController.instance.damageBullet / 100 * PlayerController.instance.critDamage), true, true);
                        myEnemyBase.TakeDamage(PlayerController.instance.damageBullet + (PlayerController.instance.damageBullet / 100 * PlayerController.instance.critDamage), true, true, true);
                    }

                    if (!GameController.instance.listcirtwhambang[0].gameObject.activeSelf)
                    {
                        switch (GameController.instance.currentChar)
                        {
                        case 0:
                            SoundController.instance.PlaySound(soundGame.soundCritHit);
                            break;

                        case 1:
                            SoundController.instance.PlaySound(soundGame.soundcrithitnv2);
                            break;
                        }
                    }
                    GameController.instance.listcirtwhambang[0].DisplayMe(transform.position);
                }
                else
                {
                    if (collision.tag != "explobulletW5")
                    {
                        TakeDamage(PlayerController.instance.damageBullet, false, false);
                        myEnemyBase.TakeDamage(PlayerController.instance.damageBullet, false, true, false);
                    }
                    else
                    {
                        TakeDamage(PlayerController.instance.damageBullet, false, true);
                        myEnemyBase.TakeDamage(PlayerController.instance.damageBullet, false, true, true);
                    }
                }

                if (collision.tag != "shotgun" && collision.tag != "explobulletW5")
                {
                    collision.gameObject.SetActive(false);
                }
                if (collision.tag == "bulletw6")
                {
                    chainLightning                    = ObjectPoolManagerHaveScript.Instance.chainlightningPooler.GetChainLightningPooledObject();
                    chainLightning.originPos          = gameObject;
                    chainLightning.transform.position = gameObject.transform.position;
                    chainLightning.gameObject.SetActive(true);
                }
            }
            break;

        case 14:
            if (!myEnemyBase.incam || myEnemyBase.enemyState == EnemyBase.EnemyState.die)
            {
                return;
            }

            if (collision.tag == "effectexploboomplane")
            {
                TakeDamage(GameController.instance.maybay.damageboom, false, false);
                myEnemyBase.TakeDamage(GameController.instance.maybay.damageboom, false, true, false);
            }
            else
            {
                TakeDamage(PlayerController.instance.damgeGrenade, false, false);
                myEnemyBase.TakeDamage(PlayerController.instance.damgeGrenade, false, true, false);
                if (currentHealth <= 0)
                {
                    if (!GameController.instance.listcirtwhambang[1].gameObject.activeSelf)
                    {
                        SoundController.instance.PlaySound(soundGame.soundGrenadeKill);
                    }
                    GameController.instance.listcirtwhambang[1].DisplayMe(transform.position);
                    MissionController.Instance.DoMission(1, 1);
                    DataController.instance.DoAchievement(3, 1);
                    DataController.instance.DoDailyQuest(1, 1);
                }
            }
            break;

        case 26:
            if (!myEnemyBase.incam || myEnemyBase.enemyState == EnemyBase.EnemyState.die)
            {
                return;
            }
            TakeDamage(PlayerController.instance.damgeGrenade, false, false);
            myEnemyBase.TakeDamage(PlayerController.instance.damgeGrenade, false, true, false);
            break;

        case 27:
            if (!myEnemyBase.incam || myEnemyBase.enemyState == EnemyBase.EnemyState.die)
            {
                return;
            }
            TakeDamage(PlayerController.instance.damageBullet * 3f, false, false);
            myEnemyBase.TakeDamage(PlayerController.instance.damageBullet * 3f, false, true, false);


            switch (GameController.instance.currentChar)
            {
            case 0:
                SoundController.instance.PlaySound(soundGame.sounddapchao);
                break;

            case 1:
                SoundController.instance.PlaySound(soundGame.sounddaonv2);
                break;
            }


            if (currentHealth <= 0)
            {
                if (!GameController.instance.listcirtwhambang[2].gameObject.activeSelf)
                {
                    SoundController.instance.PlaySound(soundGame.soundWham);
                }
                GameController.instance.listcirtwhambang[2].DisplayMe(transform.position);
                MissionController.Instance.DoMission(5, 1);
            }
            break;

        case 20:
            gameObject.SetActive(false);
            break;
        }
    }