Ejemplo n.º 1
0
    //This is the function that actually loads the new scene
    private void sceneLoad(string map)
    {
        player = GameObject.FindWithTag("Player");

        executeDestroyOnSceneChange();

        currentMap = map;

        boundary = GameObject.FindWithTag("sceneBoundary").GetComponent <sceneBoundary>() as sceneBoundary;

        characterReposition.x = player.transform.position.x;
        characterReposition.y = player.transform.position.y;
        wrapSide = "none";

        //If we're wrapping, let's check if the player is off screen before we load the new scene
        if (repositionType == repositionTypes.wrap)
        {
            wrapSide = boundary.boundaryCheck(player, wrapEdgeBuffer.x, wrapEdgeBuffer.y);
        }

        //Notify the global object
        global.onSceneChanging();

        ///LOAD THE NEW SCENE
        SceneManager.LoadScene(map, LoadSceneMode.Single);
    }
Ejemplo n.º 2
0
    //This callback is triggered when a scene has finished loading
    public void onSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        boundary = GameObject.FindWithTag("sceneBoundary").GetComponent <sceneBoundary>() as sceneBoundary;

        if (instantiateOnLoadList.Count > 0)
        {
            foreach (instantiateOnLoadObject obj in instantiateOnLoadList)
            {
                if (obj.scene == "" || scene.name == obj.scene)
                {
                    obj.load();
                    settings.objectCreated(obj.go); //Notify the sceneSettings object
                }
            }
            instantiateOnLoadList.RemoveAll(obj => obj.loaded == true); //Remove all of the objects that were loaded
        }

        if (player != null)
        {
            repositionCharacterOnLoad();
            player.GetComponent <CharacterController2D>().sceneChangeComplete();
        }

        settings = GameObject.FindWithTag("SceneSettings").GetComponent <sceneSettings>() as sceneSettings;

        global.sceneChanging = false;
    }
Ejemplo n.º 3
0
    void getBoundObject()
    {
        GameObject bgo = GameObject.FindWithTag(sceneBoundaryTag);

        if (bgo)
        {
            bound = bgo.GetComponent <sceneBoundary>() as sceneBoundary;
        }
    }
Ejemplo n.º 4
0
 public void getVariables()
 {
     camera   = gameObject.GetComponent <Camera>() as Camera;
     boundary = GameObject.FindWithTag(sceneBoundaryTag).GetComponent <sceneBoundary>() as sceneBoundary;
     findPlayer();
 }
Ejemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     rb               = gameObject.GetComponent <Rigidbody2D>();
     boundary         = GameObject.FindWithTag("sceneBoundary").GetComponent <sceneBoundary>() as sceneBoundary;
     positionPrevious = gameObject.transform.position;
 }