Exemplo n.º 1
0
 public void ForgeSnake(int SnakeTier)
 {
     if (ForgingSnake != null && ForgingSnake.Tier != SnakeTier)
     {
         DeforgeSnake();
     }
     if (ForgingSnake == null)
     {
         MoveDir ForgeSnakeFacing = Bodies.Count > 0 ? Bodies.Last.Value.FacingTail : GameController.OppositeDirection(Facing);
         ForgingSnake         = GameController.AddEnemySnake(Bodies.Last.Value.Position, SnakeTier, ForgeSnakeFacing);
         ForgingSnake.Forging = true;
     }
     else
     {
         if (Bodies.Count > 0)
         {
             ForgingSnake.AddTail(Bodies.Last.Value.Position, Bodies.Last.Value.FacingTail, false);
         }
         else
         {
             ForgingSnake.AddTail(Bodies.Last.Value.Position, GameController.OppositeDirection(Facing), false);
         }
         ForgingSnake.Length++;
     }
 }
Exemplo n.º 2
0
    private void Snake_OnCollision(BaseObject baseObject)
    {
        if (baseObject is Border)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }

        if (baseObject is Tail)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }

        if (baseObject is Border)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }

        if (baseObject is Food)
        {
            Destroy(baseObject.gameObject);

            foodSpawn.Spawn();

            sceneUI.Score.Value++;

            snake.AddTail();
        }
        if (baseObject is SpecialFood1)
        {
            Destroy(baseObject.gameObject);
            sFoodSpawn1.Spawn();
            //score++;
        }
        if (baseObject is SpecialFood2)
        {
            Destroy(baseObject.gameObject);
            sFoodSpawn2.Spawn();
            //score++;
        }
    }