예제 #1
0
        private static DirSheet getDirSheetCache(string num, string pattern, LRUCache <string, DirSheet> cache)
        {
            DirSheet sheet;

            if (cache.TryGetValue(num, out sheet))
            {
                return(sheet);
            }

            try
            {
                if (System.IO.File.Exists(String.Format(pattern, num)))
                {
                    //read file and read binary data
                    using (FileStream stream = File.OpenRead(String.Format(pattern, num)))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                        {
                            sheet = DirSheet.Load(reader);
                            cache.Add(num, sheet);
                            return(sheet);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogError(new Exception("Error loading " + String.Format(pattern, num) + "\n", ex));
            }
            DirSheet newSheet = DirSheet.LoadError();

            cache.Add(num, newSheet);
            return(newSheet);
        }
예제 #2
0
        public static DirSheet GetAttackSheet(string num)
        {
            IEffectAnim sheet;

            if (vfxCache.TryGetValue("Particle-" + num, out sheet))
            {
                return((DirSheet)sheet);
            }

            try
            {
                if (File.Exists(String.Format(PARTICLE_PATTERN, num)))
                {
                    //read file and read binary data
                    using (FileStream fileStream = File.OpenRead(String.Format(PARTICLE_PATTERN, num)))
                    {
                        using (BinaryReader reader = new BinaryReader(fileStream))
                        {
                            sheet = DirSheet.Load(reader);
                            vfxCache.Add("Particle-" + num, sheet);
                            return((DirSheet)sheet);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogError(new Exception("Error loading " + String.Format(PARTICLE_PATTERN, num) + "\n", ex));
            }
            DirSheet newSheet = DirSheet.LoadError();

            vfxCache.Add("Particle-" + num, newSheet);
            return(newSheet);
        }