コード例 #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Brick")
        {
            LastBrickPosition(collision);
            if (controlClass.GetQtdBlocks() > 1)
            {
                Destroy(collision.gameObject);

                //Score control
                controlClass.Dec_bricks();
                controlClass.AddScore(1);
                controlClass.ChangeUpdatedScore();                      //Set it as true
                //UpdateScoreText();
                Update();

                //Empty block
                activated = true;
            }
            else
            {
                Destroy(collision.gameObject);
                Destroy(gameObject);

                finalScoreText.SetActive(true);
                UpdateScreenScore();

                controlClass.ChangeActiveGame();                 //Not activated
                Update();

                restartButton.SetActive(true);
                exitButton.SetActive(true);
            }
        }
    }
コード例 #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Eugenio")
        {
            finalScoreText.SetActive(true);
            UpdateScreenScore();

            controlClass.ChangeActiveGame();             //Not activated
            restartButton.SetActive(true);
            exitButton.SetActive(true);
        }
        else
        {
            Destroy(other.gameObject);
        }
    }
コード例 #3
0
    //COUROTINE
//	IEnumerator spawn() {
//
//		int time = 10;
//
//		while(time > 1) {
//			Vector3 spawnPosition = new Vector3(transform.position.x,
//			                                    transform.position.y,
//			                                    0.0f);
//			Quaternion spawnRotation = Quaternion.identity;
//			Instantiate(brick, spawnPosition, spawnRotation);
//
//			yield return new WaitForSeconds(1.0f);
//			time--;
//		}
//
//	}

    public void StartGame()
    {
        startButton.SetActive(false);
        controlClass.ChangeActiveGame();                //Playing
    }