Пример #1
0
 public void DestroyPiece()
 {
     if (GetComponent <Snake>())
     {
         Destroy(transform.parent.gameObject);
         return;
     }
     if (nextPiece)
     {
         nextPiece.DestroyPiece();
     }
     Destroy(gameObject);
 }
Пример #2
0
 void CheckForCollisions()
 {
     for (int i = 0; i < SnakeManager.snakeList.Count; ++i)
     {
         if (SnakeManager.snakeList[i] != this)
         {
             SnakePiece piece = SnakeManager.snakeList[i].CheckForCollision(transform.position);
             if (piece)
             {
                 if (chargeCounter > 0.0f)
                 {
                     piece.DestroyPiece();
                 }
             }
         }
     }
 }
Пример #3
0
 // Update is called once per frame
 void Update()
 {
     transform.Translate(m_MoveDirection * 0.5f);
     if (transform.position.y > Snake.maxY || transform.position.y < Snake.minY || transform.position.x > Snake.maxX || transform.position.x < Snake.minX)
     {
         Destroy(gameObject);
         return;
     }
     for (int i = 0; i < SnakeManager.snakeList.Count; ++i)
     {
         SnakePiece piece = SnakeManager.snakeList[i].CheckForCollision(transform.position);
         if (piece)
         {
             piece.DestroyPiece();
             Destroy(gameObject);
         }
     }
 }