예제 #1
0
        public bool LoadFromElement(XElement e)
        {
            foreach (XAttribute a in e.Attributes())
            {
                switch (a.Name.LocalName.ToLower())
                {
                case "id":
                    InGameId = a.Value.ToIntFromHex();
                    break;

                case "width":
                    Width = a.Value.ToInt();
                    break;

                case "height":
                    Height = a.Value.ToInt();
                    break;

                case "name":
                    Name = a.Value;
                    break;

                case "class":
                    Class = a.Value.ToInt();
                    break;

                case "group":
                    Group = a.Value;
                    break;

                case "proxy":
                    ProxyId = a.Value.ToInt();
                    break;
                }
            }

            foreach (var x in e.Elements("sprite"))
            {
                SpriteInfo s = new SpriteInfo();
                s.LoadFromElement(x);
                Sprites.Add(s);
                if (s.X > MaxRightX)
                {
                    MaxRightX = s.X;
                }
                if (s.X < MaxLeftX)
                {
                    MaxLeftX = s.X;
                }
                if (s.Y > MaxBottomY)
                {
                    MaxBottomY = s.Y;
                }
                if (s.Y < MaxTopY)
                {
                    MaxTopY = s.Y;
                }
            }

            foreach (var p in e.Elements("property"))
            {
                PropertyDescriptions.Add(p.Value);
            }

            if (MaxLeftX < 0 && MaxLeftX % 16 != 0)
            {
                MaxLeftX -= 16;
            }

            MaxLeftX = (MaxLeftX / 16) * 16;// -(MaxLeftX % 8);

            if (MaxRightX % 16 != 0)
            {
                MaxRightX += 16;
            }

            MaxRightX = ((MaxRightX / 16) + 1) * 16;// -(MaxRightX % 8);

            if (MaxTopY < 0 && MaxTopY % 16 != 0)
            {
                MaxTopY -= 16;
            }
            MaxTopY = (MaxTopY / 16) * 16;// -8 - (MaxTopY % 8);

            if (MaxBottomY % 16 != 0)
            {
                MaxBottomY += 16;
            }

            MaxBottomY = ((MaxBottomY / 16) + 1) * 16;// MaxBottomY % 8;

            Sprites.Add(new SpriteInfo()
            {
                X = 0, Y = 0, Value = 0xDC, Table = -1, Palette = 1
            });
            Sprites.Add(new SpriteInfo()
            {
                X = 8, Y = 0, Value = 0xDe, Table = -1, Palette = 1
            });
            return(true);
        }
예제 #2
0
        public bool LoadFromElement(XElement e)
        {
            foreach (XAttribute a in e.Attributes())
            {
                switch (a.Name.LocalName.ToLower())
                {
                    case "id":
                        InGameId = a.Value.ToIntFromHex();
                        break;

                    case "width":
                        Width = a.Value.ToInt();
                        break;

                    case "height":
                        Height = a.Value.ToInt();
                        break;

                    case "name":
                        Name = a.Value;
                        break;

                    case "class":
                        Class = a.Value.ToInt();
                        break;

                    case "group":
                        Group = a.Value;
                        break;

                    case "proxy":
                        ProxyId = a.Value.ToInt();
                        break;
                }
            }

            foreach (var x in e.Elements("sprite"))
            {
                SpriteInfo s = new SpriteInfo();
                s.LoadFromElement(x);
                Sprites.Add(s);
                if (s.X > MaxRightX)
                    MaxRightX = s.X;
                if (s.X < MaxLeftX)
                    MaxLeftX = s.X;
                if (s.Y > MaxBottomY)
                    MaxBottomY = s.Y;
                if (s.Y < MaxTopY)
                    MaxTopY = s.Y;
            }

            foreach (var p in e.Elements("property"))
            {
                PropertyDescriptions.Add(p.Value);
            }

            if (MaxLeftX < 0 && MaxLeftX % 16 != 0)
                MaxLeftX -= 16;

            MaxLeftX = (MaxLeftX / 16) * 16;// -(MaxLeftX % 8);

            if (MaxRightX % 16 != 0)
                MaxRightX += 16;

            MaxRightX = ((MaxRightX / 16) + 1) * 16;// -(MaxRightX % 8);

            if (MaxTopY < 0 && MaxTopY % 16 != 0)
                MaxTopY -= 16;
            MaxTopY = (MaxTopY / 16) * 16;// -8 - (MaxTopY % 8);

            if (MaxBottomY % 16 != 0)
                MaxBottomY += 16;

            MaxBottomY = ((MaxBottomY / 16) + 1) * 16;// MaxBottomY % 8;

            Sprites.Add(new SpriteInfo() { X = 0, Y = 0, Value = 0xDC, Table = -1, Palette = 1 });
            Sprites.Add(new SpriteInfo() { X = 8, Y = 0, Value = 0xDe, Table = -1, Palette = 1 });
            return true;
        }