public Coords PlaceGold(IEnumerable <Client> clients) { var coords = GetRandomFreeCoords(clients); GameMap[coords.X, coords.Y].Gold = RandomizationFunctions.GetRandomNumber(10, 50); return(coords); }
public Coords CreatePotion(IEnumerable <Client> clients) { var coords = GetRandomFreeCoords(clients); var health = RandomizationFunctions.GetRandomNumber(1, 100); GameMap[coords.X, coords.Y].Health = health; return(coords); }
public Coords GetRandomFreeCoords(IEnumerable <Client> clients) { Coords coords = null; var tileIsFree = false; do { coords = new Coords( RandomizationFunctions.GetRandomNumber(0, GameMap.GetLength(0) - 1), RandomizationFunctions.GetRandomNumber(0, GameMap.GetLength(1) - 1) ); if (GameMap[coords.X, coords.Y].HasGold || GameMap[coords.X, coords.Y].IsCaveWall || GameMap[coords.X, coords.Y].HasHealth) { continue; } tileIsFree = true; foreach (var client in clients) { var player = client.Player; if (player == null) { continue; } if (player.Coordinates.X == coords.X && player.Coordinates.Y == coords.Y) { tileIsFree = false; break; } } } while (!tileIsFree); return(coords); }