2022-06-06 16:21:26 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
public class RespawnScript : MonoBehaviour
|
|
|
|
{
|
|
|
|
private string currentScene;
|
|
|
|
|
2022-06-15 19:54:44 +02:00
|
|
|
public GameObject mainCh;
|
2022-11-05 20:25:40 +01:00
|
|
|
public FloatValue maxHealth;
|
2022-06-15 19:54:44 +02:00
|
|
|
|
2022-06-06 16:21:26 +02:00
|
|
|
public void RespawnOnCurrentScene()
|
|
|
|
{
|
2022-10-01 15:39:24 +02:00
|
|
|
mainCh = GameObject.FindGameObjectWithTag("Player");
|
2022-06-06 16:21:26 +02:00
|
|
|
Scene scene = SceneManager.GetActiveScene();
|
|
|
|
currentScene = scene.name;
|
|
|
|
SceneManager.LoadScene(currentScene);
|
2023-01-05 21:22:35 +01:00
|
|
|
|
2022-06-15 19:54:44 +02:00
|
|
|
Player player = mainCh.GetComponent<Player>();
|
2023-01-05 21:22:35 +01:00
|
|
|
|
|
|
|
// 1. health
|
|
|
|
player.currentHealth = PlayerPrefs.GetFloat("maxHealth");
|
|
|
|
PlayerPrefs.SetFloat("health", PlayerPrefs.GetFloat("maxHealth"));
|
|
|
|
PlayerPrefs.SetFloat("health-S", PlayerPrefs.GetFloat("maxHealth"));
|
|
|
|
|
|
|
|
// 2. exp & lvl
|
|
|
|
player.ManageLevels(PlayerPrefs.GetFloat("exp-S"));
|
2022-06-06 16:21:26 +02:00
|
|
|
}
|
|
|
|
}
|