Exemplo n.º 1
0
        public void AddPointer()
        {
            WorldPointer p = new WorldPointer()
            {
                X         = 8,
                Y         = 0x16,
                LevelGuid = Guid.Empty
            };

            Pointers.Add(p);
        }
Exemplo n.º 2
0
        public void RemovePointer(WorldPointer p)
        {
            Pointers.Remove(p);

        }
Exemplo n.º 3
0
        public void AddPointer()
        {
            WorldPointer p = new WorldPointer()
            {
                X = 8,
                Y = 0x16,
                LevelGuid = Guid.Empty
            };

            Pointers.Add(p);

        }
Exemplo n.º 4
0
        public bool Load(string filename)
        {
            string[] compressData = null;
            string[] levelData = null;

            XDocument xDoc;
            try
            {
                xDoc = XDocument.Load(filename);
            }
            catch
            {
                return false;
            }

            XElement world = xDoc.Element("world");

            foreach (var a in world.Attributes())
            {
                switch (a.Name.LocalName)
                {
                    case "guid":
                        Guid = a.Value.ToGuid();
                        break;

                    case "graphicsbank":
                        GraphicsBank = a.Value.ToInt();
                        break;

                    case "music":
                        Music = a.Value.ToInt();
                        break;

                    case "length":
                        Length = a.Value.ToInt();
                        break;

                    case "palette":
                        Palette = a.Value.ToInt();
                        break;

                    case "compresseddata":
                        compressData = a.Value.Split(',');
                        break;

                    case "worlddata":
                        levelData = a.Value.Split(',');
                        break;
                }
            }

            int xPointer = 0, yPointer = 0;
            foreach (var c in levelData)
            {
                LevelData[xPointer, yPointer] = (byte)c.ToInt();
                xPointer++;

                if (xPointer >= Width)
                {
                    xPointer = 0;
                    yPointer++;
                    if (yPointer > Height) break;
                }
            }

            SpriteData.Clear();
            Pointers.Clear();
            foreach (var x in world.Elements())
            {
                switch (x.Name.LocalName)
                {
                    case "spritedata":
                        foreach (var spr in x.Elements("sprite"))
                        {
                            Sprite s = new Sprite();
                            s.LoadFromElement(spr);
                            SpriteData.Add(s);
                        }
                        break;

                    case "pointers":

                        foreach (var ptr in x.Elements("pointer"))
                        {
                            WorldPointer p = new WorldPointer();
                            p.LoadFromElement(ptr);
                            Pointers.Add(p);
                        }
                        break;

                    case "settings":
                        Settings.LoadFromElement(x);
                        break;
                }
            }

            return true;
        }
Exemplo n.º 5
0
 public void RemovePointer(WorldPointer p)
 {
     Pointers.Remove(p);
 }
Exemplo n.º 6
0
        public bool Load(string filename)
        {
            string[] compressData = null;
            string[] levelData    = null;

            XDocument xDoc;

            try
            {
                xDoc = XDocument.Load(filename);
            }
            catch
            {
                return(false);
            }

            XElement world = xDoc.Element("world");

            foreach (var a in world.Attributes())
            {
                switch (a.Name.LocalName)
                {
                case "guid":
                    Guid = a.Value.ToGuid();
                    break;

                case "graphicsbank":
                    GraphicsBank = a.Value.ToInt();
                    break;

                case "music":
                    Music = a.Value.ToInt();
                    break;

                case "length":
                    Length = a.Value.ToInt();
                    break;

                case "palette":
                    Palette = a.Value.ToInt();
                    break;

                case "compresseddata":
                    compressData = a.Value.Split(',');
                    break;

                case "worlddata":
                    levelData = a.Value.Split(',');
                    break;
                }
            }

            int xPointer = 0, yPointer = 0;

            foreach (var c in levelData)
            {
                LevelData[xPointer, yPointer] = (byte)c.ToInt();
                xPointer++;

                if (xPointer >= Width)
                {
                    xPointer = 0;
                    yPointer++;
                    if (yPointer > Height)
                    {
                        break;
                    }
                }
            }

            SpriteData.Clear();
            Pointers.Clear();
            foreach (var x in world.Elements())
            {
                switch (x.Name.LocalName)
                {
                case "spritedata":
                    foreach (var spr in x.Elements("sprite"))
                    {
                        Sprite s = new Sprite();
                        s.LoadFromElement(spr);
                        SpriteData.Add(s);
                    }
                    break;

                case "pointers":

                    foreach (var ptr in x.Elements("pointer"))
                    {
                        WorldPointer p = new WorldPointer();
                        p.LoadFromElement(ptr);
                        Pointers.Add(p);
                    }
                    break;

                case "settings":
                    Settings.LoadFromElement(x);
                    break;
                }
            }

            return(true);
        }