Exemplo n.º 1
0
        private void MoveSnakes()
        {
            foreach (var snake in Snakes.ToArray())
            {
                if (snake.TurnsHasNotEaten == Params.SnakeTurnToDie)
                {
                    Snakes.Remove(snake);
                }

                if (snake.IsStarving)
                {
                    var isDead = snake.StarvingSnakeTurn();

                    if (isDead)
                    {
                        Snakes.Remove(snake);
                    }
                }
                else
                {
                    var headLocation = snake.HeadLocation;

                    snake.MoveSnake(GetRandomGrassCell(headLocation));
                }

                if (snake.ShouldSplit)
                {
                    Snakes.Add(snake.SplitSnake());
                }
            }
        }
Exemplo n.º 2
0
 public void DeleteSnake(SnakeProfile currentSnake)
 {
     Snakes.Remove(currentSnake);
     if (Snakes.Count > 0)
     {
         SelectedSnake = Snakes[0];
     }
     else
     {
         SelectedSnake = null;
     }
 }
Exemplo n.º 3
0
 public void SwitchPlayer()
 {
     if (hasPlayer == false)
     {
         AddPlayerSnake();
         hasPlayer = true;
     }
     else
     {
         Snakes.Remove(PlayerSnake);
         hasPlayer = false;
     }
 }