Respown & Save fix

This commit is contained in:
kabix09 2023-01-05 21:22:35 +01:00
parent 71d7ff164a
commit 3e861d2ac3
2 changed files with 15 additions and 3 deletions

View File

@ -37,11 +37,15 @@ public class ResetPlayer : MonoBehaviour
SceneInventoryDataManager.Instance.ClearListOfElements();
SceneTaskDataManager.Instance.ClearListOfElements();
// Clear Account balance
AccountBalanceManager.Instance.SetAccountBalanceValue(0);
var saveController = GameObject.FindObjectOfType<SaveController>();
saveController.SavePlayerEquipmentItems();
saveController.SavePlayerInventory();
saveController.SavePlayerQuests();
saveController.SaveAccountBalance();
// Player reset lvl, exp & health
var playerAgent = GameObject.FindGameObjectWithTag("Player");
@ -50,11 +54,13 @@ public class ResetPlayer : MonoBehaviour
PlayerPrefs.SetFloat("health-S", PlayerPrefs.GetFloat("maxHealth"));
PlayerPrefs.SetFloat("health", PlayerPrefs.GetFloat("maxHealth"));
/*
playerAgent.GetComponent<Player>().exp = 0;
PlayerPrefs.SetFloat("exp-S", 0);
playerAgent.GetComponent<Player>().lvl = 1;
PlayerPrefs.SetInt("lvl-S", 1);
*/
playerAgent.GetComponent<Player>().SaveCheckpoint();
}

View File

@ -16,9 +16,15 @@ public class RespawnScript : MonoBehaviour
Scene scene = SceneManager.GetActiveScene();
currentScene = scene.name;
SceneManager.LoadScene(currentScene);
Player player = mainCh.GetComponent<Player>();
player.currentHealth = 10.0f;
PlayerPrefs.SetFloat("health", 10.0f);
PlayerPrefs.SetFloat("health-S", 10.0f);
// 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"));
}
}