Example #1
0
        internal void AddAdventurer(AdventurerCell cell)
        {
            ValidateCoordinate(cell.Coordinate.X, cell.Coordinate.Y);

            adventurerItems.Add(cell);
            adventurerCells.Add(cell);
        }
Example #2
0
        public void MoveAdventurer(string name, int xStep, int yStep)
        {
            AdventurerCell cell             = adventurerCells.Where(c => c.Name == name).First();
            int            targetX          = cell.Coordinate.X + xStep;
            int            targetY          = cell.Coordinate.Y + yStep;
            Coordinate     targetCoordinate = new Coordinate(targetX, targetY);

            if (CheckAdventureCanMoveTo(targetCoordinate))
            {
                adventurerItems.Remove(cell);
                cell.UpdateCoordinate(targetX, targetY);
                adventurerItems.Add(cell);
            }
        }
Example #3
0
 private static void PopulateMap(Map newMap, List <MapEntry> mapEntries)
 {
     foreach (var entry in mapEntries)
     {
         var adventurerEntry = entry as MapAdventurerEntry;
         if (adventurerEntry != null)
         {
             AdventurerCell cell = new AdventurerCell(adventurerEntry.Type, adventurerEntry.Name, new Coordinate(adventurerEntry.X, adventurerEntry.Y));
             newMap.AddAdventurer(cell);
         }
         else
         {
             Cell cell = new Cell(entry.Type, new Coordinate(((IMapCoordinate)entry).X, ((IMapCoordinate)entry).Y));
             newMap.AddCell(cell);
         }
     }
 }