示例#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());
                }
            }
        }
示例#2
0
 public void DeleteSnake(SnakeProfile currentSnake)
 {
     Snakes.Remove(currentSnake);
     if (Snakes.Count > 0)
     {
         SelectedSnake = Snakes[0];
     }
     else
     {
         SelectedSnake = null;
     }
 }
示例#3
0
 public void SwitchPlayer()
 {
     if (hasPlayer == false)
     {
         AddPlayerSnake();
         hasPlayer = true;
     }
     else
     {
         Snakes.Remove(PlayerSnake);
         hasPlayer = false;
     }
 }