示例#1
0
 public static void LoadAllMetadata()
 {
     lock (staticMutationLock) {
         for (int worldIndex = 0; worldIndex < 11; ++worldIndex)
         {
             for (int levelIndex = 0; levelIndex < 10; ++levelIndex)
             {
                 LevelID lid      = new LevelID((byte)worldIndex, (byte)levelIndex);
                 string  filename = String.Empty;
                 if (LevelExists(lid))
                 {
                     filename = Path.Combine(AssetLocator.LevelsDir, GetLevelFileName(lid));
                 }
                 if (filename == String.Empty || !File.Exists(filename))
                 {
                     StringBuilder randomStringBuilder = new StringBuilder();
                     int           strLen = RandomProvider.Next(3, 16);
                     for (int c = 0; c < strLen; ++c)
                     {
                         char x = (char)RandomProvider.Next(65, 92);
                         if (x == (char)91)
                         {
                             x = ' ';
                         }
                         randomStringBuilder.Append(x);
                     }
                     var maxTime    = 30000 + RandomProvider.Next(1, 5) * 15000;
                     var bronzeTime = maxTime - RandomProvider.Next(1, 4) * 2500;
                     var silverTime = bronzeTime - RandomProvider.Next(1, 4) * 2500;
                     var goldTime   = silverTime - RandomProvider.Next(1, 4) * 2500;
                     loadedMetadata[worldIndex * 10 + levelIndex] = new LevelMetadata(
                         randomStringBuilder.ToString(),
                         maxTime,
                         bronzeTime,
                         silverTime,
                         goldTime,
                         RandomProvider.Next(1, 51)
                         );
                 }
                 else
                 {
                     var levelDesc = (GameLevelDescription)LevelDescription.Load(filename, false);
                     loadedMetadata[worldIndex * 10 + levelIndex] = new LevelMetadata(
                         levelDesc.Title,
                         levelDesc.LevelTimerMaxMs,
                         levelDesc.LevelTimerBronzeMs,
                         levelDesc.LevelTimerSilverMs,
                         levelDesc.LevelTimerGoldMs,
                         levelDesc.GetGameObjectsByType <LizardCoin>().Count()
                         );
                     levelDesc.Dispose();
                 }
                 var coinsInLevel = loadedMetadata[worldIndex * 10 + levelIndex].TotalCoinsInLevel;
                 totalCoinsInGame += coinsInLevel;
                 totalCoinsPerWorld[worldIndex] += coinsInLevel;
             }
         }
     }
 }
示例#2
0
        private static void LoadMenuBackdrop(SkyLevelDescription preloadedSky)
        {
            UnloadMenuBackdrop();

            if (!inDeferenceMode)
            {
                cameraLight = new Light(Vector3.ZERO, CAMERA_LIGHT_RADIUS, Vector3.ONE * CAMERA_LIGHT_INTENSITY);
                AssetLocator.LightPass.AddLight(cameraLight);
                //AssetLoader.ClearCache(); // TODO work out whether we really need this line?
                if (!Single.IsPositiveInfinity(Config.DofLensMaxBlurDist))
                {
                    AssetLocator.LightPass.SetLensProperties(DOF_FOCAL_DIST, DOF_MAX_DIST);
                }
                AssetLocator.MainCamera.Position         = Vector3.ZERO + Vector3.DOWN * BACKDROP_CAM_VERTICAL_OFFSET;
                AssetLocator.ShadowcasterCamera.Position = Vector3.UP * SILLY_BIT_DROP_HEIGHT * 1.1f;
                AssetLocator.ShadowcasterCamera.LookAt(Vector3.DOWN, Vector3.FORWARD);
                AssetLocator.ShadowcasterCamera.OrthographicDimensions = new Vector3(100f, 100f, PhysicsManager.ONE_METRE_SCALED * 3f);
                Quaternion downTilt = Quaternion.FromAxialRotation(Vector3.LEFT, BACKDROP_CAM_UPWARD_TILT);
                AssetLocator.MainCamera.Orient(Vector3.FORWARD * downTilt, Vector3.UP * downTilt);
                BGMManager.CrossFadeToTitleMusic();
                mainMenuSinceLoad = false;
            }

            if (preloadedSky != null)
            {
                loadedMenuBackdrop = preloadedSky;
            }
            else
            {
                int worldIndex = RandomProvider.Next(0, PersistedWorldData.GetFurthestUnlockedWorldIndex() + 1);
                loadedMenuBackdrop = (SkyLevelDescription)LevelDescription.Load(
                    Path.Combine(AssetLocator.LevelsDir, LevelDatabase.SkyboxFileNames[worldIndex])
                    );
                loadedMenuBackdrop.ReinitializeAll();
                worldIconTex.Texture = AssetLocator.WorldIcons[worldIndex];
            }
        }