Example #1
0
        public void AddPointer()
        {
            LevelPointer p = new LevelPointer()
            {
                ExitType  = 0,
                XExit     = 0,
                XEnter    = 0,
                YExit     = 0,
                YEnter    = 0,
                LevelGuid = Guid.Empty
            };

            Pointers.Add(p);
        }
Example #2
0
 public void RemovePointer(LevelPointer p)
 {
     Pointers.Remove(p);
 }
Example #3
0
        public void AddPointer()
        {
            LevelPointer p = new LevelPointer()
                {
                    ExitType = 0,
                    XExit = 0,
                    XEnter = 0,
                    YExit = 0,
                    YEnter = 0,
                    LevelGuid = Guid.Empty
                };

            Pointers.Add(p);
        }
Example #4
0
        public bool Load(string filename)
        {
            XDocument xDoc;
            string[] levelData = null;
            string[] compressData = null;
            SpriteData.Clear();
            Pointers.Clear();

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

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

            foreach (var a in level.Attributes())
            {
                switch (a.Name.LocalName)
                {
                    case "layout":
                        LevelLayout = (LevelLayout)Enum.Parse(typeof(LevelLayout), a.Value, true);
                        break;

                    case "guid":
                        Guid = a.Value.ToGuid();
                        break;

                    case "type":
                        Type = a.Value.ToInt();
                        break;

                    case "clearvalue":
                        ClearValue = a.Value.ToInt();
                        break;

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

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

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

                    case "time":
                        Time = a.Value.ToInt();
                        break;

                    case "xstart":
                        XStart = a.Value.ToInt();
                        break;

                    case "ystart":
                        YStart = a.Value.ToInt();
                        break;

                    case "invincibleenemies":
                        InvincibleEnemies = a.Value.ToBoolean();
                        break;

                    case "vineblocked":
                        VineBlocked = a.Value.ToBoolean();
                        break;

                    case "paletteeffect":
                        PaletteEffect = a.Value.ToInt();
                        break;

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

                    case "scrolltype":
                        ScrollType = a.Value.ToInt();
                        break;

                    case "animationtype":
                        AnimationType = a.Value.ToInt();
                        break;

                    case "startaction":
                        StartAction = a.Value.ToInt();
                        break;

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

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

                    case "challengeleveltype":
                        ChallengeType = a.Value.ToInt();
                        break;

                    case "specialleveltype":
                        SpecialLevelType = a.Value.ToInt();
                        break;

                    case "misc1":
                        MiscByte1 = a.Value.ToInt();
                        break;

                    case "misc2":
                        MiscByte2 = a.Value.ToInt();
                        break;

                    case "misc3":
                        MiscByte3 = a.Value.ToInt();
                        break;

                    case "tempprojeffects":
                        ProjectileBlocksTemporary = a.Value.ToBoolean();
                        break;

                    case "rhythm":
                        RhythmPlatforms = a.Value.ToBoolean();
                        break;

                    case "dpadtiles":
                        DpadTiles = a.Value.ToBoolean();
                        break;
                }
            }

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

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

            int highestTileCount = -1;
            for (int i = 0; i < 256; i++)
            {
                if (tileCount[i] > highestTileCount)
                {
                    highestTileCount = MostCommonTile = i;

                }
            }

            foreach (var x in level.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"))
                        {
                            LevelPointer p = new LevelPointer();
                            p.LoadFromElement(ptr);
                            Pointers.Add(p);
                        }
                        break;

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

            return true;
        }
Example #5
0
 public void RemovePointer(LevelPointer p)
 {
     Pointers.Remove(p);
 }
Example #6
0
        public bool Load(string filename)
        {
            XDocument xDoc;

            string[] levelData    = null;
            string[] compressData = null;
            SpriteData.Clear();
            Pointers.Clear();

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

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

            foreach (var a in level.Attributes())
            {
                switch (a.Name.LocalName)
                {
                case "layout":
                    LevelLayout = (LevelLayout)Enum.Parse(typeof(LevelLayout), a.Value, true);
                    break;

                case "guid":
                    Guid = a.Value.ToGuid();
                    break;

                case "type":
                    Type = a.Value.ToInt();
                    break;

                case "clearvalue":
                    ClearValue = a.Value.ToInt();
                    break;

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

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

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

                case "time":
                    Time = a.Value.ToInt();
                    break;

                case "xstart":
                    XStart = a.Value.ToInt();
                    break;

                case "ystart":
                    YStart = a.Value.ToInt();
                    break;

                case "invincibleenemies":
                    InvincibleEnemies = a.Value.ToBoolean();
                    break;

                case "vineblocked":
                    VineBlocked = a.Value.ToBoolean();
                    break;

                case "paletteeffect":
                    PaletteEffect = a.Value.ToInt();
                    break;

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

                case "scrolltype":
                    ScrollType = a.Value.ToInt();
                    break;

                case "animationtype":
                    AnimationType = a.Value.ToInt();
                    break;

                case "startaction":
                    StartAction = a.Value.ToInt();
                    break;

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

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

                case "challengeleveltype":
                    ChallengeType = a.Value.ToInt();
                    break;

                case "specialleveltype":
                    SpecialLevelType = a.Value.ToInt();
                    break;

                case "misc1":
                    MiscByte1 = a.Value.ToInt();
                    break;

                case "misc2":
                    MiscByte2 = a.Value.ToInt();
                    break;

                case "misc3":
                    MiscByte3 = a.Value.ToInt();
                    break;

                case "tempprojeffects":
                    ProjectileBlocksTemporary = a.Value.ToBoolean();
                    break;

                case "rhythm":
                    RhythmPlatforms = a.Value.ToBoolean();
                    break;

                case "dpadtiles":
                    DpadTiles = a.Value.ToBoolean();
                    break;
                }
            }

            int xPointer = 0, yPointer = 0;

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

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

            int highestTileCount = -1;

            for (int i = 0; i < 256; i++)
            {
                if (tileCount[i] > highestTileCount)
                {
                    highestTileCount = MostCommonTile = i;
                }
            }

            foreach (var x in level.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"))
                    {
                        LevelPointer p = new LevelPointer();
                        p.LoadFromElement(ptr);
                        Pointers.Add(p);
                    }
                    break;

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

            return(true);
        }