Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Enemy" && canPlay)
        {
            if (col.gameObject.renderer.material.color == myColor)
            {
                score += 50;
                col.gameObject.transform.position = new Vector2(col.gameObject.transform.position.x, -9);
                particleSystem.PlayColor(myColor, myTransform.position);
            }
            else
            {
                canPlay = false;

                if (Application.isWebPlayer)
                {
                    Instantiate(Resources.Load("Prefabs/GameScreen"));
                    Text finalScore = GameObject.FindGameObjectWithTag("ScoreText").GetComponent <Text>();
                    finalScore.text = "Score: " + score;
                    return;
                }
                else if (HighScores.GetLowestScore() < score)
                {
                    Instantiate(Resources.Load("Prefabs/HighScoreScreen"));
                    Text finalScore = GameObject.FindGameObjectWithTag("HighScoreText").GetComponent <Text>();
                    finalScore.text = "" + score;
                }
                else
                {
                    Instantiate(Resources.Load("Prefabs/GameScreen"));
                    Text finalScore = GameObject.FindGameObjectWithTag("ScoreText").GetComponent <Text>();
                    finalScore.text = "Score: " + score;
                }
            }
        }
    }