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