Exemplo n.º 1
0
        public override void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            if (Finished)
            {
                return;
            }

            Loc       drawLoc = GetDrawLoc(offset);
            CharSheet sheet   = GraphicsManager.GetChara(Appearance);

            sheet.DrawCharFrame(spriteBatch, CurrentAnim, true, Direction, drawLoc.ToVector2(), Frame, Color.White * ((float)Alpha / 255));
        }
Exemplo n.º 2
0
        public static CharSheet GetChara(MonsterID data)
        {
            data = GetFallbackForm(CharaIndex, data);

            CharSheet sheet;

            if (spriteCache.TryGetValue(data, out sheet))
            {
                return(sheet);
            }

            if (data.IsValid())
            {
                try
                {
                    using (FileStream stream = File.OpenRead(String.Format(CHARA_PATTERN, data.Species)))
                    {
                        using (BinaryReader reader = new BinaryReader(stream))
                        {
                            long position = CharaIndex.GetPosition(data.Species, data.Form, (int)data.Skin, (int)data.Gender);
                            // Jump to the correct position
                            stream.Seek(position, SeekOrigin.Begin);
                            sheet = CharSheet.Load(reader);
                            spriteCache.Add(data, sheet);
                            return(sheet);
                        }
                    }
                }
                catch (Exception ex)
                {
                    DiagManager.Instance.LogError(new Exception("Error loading chara " + data.Species + " " + data.Form + "-" + data.Skin + "-" + data.Gender + "\n", ex));
                }
            }

            //add error sheet
            CharSheet error = CharSheet.LoadError();

            spriteCache.Add(data, error);
            return(error);
        }