Пример #1
0
 /// <summary>
 /// Make a specific tile group swallow all its neighboring groups.
 /// </summary>
 /// <param name="swallowingCard">The tile card which causes the swallowing of the other groups.</param>
 /// <param name="swallowingGroup">The group which swallows all its neighboring groups.</param>
 private static void SwallowGroups(TileCard swallowingCard, TileGroup swallowingGroup)
 {
     swallowingCard.Tile.Hotel = swallowingGroup.Hotel;
     var neighboringGroups = new List<TileGroup>();
     foreach (var neighbor in swallowingCard.Point.Neighbors)
     {
         if (Board.PointGroupDictionary.ContainsKey(neighbor) &&
             !neighboringGroups.Contains(Board.PointGroupDictionary[neighbor]) &&
             Board.PointGroupDictionary[neighbor] != swallowingGroup)
         {
             neighboringGroups.Add(Board.PointGroupDictionary[neighbor]);
         }
     }
     foreach (var group in neighboringGroups)
     {
         group.Tiles.ForEach(tile => Board.PointGroupDictionary.Remove(tile.Point));
         group.Tiles.ForEach(tile => tile.Hotel = swallowingGroup.Hotel);
         group.Tiles.ForEach(tile => Board.PointGroupDictionary.Add(tile.Point, swallowingGroup));
         swallowingGroup.AddTiles(group.Tiles);
         Board.TileGroups.Remove(group);
     }
     NotifyGroupChanged(swallowingGroup);
 }
Пример #2
0
        /// <summary>
        /// Puts a new tile on board.
        /// </summary>
        /// <param name="card">The tile card representing the tile to be put.</param>
        private static void PutTile(TileCard card)
        {
            card.Tile.Occupied = true;
            var group = new TileGroup(card.Tile);

            // Only for the pre-game putting of tiles where neighboring tiles do not set-up a new hotel.
            SwallowGroups(card, group);
        }
Пример #3
0
 /// <summary>
 /// Setup a new hotel on board.
 /// </summary>
 /// <param name="card">The card who caused the setup.</param>
 /// <param name="involvedHotel">The hotel chosen to be setup.</param>
 private static void SetUp(TileCard card, Hotel involvedHotel)
 {
     card.Tile.Occupied = true;
     var group = new TileGroup(card.Tile) { Hotel = involvedHotel };
     SwallowGroups(card, group);
 }
Пример #4
0
 /// <summary>
 /// Raises an event notifying a tile group has changed, so the game logic will be updated.
 /// </summary>
 /// <param name="changedGroup">The tile group which have been changed.</param>
 private static void NotifyGroupChanged(TileGroup changedGroup)
 {
     if (GroupChanged != null)
         GroupChanged(changedGroup, new EventArgs());
 }