Exemplo n.º 1
0
        /// <summary>
        /// Loads a texture file.
        /// </summary>
        /// <param name="filePath">Absolute path to TEXTURE.* file</param>
        /// <param name="usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="readOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string filePath, FileUsage usage, bool readOnly)
        {
            // Exit if this file already loaded
            if (managedFile.FilePath == filePath)
            {
                return(true);
            }

            // Validate filename
            string fn = Path.GetFileName(filePath);

            if (!fn.StartsWith("TEXTURE.", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            // Handle unsupported files
            if (!IsFilenameSupported(fn))
            {
                Console.WriteLine(string.Format("{0} is unsupported.", fn));
                return(false);
            }

            // Handle solid types
            if (fn == "TEXTURE.000")
            {
                solidType = SolidTypes.SolidColoursA;
            }
            else if (fn == "TEXTURE.001")
            {
                solidType = SolidTypes.SolidColoursB;
            }
            else
            {
                solidType = SolidTypes.None;
            }

            // Load file
            if (!managedFile.Load(filePath, usage, readOnly))
            {
                return(false);
            }

            // Attempt to load palette file from same path
            string arena2Path = Path.GetDirectoryName(filePath);

            LoadPalette(Path.Combine(arena2Path, PaletteName));

            // Read file
            if (!Read())
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public Solid(Entity entity, SolidTypes solidType) : base(entity)
        {
            SolidType = solidType;

            if (SolidType == SolidTypes.Block)
            {
                Collider            = (Collider)entity.AddComponent(new Collider(entity, Vector2.Zero, 16, 16));
                Collider.DebugColor = Color.Red;
            }
        }
        /// <summary>
        /// Loads a texture file.
        /// </summary>
        /// <param name="FilePath">Absolute path to TEXTURE.* file</param>
        /// <param name="Usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="ReadOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string FilePath, FileUsage Usage, bool ReadOnly)
        {
            // Exit if this file already loaded
            if (ManagedFile.FilePath == FilePath)
            {
                return(true);
            }

            // Validate filename
            FilePath = FilePath.ToUpper();
            string fn = Path.GetFileName(FilePath);

            if (!fn.StartsWith("TEXTURE."))
            {
                return(false);
            }

            // Handle unsupported files
            if (!IsFilenameSupported(fn))
            {
                Console.WriteLine(string.Format("{0} is unsupported.", fn));
                return(false);
            }

            // Handle solid types
            if (fn == "TEXTURE.000")
            {
                SolidType = SolidTypes.SolidColoursA;
            }
            else if (fn == "TEXTURE.001")
            {
                SolidType = SolidTypes.SolidColoursB;
            }
            else
            {
                SolidType = SolidTypes.None;
            }

            // Load file
            if (!ManagedFile.Load(FilePath, Usage, ReadOnly))
            {
                return(false);
            }

            // Read file
            if (!Read())
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads a texture file.
        /// </summary>
        /// <param name="filePath">Absolute path to TEXTURE.* file</param>
        /// <param name="usage">Specify if file will be accessed from disk, or loaded into RAM.</param>
        /// <param name="readOnly">File will be read-only if true, read-write if false.</param>
        /// <returns>True if successful, otherwise false.</returns>
        public override bool Load(string filePath, FileUsage usage, bool readOnly)
        {
            // Exit if this file already loaded
            if (managedFile.FilePath == filePath)
                return true;

            // Validate filename
            filePath = filePath.ToUpper();
            string fn = Path.GetFileName(filePath);
            if (!fn.StartsWith("TEXTURE."))
                return false;

            // Handle unsupported files
            if (!IsFilenameSupported(fn))
            {
                Console.WriteLine(string.Format("{0} is unsupported.", fn));
                return false;
            }

            // Handle solid types
            if (fn == "TEXTURE.000")
                solidType = SolidTypes.SolidColoursA;
            else if (fn == "TEXTURE.001")
                solidType = SolidTypes.SolidColoursB;
            else
                solidType = SolidTypes.None;

            // Handle spectral types
            if (fn == "TEXTURE.273" || fn == "TEXTURE.278")
                spectralType = SpectralTypes.Spectral;
            else
                spectralType = SpectralTypes.None;

            // Load file
            if (!managedFile.Load(filePath, usage, readOnly))
                return false;

            // Attempt to load palette file from same path
            string arena2Path = Path.GetDirectoryName(filePath);
            LoadPalette(Path.Combine(arena2Path, PaletteName));

            // Read file
            if (!Read())
                return false;

            return true;
        }