Esempio n. 1
0
        private static void SetLevel(LevelInfo level)
        {
            if (level.existingSprite == null && level.Thumbnail != null)
            {
                level.existingSprite = SpriteLoader.ConvertTextureToSprite(level.Thumbnail);
            }
            TNH_LevelSelector.levelImage.sprite         = level.existingSprite;
            TNH_LevelSelector.levelNameText.text        = level.SceneName + "\nby " + level.Author;
            TNH_LevelSelector.levelDescriptionText.text = level.Description;
            bool isVanilla = level.Equals(vanillaLevel);

            if (isVanilla)
            {
                Loader.LevelToLoad = null;
            }
            else
            {
                Loader.LevelToLoad = level;
            }
        }
        private static void SetupLevelDefs()
        {
            var levels = CustomLevelFinder.EnumerateLevelInfos().Where(x => x.Gamemode != Constants.GamemodeTakeAndHold).ToArray();

            for (int ii = 0; ii < levels.Length; ii++)
            {
                var level = levels[ii];

                var       imageT = level.Thumbnail;
                Texture2D image  = null;
                if (imageT)
                {
                    image = imageT;
                }

                if (level.existingSprite == null && level.Thumbnail != null)
                {
                    level.existingSprite = SpriteLoader.ConvertTextureToSprite(image);
                }

                // Create and apply scene def.
                MainMenuSceneDef moddedDef = ScriptableObject.CreateInstance <MainMenuSceneDef>();
                moddedDef.Name       = level.SceneName + "\n" + level.Identifier;
                moddedDef.Type       = level.Author;
                moddedDef.SceneName  = "ProvingGround";
                moddedDef.Desciption = level.Description;
                moddedDef.Image      = level.existingSprite;

                MainMenuScenePointable screen = screens.First(x => !x.gameObject.activeSelf);
                screen.Def = moddedDef;
                screen.GetComponent <MeshRenderer>().material.SetTexture("_MainTex", imageT);

                // Enable the screen now that it has been set up.
                screen.gameObject.SetActive(true);
            }
        }