Пример #1
0
        public static AnimSheet GetSpellSheet(SpellAnimType animType, int num)
        {
            AnimSheet cacheSheet = spellCache.Get(animType.ToString() + num);

            if (cacheSheet != null)
            {
                return(cacheSheet);
            }

            if (File.Exists(Paths.EffectsPath + animType.ToString() + "-" + num + ".png"))
            {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.EffectsPath + animType.ToString() + "-" + num + ".png");
                sheet.LoadTextureFromPixels32();
                switch (animType)
                {
                case SpellAnimType.Spell:
                    sheet.GenerateDataBuffer(1, 1);
                    break;

                case SpellAnimType.Arrow:
                    sheet.GenerateDataBuffer(8, 1);
                    break;

                case SpellAnimType.Beam:
                    sheet.GenerateDataBuffer(8, 4);
                    break;
                }
                spellCache.Add(animType.ToString() + num, sheet);
                return(sheet);
            }
            spellCache.Add(animType.ToString() + num, ErrorTexture);
            return(ErrorTexture);
        }
Пример #2
0
        public static void Init()
        {
            //run conversions
            if (!Directory.Exists(Paths.CachedGFXPath))
            {
                Directory.CreateDirectory(Paths.CachedGFXPath);
            }

            Conversion.CompileAllSprites(Paths.SpritesPath, Paths.CachedGFXPath + "Sprite");
            Conversion.CompileAllTiles(Paths.TilesPath, Paths.CachedGFXPath + "Tile");
            Conversion.CompileAllPortraits(Paths.PortraitsPath, Paths.CachedGFXPath + "Portrait");

            Game.UpdateLoadMsg("Loading Base Textures");
            //load error texture
            ErrorTexture = new AnimSheet();
            ErrorTexture.LoadPixelsFromFile32(Paths.BaseGFXPath + "Error.png");

            //load blank texture
            BlankTexture = new Texture();
            BlankTexture.LoadPixelsFromFile32(Paths.BaseGFXPath + "UI\\Blank.png");

            //load menu data
            MenuBack = new TileSheet();
            MenuBack.LoadPixelsFromFile32(Paths.BaseGFXPath + "UI\\Back.png");

            Picker = new TileSheet();
            Picker.LoadPixelsFromFile32(Paths.BaseGFXPath + "UI\\Picker.png");


            Game.UpdateLoadMsg("Loading Caches");
            //initialize caches
            spriteCache = new MultiNameLRUCache <string, SpriteSheet>(SPRITE_CACHE_SIZE);
            spriteCache.OnItemRemoved = DisposeCachedObject;
            mugshotCache = new MultiNameLRUCache <string, TileSheet>(MUGSHOT_CACHE_SIZE);
            mugshotCache.OnItemRemoved = DisposeCachedObject;
            spellCache = new LRUCache <string, AnimSheet>(SPELL_CACHE_SIZE);
            spellCache.OnItemRemoved = DisposeCachedObject;
            statusCache = new LRUCache <int, AnimSheet>(STATUS_CACHE_SIZE);
            statusCache.OnItemRemoved = DisposeCachedObject;
            itemCache = new LRUCache <int, AnimSheet>(ITEM_CACHE_SIZE);
            itemCache.OnItemRemoved   = DisposeCachedObject;
            objectCache               = new LRUCache <int, AnimSheet>(OBJECT_CACHE_SIZE);
            objectCache.OnItemRemoved = DisposeCachedObject;
            tileCache = new LRUCache <string, Texture>(TILE_CACHE_SIZE);
            tileCache.OnItemRemoved = DisposeCachedObject;

            //load metadata
            tileData = new TileMetadata[TOTAL_TILE_SHEETS];
        }
Пример #3
0
        public static AnimSheet GetItemSheet(int num)
        {
            AnimSheet cacheSheet = itemCache.Get(num);

            if (cacheSheet != null)
            {
                return(cacheSheet);
            }

            if (File.Exists(Paths.ItemsPath + num + ".png"))
            {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.ItemsPath + num + ".png");
                sheet.LoadTextureFromPixels32();
                sheet.GenerateDataBuffer(1, 1);
                itemCache.Add(num, sheet);
                return(sheet);
            }
            itemCache.Add(num, ErrorTexture);
            return(ErrorTexture);
        }
Пример #4
0
        public static AnimSheet GetStatusSheet(int num)
        {
            AnimSheet cacheSheet = statusCache.Get(num);

            if (cacheSheet != null)
            {
                return(cacheSheet);
            }

            if (File.Exists(Paths.DataPath + "\\Graphics\\Status\\Status-" + num + ".png"))
            {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.DataPath + "\\Graphics\\Status\\Status-" + num + ".png");
                sheet.LoadTextureFromPixels32();
                sheet.GenerateDataBuffer(1, 1);
                statusCache.Add(num, sheet);
                return(sheet);
            }
            statusCache.Add(num, ErrorTexture);
            return(ErrorTexture);
        }
Пример #5
0
        public static AnimSheet GetObjectSheet(int num)
        {
            AnimSheet cacheSheet = objectCache.Get(num);

            if (cacheSheet != null)
            {
                return(cacheSheet);
            }

            if (System.IO.File.Exists(Paths.DataPath + "Graphics\\Object\\Object-" + num + ".png"))
            {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.DataPath + "Graphics\\Object\\Object-" + num + ".png");
                sheet.LoadTextureFromPixels32();
                sheet.GenerateDataBuffer(1, 1);
                objectCache.Add(num, sheet);
                return(sheet);
            }

            objectCache.Add(num, ErrorTexture);
            return(ErrorTexture);
        }
Пример #6
0
        public static void Init()
        {
            //run conversions
            if (!Directory.Exists(Paths.CachedGFXPath))
                Directory.CreateDirectory(Paths.CachedGFXPath);

            Conversion.CompileAllSprites(Paths.SpritesPath, Paths.CachedGFXPath + "Sprite");
            Conversion.CompileAllTiles(Paths.TilesPath, Paths.CachedGFXPath + "Tile");
            Conversion.CompileAllPortraits(Paths.PortraitsPath, Paths.CachedGFXPath + "Portrait");

            Game.UpdateLoadMsg("Loading Base Textures");
            //load error texture
            ErrorTexture = new AnimSheet();
            ErrorTexture.LoadPixelsFromFile32(Paths.BaseGFXPath+"Error.png");

            //load blank texture
            BlankTexture = new Texture();
            BlankTexture.LoadPixelsFromFile32(Paths.BaseGFXPath + "UI\\Blank.png");

            //load menu data
            MenuBack = new TileSheet();
            MenuBack.LoadPixelsFromFile32(Paths.BaseGFXPath + "UI\\Back.png");

            Picker = new TileSheet();
            Picker.LoadPixelsFromFile32(Paths.BaseGFXPath + "UI\\Picker.png");

            Game.UpdateLoadMsg("Loading Caches");
            //initialize caches
            spriteCache = new MultiNameLRUCache<string, SpriteSheet>(SPRITE_CACHE_SIZE);
            spriteCache.OnItemRemoved = DisposeCachedObject;
            mugshotCache = new MultiNameLRUCache<string, TileSheet>(MUGSHOT_CACHE_SIZE);
            mugshotCache.OnItemRemoved = DisposeCachedObject;
            spellCache = new LRUCache<string, AnimSheet>(SPELL_CACHE_SIZE);
            spellCache.OnItemRemoved = DisposeCachedObject;
            statusCache = new LRUCache<int, AnimSheet>(STATUS_CACHE_SIZE);
            statusCache.OnItemRemoved = DisposeCachedObject;
            itemCache = new LRUCache<int, AnimSheet>(ITEM_CACHE_SIZE);
            itemCache.OnItemRemoved = DisposeCachedObject;
            objectCache = new LRUCache<int, AnimSheet>(OBJECT_CACHE_SIZE);
            objectCache.OnItemRemoved = DisposeCachedObject;
            tileCache = new LRUCache<string, Texture>(TILE_CACHE_SIZE);
            tileCache.OnItemRemoved = DisposeCachedObject;

            //load metadata
            tileData = new TileMetadata[TOTAL_TILE_SHEETS];
        }
Пример #7
0
        public static AnimSheet GetStatusSheet(int num)
        {
            AnimSheet cacheSheet = statusCache.Get(num);
            if (cacheSheet != null) return cacheSheet;

            if (System.IO.File.Exists(Paths.DataPath + "\\Graphics\\Status\\Status-" + num + ".png"))
            {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.DataPath + "\\Graphics\\Status\\Status-" + num + ".png");
                sheet.LoadTextureFromPixels32();
                sheet.GenerateDataBuffer(1, 1);
                statusCache.Add(num, sheet);
                return sheet;
            }
            statusCache.Add(num, ErrorTexture);
            return ErrorTexture;
        }
Пример #8
0
        public static AnimSheet GetSpellSheet(SpellAnimType animType, int num)
        {
            AnimSheet cacheSheet = spellCache.Get(animType.ToString() + num);
            if (cacheSheet != null) return cacheSheet;

            if (System.IO.File.Exists(Paths.EffectsPath + animType.ToString() + "-" + num + ".png")) {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.EffectsPath + animType.ToString() + "-" + num + ".png");
                sheet.LoadTextureFromPixels32();
                switch (animType) {
                    case SpellAnimType.Spell:
                        sheet.GenerateDataBuffer(1, 1);
                        break;
                    case SpellAnimType.Arrow:
                        sheet.GenerateDataBuffer(8, 1);
                        break;
                    case SpellAnimType.Beam:
                        sheet.GenerateDataBuffer(8, 4);
                        break;
                }
                spellCache.Add(animType.ToString() + num, sheet);
                return sheet;
            }
            spellCache.Add(animType.ToString() + num, ErrorTexture);
            return ErrorTexture;
        }
Пример #9
0
        public static AnimSheet GetItemSheet(int num)
        {
            AnimSheet cacheSheet = itemCache.Get(num);
            if (cacheSheet != null) return cacheSheet;

            if (System.IO.File.Exists(Paths.ItemsPath + num + ".png")) {
                AnimSheet sheet = new AnimSheet();
                sheet.LoadPixelsFromFile32(Paths.ItemsPath + num + ".png");
                sheet.LoadTextureFromPixels32();
                sheet.GenerateDataBuffer(1, 1);
                itemCache.Add(num, sheet);
                return sheet;
            }
            itemCache.Add(num, ErrorTexture);
            return ErrorTexture;
        }