Beispiel #1
0
        public AssetsFile CreateAssetsFile(IAssetCollection collection)
        {
            AssetsFile assetsFile = new AssetsFile(collection, Name);

            m_stream.Position = m_offset;
            assetsFile.Parse(m_stream);
            long read = m_stream.Position - m_offset;

            if (read != m_length)
            {
                //throw new Exception($"Read {read} but expected {m_length}");
            }
            return(assetsFile);
        }
        public SerializedFile ReadSerializedFile(IAssetCollection collection, string filePath)
        {
            SerializedFile file = new SerializedFile(collection, filePath, Name);

            m_stream.Position = m_offset;
            file.Read(m_stream);
            long read = m_stream.Position - m_offset;

            if (read != m_size)
            {
                //throw new System.Exception($"Read {read} but expected {m_length}");
            }
            return(file);
        }
Beispiel #3
0
        public AssetsFile(IAssetCollection collection, string filePath, string fileName)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            m_collection = collection;
            FilePath     = filePath;
            Name         = fileName.ToLower();
        }
        public SerializedFile(IAssetCollection collection, string filePath, string fileName)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException(nameof(fileName));
            }

            Collection = collection;
            FilePath   = filePath;
            Name       = fileName.ToLower();

            Header   = new SerializedFileHeader(Name);
            Metadata = new SerializedFileMetadata(Name);
        }
Beispiel #5
0
        public AssetsFile(IAssetCollection collection, string filepath)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (string.IsNullOrEmpty(filepath))
            {
                throw new ArgumentException("filepath");
            }

            m_collection = collection;
            FilePath     = filepath;
            Name         = Path.GetFileNameWithoutExtension(FilePath);
            if (Name == string.Empty)
            {
                throw new ArgumentException($"Can't obtain name from fullname {filepath}", "fullname");
            }
        }
Beispiel #6
0
 private void OnTextureAssetsAdded(IAssetCollection collection, Asset asset)
 {
 }
Beispiel #7
0
        /// <summary>
        /// Sets up class variables from the main Game1 class which will be useful for our game.
        /// Loads options from XML.
        /// MUST be called before LoadContent and Initialise.
        /// </summary>
        /// <param name="spriteBatch">The SpriteBatch from our Game1 class</param>
        /// <param name="viewport">The Viewport corresponding to the window</param>
        public void Setup(Game game, SpriteBatch spriteBatch, GraphicsDeviceManager graphics, InputManager inputManager, IAssetCollection assetCollectionTechnique = null)
        {
            // Check that we have called this before loading and initialising
            CheckShouldLoad();
            CheckShouldInitialise();

            Game                  = game;
            SpriteBatch           = spriteBatch;
            Content               = game.Content;
            Viewport              = game.GraphicsDevice.Viewport;
            GraphicsDeviceManager = graphics;

            ScreenDimensions = new Vector2(Viewport.Width, Viewport.Height);
            ScreenCentre     = ScreenDimensions * 0.5f;

            // Set our game to update on a fixed time step
            Game.IsFixedTimeStep = true;

            // Set our asset manager impl for cross platform asset loading
            AssetCollectionManager.AssetCollectionTechnique = assetCollectionTechnique;
            InputManager.Instance = inputManager;

            LoadContent();
            Initialise();
        }