private void setupSceneActors()
    {
        // set Player spawn position for this level
        player.locateAt(getPlayerSpawnPosition(activeLevel));

        // move camera instantaneously to where player spawns
        Camera.main.GetComponent <PlayerFollowerXY>().enableInstantMoveOneTime();

        // setup those scripts dependant on LookUpwards
        player.GetComponent <LookDirections>().setup();
        // makes the camera to follow the player's Y axis until it lands. Then lock the camera's Y axis
        LockYWhenPlayerLands lockYscript = Camera.main.GetComponent <LockYWhenPlayerLands>();

        if (lockYscript)
        {
            lockYscript.enableCorrection();
        }
    }
Beispiel #2
0
    /// <summary>
    /// This invoked from StartLevel object which has the number of the level.
    /// It enables the player's game object if playerEnabled is true, load the spawn positions, set the player's position.
    /// </summary>
    /// <param name='level'>
    /// Number of scene according Unity's indexing
    /// </param>
    /// <param name='playerEnabled'>
    /// True if player starts being enabled. False if not
    /// </param>
    /// <param name='levelExtent'>
    /// Level dimension in world coordinates
    /// </param>
    public void startLevel(int level, bool playerEnabled, Rect levelExtent)
    {
        activeLevel = level;
        // move camera instantaneously to where player spawns
        Camera.main.GetComponent <PlayerFollowerXY>().doInstantMoveOneTime();
        // activate the player's game object
        player.toogleEnabled(playerEnabled);
        // setup some scene only scripts in LookUpwards
        player.GetComponent <LookUpwards>().setup();
        // set Mario spawn position for this level
        setPlayerPosition(level);
#if UNITY_EDITOR
        // throw error if no GUI container was created
        if (LevelManager.getGUIContainerNonDestroyable() == null)
        {
            Debug.LogWarning("Missing " + GUI_container_nd + " game object. Will be created and populated with minimum elements.");
        }
        if (LevelManager.getGUIContainerSceneOnly() == null)
        {
            Debug.LogError("Missing " + GUI_container_so + " game object. Please create it.");
        }
#endif
        // if GUI_container_nd doesn't exist then create it and add minimum required game objects
        setupGUIContainerNonDestroyable();
        // configure the parallax properties for a correct scrolling of background and foreground images
        setParallaxProperties(spawnPosArray[activeLevel].position, levelExtent);
        // makes the camera to follow the player's Y axis until it lands. Then lock the camera's Y axis
        LockYWhenPlayerLands lockYscript = Camera.main.GetComponent <LockYWhenPlayerLands>();
        if (lockYscript)
        {
            lockYscript.init();
        }
        // warm no GUI dependant elements in case they don't exist yet
        TouchEventManager.warm();
        // find IFadeable component since main camera instance changes during scenes
        OptionQuit.Instance.setFaderFromMainCamera();
    }