Beispiel #1
0
    /// <summary>
    /// Respawns the player at there last checkpoint
    /// </summary>
    public void Respawn()
    {
        var load = SaveGame.LoadGame();

        if (load != null)
        {
            GameObject           obj   = Instantiate(transitionMakerObject, Vector3.zero, Quaternion.identity);
            SceneTransitionMaker maker = obj.GetComponent <SceneTransitionMaker>();
            maker.DoTransitionMovePlayer(load);
        }
        else
        {
            Debug.LogWarning("No Save file to respawn to.");
        }
    }
Beispiel #2
0
    /// <summary>
    /// Goes to a scene and then places the player in the intended place
    /// </summary>
    /// <param name="targetPos"></param>
    /// <param name="sceneName"></param>
    public void GoToScene(Vector2 targetPos, string sceneName)
    {
        var load = SaveGame.LoadGame();

        if (load != null)
        {
            GameObject           obj   = Instantiate(transitionMakerObject, Vector3.zero, Quaternion.identity);
            SceneTransitionMaker maker = obj.GetComponent <SceneTransitionMaker>();

            if (maker == null)
            {
                return;
            }
            maker.DoTransitionMovePlayer(load, sceneName, targetPos);
        }
        else
        {
            Debug.LogWarning("No Save file to respawn to.");
        }
    }
Beispiel #3
0
    /// <summary>
    /// Load the save, if there is a save to load that is.
    /// </summary>
    public void Continue()
    {
        if (transition == null)
        {
            return;
        }

        if (File.Exists(Path.Combine(Application.persistentDataPath, SaveGame.fileName)))
        {
            var load = SaveGame.LoadGame();

            if (load != null)
            {
                transition.DoTransitionMovePlayer(load, load.sceneName, new Vector2(load.playerXPos, load.playerYPos));
            }
            else
            {
                Debug.LogWarning("No Save file to respawn to.");
            }

            Debug.Log(Path.Combine(Application.persistentDataPath, SaveGame.fileName));
        }
    }