Пример #1
0
    private void OnTriggerEnter(Collider otherCollider)
    {
        if (!(otherCollider.tag == "Tank"))
        {
            return;
        }
        TankScript tankScript = otherCollider.transform.GetComponent <TankScript>();

        if (tankScript.ally == "Player")
        {
            if (!ms.noSound)
            {
                audio.Play();
            }
            Player player = ms.playersList[tankScript.number];
            player.scores += 500;
            player.kills[4]++;
            ms.ShowFlower(transform.position, "500");
            switch (type)
            {
            case Bonus.Life:
            {
                player.lifes++;
                break;
            }

            case Bonus.Upgrade:
                if (tankScript.rank < 3)
                {
                    tankScript.Upgrade(1);
                    break;
                }
                else
                {
                    break;
                }

            case Bonus.Bomb:
                ms.DestroyAllEnemy();
                break;

            case Bonus.Freeze:
                ms.FreezeAllEnemy();
                break;

            case Bonus.Fort:
                ms.UpgradeFort();
                break;

            case Bonus.Shield:
            {
                tankScript.invincible = 10;
                break;
            }

            case Bonus.FullUpgrade:
            {
                if (tankScript.rank < 3)
                {
                    tankScript.Upgrade(3);
                }
                break;
            }

            case Bonus.Ship:
            {
                tankScript.SetWaterWalking(true);
                break;
            }
            }
            Hide();
        }
        if (!(tankScript.ally == "Enemy") || ms.difficulty != 2)
        {
            return;
        }
        switch (type)
        {
        case Bonus.Life:
            if (tankScript.rank < 3)
            {
                tankScript.Upgrade(3);
                break;
            }
            else
            {
                break;
            }

        case Bonus.Upgrade:
            if (tankScript.rank < 3)
            {
                tankScript.Upgrade(1);
                break;
            }
            else
            {
                break;
            }

        case Bonus.Bomb:
            ms.DestroyAllPlayers();
            break;

        case Bonus.Freeze:
            ms.FreezeAllPlayers();
            break;

        case Bonus.Fort:
            ms.ClearUpgradeFort();
            break;

        case Bonus.Shield:
            if (tankScript.rank < 3)
            {
                tankScript.Upgrade(3);
                break;
            }
            else
            {
                break;
            }

        case Bonus.FullUpgrade:
            if (tankScript.rank < 3)
            {
                tankScript.Upgrade(3);
                break;
            }
            else
            {
                break;
            }

        case Bonus.Ship:
        {
            tankScript.SetWaterWalking(true);
            break;
        }
        }
        Hide();
    }