예제 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            ResourceProvider.Instance.Initialize(GraphicsDevice, Content);

            var dungeonParser = new DungeonParser();

            dungeonParser.Parse();

            var renderers = new DefaulRenderers(Content, GraphicsDevice);
            var factoreis = new LegacyFactories(dungeonParser.Data, renderers);
            var theron    = new LegacyLeader(factoreis);

            var initializer = new LegacyMapBuilderInitializer();
            var builder     = new LegacyMapBuilder(initializer);

            initializer.Data        = dungeonParser.Data;
            initializer.ItemCreator = new LegacyItemCreator(builder);

            var wallActuatorCreator  = new WallActuatorCreator(builder);
            var floorActuatorCreator = new FloorActuatorCreator(builder);
            var sidesCreator         = new SidesCreator(builder, wallActuatorCreator, floorActuatorCreator);
            var logicActuatorCreator = new LogicActuatorCreator(builder);
            var creatureCreator      = new CreatureCreator(builder);

            initializer.TileCreator = new LegacyTileCreator(builder, sidesCreator, logicActuatorCreator, creatureCreator);
            initializer.Initialize();

            dungeon = new Dungeon(builder, factoreis, theron, GraphicsDevice);

            GameConsole.InitializeConsole(this, dungeon);
            GameConsole.Instance.DrawOrder = 1;
        }
예제 #2
0
        public LegacyMapBuilder()
        {
            var parser = new DungeonParser();

            parser.Parse();
            Data = parser.Data;

            ItemCreator = new LegacyItemCreator(this);

            WeaponFactories = Data.WeaponDescriptors
                              .Select(wd =>
            {
                var itemDescriptor = Data.GetItemDescriptor(ObjectCategory.Weapon, wd.Identifer);
                return(new WeaponItemFactory(wd.Name, wd.Weight, GetAttackFactories(itemDescriptor),
                                             ItemCreator.GetStorageTypes(itemDescriptor.CarryLocation),
                                             wd.DeltaEnergy, (WeaponClass)wd.Class, wd.KineticEnergy, wd.ShootDamage, wd.Strength));
            })
                              .ToArray();

            ClothFactories = Data.ArmorDescriptors
                             .Select(wd =>
            {
                var itemDescriptor = Data.GetItemDescriptor(ObjectCategory.Clothe, wd.Identifer);
                return(new ClothItemFactory(wd.Name, wd.Weight, GetAttackFactories(itemDescriptor)
                                            , ItemCreator.GetStorageTypes(itemDescriptor.CarryLocation)));
            })
                             .ToArray();;

            ContainerFactories = Data.ContainerDescriptors
                                 .Select(wd =>
            {
                var itemDescriptor = Data.GetItemDescriptor(ObjectCategory.Container, wd.Identifer);
                return(new ContainerItemFactory(wd.Name, wd.Weight, GetAttackFactories(itemDescriptor)
                                                , ItemCreator.GetStorageTypes(itemDescriptor.CarryLocation)));
            })
                                 .ToArray();

            ScrollFactories = Data.ScrollDescriptors
                              .Select(wd =>
            {
                var itemDescriptor = Data.GetItemDescriptor(ObjectCategory.Scroll, wd.Identifer);
                return(new ScrollItemFactory(wd.Name, wd.Weight, GetAttackFactories(itemDescriptor)
                                             , ItemCreator.GetStorageTypes(itemDescriptor.CarryLocation)));
            })
                              .ToArray();


            MiscFactories = Data.MiscDescriptors
                            .Select(wd =>
            {
                var itemDescriptor = Data.GetItemDescriptor(ObjectCategory.Miscellenaous, wd.Identifer);
                return(new MiscItemFactory(wd.Name, wd.Weight, GetAttackFactories(itemDescriptor)
                                           , ItemCreator.GetStorageTypes(itemDescriptor.CarryLocation)));
            })
                            .ToArray();

            PotionFactories = Data.PotionDescriptors
                              .Select(p =>
            {
                var itemDescriptor = Data.GetItemDescriptor(ObjectCategory.Potion, p.Identifer);
                return(new PotionItemFactory(p.Name, p.Weight, GetAttackFactories(itemDescriptor)
                                             , ItemCreator.GetStorageTypes(itemDescriptor.CarryLocation)));
            })
                              .ToArray();
        }