예제 #1
0
        /// <summary>
        /// Setup API file readers.
        /// </summary>
        private void SetupReaders()
        {
            // Try to setup Arena2-dependent content readers
            if (blockFileReader == null)
            {
                blockFileReader = new BlocksFile(Path.Combine(arena2Path, BlocksFile.Filename), FileUsage.UseMemory, true);
            }
            if (mapFileReader == null)
            {
                mapFileReader = new MapsFile(Path.Combine(arena2Path, MapsFile.Filename), FileUsage.UseMemory, true);
            }
            if (monsterFileReader == null)
            {
                monsterFileReader = new MonsterFile(Path.Combine(arena2Path, MonsterFile.Filename), FileUsage.UseMemory, true);
            }
            if (woodsFileReader == null)
            {
                woodsFileReader = new WoodsFile(Path.Combine(arena2Path, WoodsFile.Filename), FileUsage.UseMemory, true);
            }

            // Build map lookup dictionary
            if (mapDict == null && mapFileReader != null)
            {
                EnumerateMaps();
            }

            // Raise ready flag
            isReady = true;
        }
        /// <summary>
        /// Called to initialise core.
        /// </summary>
        public void Initialize()
        {
            // Create content manager
            contentManager = new ContentManager(serviceProvider, contentRootDirectory);

            // Create input
            input = new Input();
            input.ActiveDevices = Input.DeviceFlags.All;

            // Create empty scene
            scene = new Scene(this);

            // Initialise engine objects
            renderer.Initialize();

            // Get GraphicsDevice
            IGraphicsDeviceService graphicsDeviceService =
                (IGraphicsDeviceService)serviceProvider.GetService(typeof(IGraphicsDeviceService));

            this.graphicsDevice = graphicsDeviceService.GraphicsDevice;

            // Create sprite batch for rendering console and other overlays
            spriteBatch = new SpriteBatch(graphicsDevice);

            // Create Daggerfall managers.
            // MaterialManager must be created before ModelManager due to dependencies.
            this.materialManager = new MaterialManager(this);
            this.modelManager    = new ModelManager(this);
            this.blockManager    = new BlocksFile(Path.Combine(arena2Path, BlocksFile.Filename), FileUsage.UseDisk, true);
            this.mapManager      = new MapsFile(Path.Combine(arena2Path, MapsFile.Filename), FileUsage.UseDisk, true);
            this.soundManager    = new SndFile(Path.Combine(arena2Path, SndFile.Filename), FileUsage.UseDisk, true);

            // Load engine objects content
            renderer.LoadContent();
        }
예제 #3
0
        /// <summary>
        /// Setup API file readers.
        /// </summary>
        private void SetupReaders()
        {
            // Try to setup Arena2-dependent content readers
            if (blockFileReader == null)
            {
                blockFileReader = new BlocksFile(Path.Combine(arena2Path, BlocksFile.Filename), FileUsage.UseMemory, true);
            }
            if (mapFileReader == null)
            {
                mapFileReader = new MapsFile(Path.Combine(arena2Path, MapsFile.Filename), FileUsage.UseMemory, true);
            }
            if (monsterFileReader == null)
            {
                monsterFileReader = new MonsterFile(Path.Combine(arena2Path, MonsterFile.Filename), FileUsage.UseMemory, true);
            }
            if (woodsFileReader == null)
            {
                woodsFileReader = new WoodsFile(Path.Combine(arena2Path, WoodsFile.Filename), FileUsage.UseMemory, true);
            }
            if (factionFileReader == null)
            {
                factionFileReader = new FactionFile(GetFactionFilePath(), FileUsage.UseMemory, true);
            }
            if (flatsFileReader == null)
            {
                flatsFileReader = new FlatsFile(Path.Combine(arena2Path, FlatsFile.Filename), FileUsage.UseMemory, true);
            }
            if (paintFileReader == null)
            {
                paintFileReader = new PaintFile(Path.Combine(arena2Path, PaintFile.Filename), FileUsage.UseMemory, true);
            }

            // Raise ready flag
            isReady = true;
        }
예제 #4
0
        /// <summary>
        /// Setup API file readers.
        /// </summary>
        private void SetupReaders()
        {
            // Setup general content readers
            if (blockFileReader == null)
            {
                blockFileReader = new BlocksFile(Path.Combine(arena2Path, BlocksFile.Filename), FileUsage.UseMemory, true);
            }
            if (mapFileReader == null)
            {
                mapFileReader = new MapsFile(Path.Combine(arena2Path, MapsFile.Filename), FileUsage.UseMemory, true);
            }
            if (monsterFileReader == null)
            {
                monsterFileReader = new MonsterFile(Path.Combine(arena2Path, MonsterFile.Filename), FileUsage.UseMemory, true);
            }
            if (woodsFileReader == null)
            {
                woodsFileReader = new WoodsFile(Path.Combine(arena2Path, WoodsFile.Filename), FileUsage.UseMemory, true);
            }
            if (noise == null)
            {
                noise = new Noise();
            }

            // Build map lookup dictionary
            if (mapDict == null)
            {
                EnumerateMaps();
            }

            isReady = true;
        }
        /// <summary>
        /// Constructor. Accepts GraphicsDevice and Arena2 path.
        ///  Creates own content manager objects.
        /// </summary>
        /// <param name="graphicsDevice">GraphicsDevice.</param>
        /// <param name="arena2Path">Path to Arena2 folder.</param>
        public SceneBuilder(
            GraphicsDevice graphicsDevice,
            string arena2Path)
        {
            // Create managers
            this.textureManager = new TextureManager(graphicsDevice, arena2Path);
            this.modelManager   = new ModelManager(graphicsDevice, arena2Path);
            this.blocksFile     = new BlocksFile(
                Path.Combine(arena2Path, BlocksFile.Filename),
                FileUsage.UseDisk,
                true);
            this.mapsFile = new MapsFile(
                Path.Combine(arena2Path, MapsFile.Filename),
                FileUsage.UseDisk,
                true);

            // Create action link dictionary
            actionLinkDict = new Dictionary <int, ActionLink>();
        }
        private static bool AssignBlockIndices(ref DFLocation dfLocation)
        {
            ContentReader reader = DaggerfallUnity.Instance.ContentReader;

            if (reader != null)
            {
                BlocksFile blocksFile = reader.BlockFileReader;
                if (blocksFile != null)
                {
                    if (nextBlockIndex == 0)
                    {
                        nextBlockIndex = blocksFile.BsaFile.Count;
                    }

                    // RMB blocks
                    foreach (string blockName in dfLocation.Exterior.ExteriorData.BlockNames)
                    {
                        if (blocksFile.GetBlockIndex(blockName) == -1)
                        {
                            AssignNextIndex(blockName);
                        }
                    }

                    // RDB blocks
                    if (dfLocation.Dungeon.Blocks != null)
                    {
                        foreach (DFLocation.DungeonBlock dungeonBlock in dfLocation.Dungeon.Blocks)
                        {
                            string blockName = dungeonBlock.BlockName;
                            if (blocksFile.GetBlockIndex(blockName) == -1)
                            {
                                AssignNextIndex(blockName);
                            }
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        /// Constructor. Accepts pre-created TextureManager, ModelManager,
        ///  BlocksFile, and MapsFile objects.
        ///  These content managers cannot be NULL and must
        ///  be configured ready for use.
        /// </summary>
        /// <param name="textureManager">TextureManager.</param>
        /// <param name="modelManager">ModelManager</param>
        /// <param name="blocksFile">BlocksFile.</param>
        /// <param name="mapsFile">MapsFile.</param>
        public SceneBuilder(
            TextureManager textureManager,
            ModelManager modelManager,
            BlocksFile blocksFile,
            MapsFile mapsFile)
        {
            // Check managers non-null
            if (textureManager == null ||
                modelManager == null ||
                blocksFile == null ||
                mapsFile == null)
            {
                throw new Exception(
                          "One or more content managers are NULL.");
            }

            // Store
            this.textureManager = textureManager;
            this.modelManager   = modelManager;
            this.blocksFile     = blocksFile;
            this.mapsFile       = mapsFile;
        }