Ejemplo n.º 1
0
        public Dungeon GetDungeon(string id)
        {
            using (TinyIoCContainer requestContainer = _container.GetChildContainer())
            {
                Dungeon       result = null;
                IDungeonDepot depot  = requestContainer.Resolve <IDungeonDepot>();

                if (depot.ContainsKey(id))
                {
                    DungeonConfigEntity dungeonConfig = depot[id];
                    requestContainer.Register <DungeonConfigEntity>(dungeonConfig);

                    //TODO: Pull the generator by name stored in the config
                    IDungeonGenerator generator = requestContainer.Resolve <IDungeonGenerator>();

                    result = generator.Generate();
                }
                else if (id == _defaultId)
                {
                    // return the default dungeon
                    result = new Dungeon(_defaultId, _defaultSize, _defaultSize);
                }
                else
                {
                    throw new WebFaultException <string>(
                              string.Format("No dungeon exists with id {0}", id),
                              HttpStatusCode.NotFound);
                }


                return(result);
            }
        }
Ejemplo n.º 2
0
 public virtual DungeonNode GenerateDungeon()
 {
     Dungeon = generator.Generate(levelIndex++);
     return(Dungeon);
 }