Esempio n. 1
0
    //set the player to the checkpoint's position and clear that checkpoint from the list
    public void RespawnPlayerAtLastCheckpoint()
    {
        checkpointStack = checkpointsScript.GetCheckpointsList().Count;


        if (checkpointStack >= 1)
        {
            //position
            player.transform.position         = checkpointsScript.GetCheckpointsListAtIndex(checkpointsScript.GetCheckpointsList().Count - 1);
            Camera.main.transform.eulerAngles = player.transform.eulerAngles;

            //monster position
            monster.transform.position = checkpointsScript.GetMonsterCheckpointsListAtIndex(checkpointsScript.GeMonsterCheckpointsList().Count - 1);

            //rotation
            player.transform.rotation      = checkpointsScript.GetCheckpointRotationsListAtIndex(checkpointsScript.GetCheckpointRotationsList().Count - 1);
            Camera.main.transform.rotation = player.transform.rotation;

            //reset sanity
            dataHandler.SetCurrentSanity((int)dataHandler.GetSavedSanityOnCheckpoint(checkpointsScript.GetCheckpointsList().Count - 1));

            //empty buffer without increasing checkpoint stack
            dataHandler.EmptySanityBuffer(false);

            //clear the checkpoint
            checkpointsScript.ClearUsedCheckpoint();

            //slow time without using sanity
            runTimeSlow = true;
            playerMovement.SetSlowDownDueToRespawn(true);
        }
        else
        {
            Debug.Log("PERMADEATH");
            displayDeathScreen();
        }
    }