using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// Script to reset player stuf like
/// - missions list
/// - items
/// - equipment
/// - health
/// - exp
///
public class ResetPlayer : MonoBehaviour
{
public bool isAfterReset = false;
void Update()
{
if (!isAfterReset)
ResetPlayerData();
}
void ResetPlayerData()
{
if (
EquipmentDataManager.Instance == null ||
SceneInventoryDataManager.Instance == null ||
SceneTaskDataManager.Instance == null
) return;
if (PlayerPrefs.GetString("gateway.sourceMapName") == "SampleScene")
{
isAfterReset = true;
// Clear panels data
EquipmentDataManager.Instance.ClearListOfElements();
SceneInventoryDataManager.Instance.ClearListOfElements();
SceneTaskDataManager.Instance.ClearListOfElements();
var saveController = GameObject.FindObjectOfType();
saveController.SavePlayerEquipmentItems();
saveController.SavePlayerInventory();
saveController.SavePlayerQuests();
// Player reset lvl, exp & health
var playerAgent = GameObject.FindGameObjectWithTag("Player");
playerAgent.GetComponent().currentHealth = PlayerPrefs.GetFloat("maxHealth");
PlayerPrefs.SetFloat("health-S", PlayerPrefs.GetFloat("maxHealth"));
PlayerPrefs.SetFloat("health", PlayerPrefs.GetFloat("maxHealth"));
playerAgent.GetComponent().exp = 0;
PlayerPrefs.SetFloat("exp-S", 0);
playerAgent.GetComponent().lvl = 1;
PlayerPrefs.SetInt("lvl-S", 1);
playerAgent.GetComponent().SaveCheckpoint();
}
}
}