示例#1
0
    /// <summary>
    /// Loads the current level with the loaded level descriptor.
    /// </summary>
    /// <returns>If the level is loaded or not.</returns>
    public bool LoadLevel()
    {
        if (LevelDescriptor != null)
        {
            // Set some logic data:
            changeSteps(0);
            changeSecond(0);

            // Clean unused assets:
            Resources.UnloadUnusedAssets();

            // Add the input controller to the world:
            var world = SceneUtil.Find(CoreManager.WORLD_GOBJ_NAME);
            levelController         = world.AddComponent <LevelController>();
            levelController.enabled = true;

            // Change the layer of the terrain and entities nodes:
            Action <string, GameObject, float> updateNode = (name, parent, z) => {
                var victim = SceneUtil.Find(name);
                SceneUtil.SetParent(victim, parent);
                SceneUtil.SetPosition(victim, 0.0f, 0.0f, z);
            };

            updateNode(CoreManager.TERRAIN_GOBJ_NAME, world, 1.0f);
            updateNode(CoreManager.ENTITIES_GOBJ_NAME, world, 0.0f);

            // Create the current level:
            Level = new LevelData();
            Level.Create(LevelDescriptor);
            return(Level.IsLoaded);
        }
        return(false);
    }
示例#2
0
 /// <summary>
 /// Shows the menu background in the level scene.
 /// </summary>
 public void ShowMenuBackground()
 {
     if (IsLevelScene || IsTutorialScene)
     {
         var menuBackground = SceneUtil.Find(CoreManager.MNUBACK_GOBJ_NAME, false);
         var renderer       = menuBackground.GetComponent <SpriteRenderer>();
         renderer.enabled = true;
     }
 }