private RiverPath SelectRandomPath(List <RiverPath> PossibleRiverPaths) { altitudeChanged = false; int randomInt = (PossibleRiverPaths.Count == 0) ? 0:RngThreadSafe.Next(0, (PossibleRiverPaths.Count)); RiverPath chosenRiverPath = PossibleRiverPaths[randomInt]; return(chosenRiverPath); }
public static Item CreateItem() { if (RngThreadSafe.Next(1, 100) <= 20) { return(GetItem()); } return(null); }
/// <summary> /// Randomly creates monster based on percentage value /// </summary> /// <param name="location">location to add the monster to</param> /// <returns></returns> public static Monster CreateMonster(Location location) { if (RngThreadSafe.Next(_noChance, _fullChance) <= percentChance) { return(GetMonster(location)); } return(null); }
private static coordinate NextTile(Continent continent, List <int> listOfOptions) { var randomNumber = RngThreadSafe.Next(0, listOfOptions.Count); var tileToExpandFrom = continent.SurfaceArea[listOfOptions[randomNumber]]; listOfOptions.RemoveAt(randomNumber); return(tileToExpandFrom); }
private static Item GetItem() { switch (RngThreadSafe.Next(1, 5)) { case 1: return(new HealingPotion()); case 2: return(new WoodenSword()); default: return(new LinenArmor()); } }
private static Location GetTile(int x, int y) { Location result = null; switch (RngThreadSafe.Next(1, 3)) { case 1: result = new Forest(x, y); break; case 2: result = new Plains(x, y); break; default: result = new Lake(x, y); break; } return(result); }
private static coordinate SearchNewPaths(coordinate coordinate, Continent continent, List <coordinate> map) { var coordX = coordinate.X; var coordY = coordinate.Y; List <coordinate> newPaths = new List <coordinate>(); if (coordX != continent.MapXSize) { coordinate northCoordinate = new coordinate(coordX + 1, coordY); if (!map.Contains(northCoordinate)) { newPaths.Add(northCoordinate); } } if (coordX != 1) { coordinate southCoordinate = new coordinate(coordX - 1, coordY); if (!map.Contains(southCoordinate)) { newPaths.Add(southCoordinate); } } if (coordY != 1) { coordinate westCoordinate = new coordinate(coordX, coordY - 1); if (!map.Contains(westCoordinate)) { newPaths.Add(westCoordinate); } } if (coordY != continent.MapYSize) { coordinate eastCoordinate = new coordinate(coordX, coordY + 1); if (!map.Contains(eastCoordinate)) { newPaths.Add(eastCoordinate); } } if (newPaths.Count() == 0) { return(null); } var randomIndex = RngThreadSafe.Next(0, newPaths.Count()); var newLocation = newPaths[randomIndex]; return(newLocation); }
//Generate random new Monster private static Monster GetMonster(Location location) { switch (RngThreadSafe.Next(1, 6)) { case 1: return(new Boar(location)); case 2: return(new KoboldWarrior(location)); case 3: return(new KoboldGatherer(location)); case 4: return(new KoboldHunter(location)); default: return(new Deer(location)); } }
//Randomly select a location surrounding the tile you expand from private static Location NewMountain(int x, int y, List<Location> mountainRange, ICollection<Location> map) { var possibleNewMountains = map.Where(l => (mountainRange.SingleOrDefault(d => d.XCoord == l.XCoord && d.YCoord == l.YCoord) == null) && ((l.XCoord == x+1 && l.YCoord == y && !(l is Mountain)) || (l.XCoord == x-1 && l.YCoord == y && !(l is Mountain)) || (l.XCoord == x && l.YCoord == y+1 && !(l is Mountain)) || (l.XCoord == x && l.YCoord == y-1 && !(l is Mountain))) ).ToList(); if (possibleNewMountains.Count() == 0) { return null; } var randomIndex = RngThreadSafe.Next(0, possibleNewMountains.Count()); var newLocation = possibleNewMountains[randomIndex]; return new Mountain(newLocation.XCoord, newLocation.YCoord); }
//Randomly selects the next tile to expand from within the MountainRange private static Location NextTile(List<Location> mountainRange, ICollection<Location> map) { var randomNumber = RngThreadSafe.Next(0, mountainRange.Count); var tileToExpandFrom = mountainRange[randomNumber]; return tileToExpandFrom; }