Exemplo n.º 1
0
        public Point GetRandomNeighbour(Point roomToConnect)
        {
            Direction[] allDirections = (Direction[])Enum.GetValues(typeof(Direction));
            Direction   direction     = Chance.RandomElement(allDirections);

            return(roomToConnect.Add(direction));
        }
Exemplo n.º 2
0
        private string GetRoomDescription()
        {
            if (streetNames.Count == 0)
            {
                return("A busy street in London.");
            }
            var result = Chance.RandomElement(streetNames);

            streetNames.Remove(result);
            return(result.Substring(0, result.Length - 1));
        }
Exemplo n.º 3
0
 private void AddExtraConnections(int extras)
 {
     if (Width < 3 || Height < 3)
     {
         return;
     }
     for (int i = 0; i < extras; ++i)
     {
         var roomToConnect  = new Point(Chance.Between(1, Width - 1), Chance.Between(1, Height - 1));
         var neighbourPoint = GetRandomNeighbour(roomToConnect);
         Connect(roomToConnect, neighbourPoint);
     }
 }
Exemplo n.º 4
0
        public int GenerateDamage()
        {
            const int maxBonusDamage = 10;
            int       bonusDamage    = Chance.Between(0, maxBonusDamage);

            int damage = Strength + bonusDamage;

            if (EquippedWeapon != null)
            {
                damage += EquippedWeapon.Strength;
            }
            return(damage);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Create rooms next to the current one as long as there are still null neighbours
 /// </summary>
 /// <param name="fromPoint"></param>
 private void CreateNeighbour(Point fromPoint)
 {
     while (true)
     {
         List <Point> options = ListEmptyNeighbours(fromPoint);
         if (options.Count == 0)
         {
             return;
         }
         Point destPoint = Chance.RandomElement(options);
         Rooms[destPoint.X, destPoint.Y] = new Room(GetRoomDescription(), destPoint);
         Connect(fromPoint, destPoint);
         CreateNeighbour(destPoint); //recursive step
     }
 }
Exemplo n.º 6
0
        public Room GetRandomOtherRoom(Room currentRoom)
        {
            List <Room> otherRooms = new List <Room>();

            foreach (Room room in this)
            {
                if (room.LocationOfRoom != currentRoom.LocationOfRoom)
                {
                    otherRooms.Add(room);
                }
            }
            if (otherRooms.Count == 0)
            {
                return(null);
            }
            return(Chance.RandomElement(otherRooms));
        }
Exemplo n.º 7
0
 public Point GetRandomRoom()
 {
     return(new Point(Chance.Between(0, Width), Chance.Between(0, Height)));
 }