Ejemplo n.º 1
0
 public static void Initialize()
 {
     foreach (string level1 in Content.GetLevels("challenge", LevelLocation.Content))
     {
         LevelData level2 = Content.GetLevel(level1);
         string    guid   = level2.metaData.guid;
         foreach (BinaryClassChunk node in level2.objects.objects)
         {
             string property = node.GetProperty <string>("type");
             if (property != null)
             {
                 if (property.Contains("DuckGame.ChallengeMode,"))
                 {
                     try
                     {
                         if (Thing.LoadThing(node, false) is ChallengeMode challengeMode)
                         {
                             challengeMode.challenge.fileName = level1;
                             challengeMode.challenge.levelID  = guid;
                             challengeMode.challenge.preview  = level2.previewData.preview;
                             if (challengeMode.challenge.trophies[5].goodies == -1 && challengeMode.challenge.trophies[5].targets == -1)
                             {
                                 int timeRequirement = challengeMode.challenge.trophies[5].timeRequirement;
                             }
                             Challenges._challenges.Add(level2.metaData.guid, challengeMode.challenge);
                         }
                     }
                     catch (Exception ex)
                     {
                     }
                 }
             }
         }
     }
     foreach (string file in DuckFile.GetFiles(DuckFile.challengeDirectory))
     {
         XDocument xdocument = DuckFile.LoadXDocument(file);
         if (xdocument != null)
         {
             string   withoutExtension = Path.GetFileNameWithoutExtension(file);
             XElement xelement         = xdocument.Element((XName)"Data");
             if (xelement != null)
             {
                 foreach (XElement element1 in xelement.Elements((XName)"challengeSaveData"))
                 {
                     ChallengeSaveData element2 = new ChallengeSaveData();
                     element2.LegacyDeserialize(element1);
                     element2.challenge = withoutExtension;
                     Challenges._saveData.Add(withoutExtension, element2);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public static RandomLevelData LoadInTile(string tile, string realName = null)
        {
            RandomLevelData element = new RandomLevelData();

            element.file = tile;
            if (realName != null)
            {
                element.file = realName;
            }
            LevelData levelData = Content.GetLevel(tile) ?? DuckFile.LoadLevel(tile);
            int       sideMask  = levelData.proceduralData.sideMask;

            if (sideMask == 0)
            {
                return((RandomLevelData)null);
            }
            if ((sideMask & 1) != 0)
            {
                element.up = true;
            }
            if ((sideMask & 2) != 0)
            {
                element.right = true;
            }
            if ((sideMask & 4) != 0)
            {
                element.down = true;
            }
            if ((sideMask & 8) != 0)
            {
                element.left = true;
            }
            element.chance = levelData.proceduralData.chance;
            element.max    = levelData.proceduralData.maxPerLevel;
            element.single = levelData.proceduralData.enableSingle;
            element.multi  = levelData.proceduralData.enableMulti;
            element.ApplyWeaponData(levelData.proceduralData.weaponConfig);
            element.ApplySpawnerData(levelData.proceduralData.spawnerConfig);
            element.numArmor       = levelData.proceduralData.numArmor;
            element.numEquipment   = levelData.proceduralData.numEquipment;
            element.numKeys        = levelData.proceduralData.numKeys;
            element.numLockedDoors = levelData.proceduralData.numLockedDoors;
            element.numSpawns      = levelData.proceduralData.numSpawns;
            element.numTeamSpawns  = levelData.proceduralData.numTeamSpawns;
            element.canMirror      = levelData.proceduralData.canMirror;
            element.isMirrored     = levelData.proceduralData.isMirrored;
            element.data           = levelData.objects.objects;
            LevelGenerator._tiles.Add(element);
            if (element.up)
            {
                LevelGenerator._connections.Add(TileConnection.Up, element);
            }
            if (element.down)
            {
                LevelGenerator._connections.Add(TileConnection.Down, element);
            }
            if (element.left)
            {
                LevelGenerator._connections.Add(TileConnection.Left, element);
                LevelGenerator._connections.Add(TileConnection.Right, element.Flipped());
            }
            if (element.right)
            {
                LevelGenerator._connections.Add(TileConnection.Right, element);
                LevelGenerator._connections.Add(TileConnection.Left, element.Flipped());
            }
            LevelGenerator._tiles.Add(element.Flipped());
            return(element);
        }