Пример #1
0
 private void OnMouseDown()
 {
     isClicked = true;
     tileSpawner.UnselectTile();
     if (gameObject.tag == "Start tile" || gameObject.tag == "End tile")
     {
         tileSpawner.CheckButtons();
     }
 }
Пример #2
0
 public void ChangeDimension()
 {
     if (GetButtonText() == "3D" && CheckStartEndTiles())
     {
         m_OrthographicCamera.gameObject.SetActive(false);
         m_PerspectiveCamera.gameObject.SetActive(true);
         SetButtonText("2D");
         lines.gameObject.SetActive(false);
         foreach (Button button in buttons)
         {
             button.gameObject.SetActive(false);
         }
         coinTiles = GameObject.FindGameObjectsWithTag("Coin");
         foreach (GameObject coinTile in coinTiles)
         {
             coinTile.GetComponent <Coin>().SetAnimation(true);
             coinTile.GetComponent <Coin>().SetIs3DScene(true);
         }
         GameObject[] platformTiles;
         platformTiles = GameObject.FindGameObjectsWithTag("Moving Platform");
         foreach (GameObject platformTile in platformTiles)
         {
             platformTile.GetComponent <Tile>().SetAnimation(true);
             platformTile.GetComponent <BoxCollider>().enabled = false;
             foreach (Transform child in platformTile.transform)
             {
                 if (child.tag == "Transparent")
                 {
                     child.gameObject.SetActive(false);
                 }
                 if (child.tag == "Moving")
                 {
                     child.gameObject.GetComponent <BoxCollider>().enabled = true;
                 }
             }
         }
         GameObject startTile    = GameObject.FindGameObjectWithTag("Start tile");
         Vector3    startTilePos = startTile.transform.position;
         Vector3    ballPos      = new Vector3(startTilePos.x, startTilePos.y + 1, startTilePos.z);
         ball = Instantiate(ballPrefab, ballPos, startTile.transform.rotation);
         Tile[] tiles = FindObjectsOfType <Tile>();
         foreach (Tile tile in tiles)
         {
             tile.SetIs3DScene(true);
         }
         SetAllGameObjects();
     }
     else
     {
         m_OrthographicCamera.gameObject.SetActive(true);
         m_PerspectiveCamera.gameObject.SetActive(false);
         SetButtonText("3D");
         lines.gameObject.SetActive(true);
         foreach (Button button in buttons)
         {
             button.gameObject.SetActive(true);
             tileSpawner.CheckButtons();
         }
         foreach (GameObject coinTile in coinTiles)
         {
             coinTile.gameObject.SetActive(true);
             coinTile.GetComponent <Coin>().SetAnimation(false);
             coinTile.GetComponent <Coin>().SetIs3DScene(false);
         }
         GameObject[] platformTiles;
         platformTiles = GameObject.FindGameObjectsWithTag("Moving Platform");
         foreach (GameObject platformTile in platformTiles)
         {
             platformTile.GetComponent <Tile>().SetAnimation(false);
             platformTile.GetComponent <BoxCollider>().enabled = true;
             foreach (Transform child in platformTile.transform)
             {
                 if (child.tag == "Transparent")
                 {
                     child.gameObject.SetActive(true);
                 }
                 if (child.tag == "Moving")
                 {
                     child.gameObject.GetComponent <BoxCollider>().enabled = false;
                 }
             }
         }
         Tile[] tiles = FindObjectsOfType <Tile>();
         foreach (Tile tile in tiles)
         {
             tile.SetIs3DScene(false);
         }
         Destroy(ball);
     }
 }