Exemplo n.º 1
0
        public Dictionary <Location, IAdventureLocation> Build(AdventureGame game)
        {
            var dungeon = new Dictionary <Location, IAdventureLocation>();

            try
            {
                // Must use a concrete type in instantiating dungeon locations ...
                var locations = GetType().Assembly.GetTypes().Where(t => typeof(AdventureLocation).IsAssignableFrom(t));

                foreach (var type in locations)
                {
                    if (type.Name == nameof(AdventureLocation))
                    {
                        continue;
                    }

                    var loc = Activator.CreateInstance(type, game) as AdventureLocation;
                    if (loc != null)
                    {
                        dungeon.Add(loc.LocationId, loc);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + ": " + ex.StackTrace);
            }

            return(dungeon);
        }
Exemplo n.º 2
0
 public Dungeon(AdventureGame game, IDungeonBuilder builder)
 {
     Locations = builder.Build(game);
 }
Exemplo n.º 3
0
 public CommandHandler(AdventureGame game)
 {
     _game            = game;
     _commandRegistry = new AdventureCommandRegistry(game);
 }