コード例 #1
0
ファイル: Player.cs プロジェクト: albertnez/velocicube
 // When colliding with something
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Obstacle"))
     {
         Game.GameOver();
     }
     else if (other.CompareTag("Coin"))
     {
         Game.CollectCoin();
         scoreSlider.value += 1;
         // Advance level.
         if (scoreSlider.value >= scoreSlider.maxValue && levelManager.HasNextLevel())
         {
             Game.FullCoins();
             scoreSlider.value = 0;
             levelManager.NextLevel();
             Instantiate(levelExplosion, transform.position, transform.rotation);
         }
         else
         {
             Instantiate(coinExplosion, transform.position, transform.rotation);
         }
         Destroy(other.gameObject);
     }
     else if (!changingState)
     {
         if (other.CompareTag("RightWall") && FloorWall != Floor.Right)
         {
             if (FloorWall == Floor.Bottom)
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, 90.0f);
                 //StartCoroutine(SmoothRotate(90.0f, 1.0f));
             }
             else
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, -90.0f);
             }
             FloorWall = Floor.Right;
             cameraScript.SmoothRotate(FloorWall);
         }
         else if (other.CompareTag("LeftWall") && FloorWall != Floor.Left)
         {
             if (FloorWall == Floor.Top)
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, 90.0f);
             }
             else
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, -90.0f);
             }
             FloorWall = Floor.Left;
             cameraScript.SmoothRotate(FloorWall);
         }
         else if (other.CompareTag("TopWall") && FloorWall != Floor.Top)
         {
             if (FloorWall == Floor.Right)
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, 90.0f);
             }
             else
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, -90.0f);
             }
             FloorWall = Floor.Top;
             cameraScript.SmoothRotate(FloorWall);
         }
         else if (other.CompareTag("BottomWall") && FloorWall != Floor.Bottom)
         {
             if (FloorWall == Floor.Left)
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, 90.0f);
             }
             else
             {
                 gameObject.transform.Rotate(0.0f, 0.0f, -90.0f);
             }
             FloorWall = Floor.Bottom;
             cameraScript.SmoothRotate(FloorWall);
         }
     }
 }