Ejemplo n.º 1
0
    IEnumerator OnTriggerEnter2D(Collider2D collider)
    {
        object[] currentBalls = GameObject.FindObjectsOfType <Ball>();

        if (collider.gameObject.name == "Paddle")
        {
            switch (gameObject.GetComponent <SpriteRenderer>().sprite.name)
            {
            case "01-Life":
                gameKeeper.GainLife();
                break;

            case "02-50-points":
                gameKeeper.ChangeScore(50);
                break;

            case "03-100-points":
                gameKeeper.ChangeScore(100);
                break;

            case "04-250-points":
                gameKeeper.ChangeScore(250);
                break;

            case "05-500-points":
                gameKeeper.ChangeScore(500);
                break;

            case "06-Fast":
                foreach (Ball ball in currentBalls)
                {
                    StartCoroutine(ball.ChangeBallSpeed(1.5f));
                }
                break;

            case "07-Slow":
                foreach (Ball ball in currentBalls)
                {
                    StartCoroutine(ball.ChangeBallSpeed(0.5f));
                }
                break;

            case "08-Large":
                StartCoroutine(paddle.ChangePaddleSize(1));
                break;

            case "09-Small":
                StartCoroutine(paddle.ChangePaddleSize(-1));
                break;

            case "10-Split":
                foreach (Ball ball in currentBalls)
                {
                    StartCoroutine(ball.SplitBall());
                }
                break;

            case "11-Fire":
                break;

            default:
                Debug.Log("Default case");
                break;
            }

            gameObject.GetComponent <SpriteRenderer>().enabled = false;
            yield return(new WaitForSeconds(11));

            Destroy(gameObject);
        }
    }