예제 #1
0
        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);
        }
예제 #2
0
 public static Item CreateItem()
 {
     if (RngThreadSafe.Next(1, 100) <= 20)
     {
         return(GetItem());
     }
     return(null);
 }
예제 #3
0
 /// <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);
 }
예제 #4
0
        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);
        }
예제 #5
0
        private static Item GetItem()
        {
            switch (RngThreadSafe.Next(1, 5))
            {
            case 1:
                return(new HealingPotion());

            case 2:
                return(new WoodenSword());

            default:
                return(new LinenArmor());
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        //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));
            }
        }
예제 #9
0
 //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);
 }
예제 #10
0
 //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;
 }