mirror of
https://github.com/Kizuren/ShantiManti.git
synced 2026-01-09 07:59:34 +01:00
59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerSaving : MonoBehaviour
|
|
{
|
|
public static int level = 0;
|
|
public static int coins = 0;
|
|
public static bool hasCompletedTutorial = false;
|
|
public static bool movingClouds = true;
|
|
public static bool Deleteing = false;
|
|
|
|
void Awake()
|
|
{
|
|
LoadPlayer();
|
|
}
|
|
|
|
public static void SavePlayer()
|
|
{
|
|
SaveSystem.SavePlayer();
|
|
Debug.Log("Saved");
|
|
Debug.Log($"Saved level: {level}, coins: {coins}, tutorial: {hasCompletedTutorial}, cloudsMove: {movingClouds}");
|
|
}
|
|
|
|
public static void LoadPlayer()
|
|
{
|
|
PlayerData data = SaveSystem.LoadPlayer();
|
|
|
|
level = data.savedLevels;
|
|
coins = data.savedCoins;
|
|
hasCompletedTutorial = data.tutorial;
|
|
movingClouds = data.cloudsMove;
|
|
|
|
Debug.Log("Loaded");
|
|
Debug.Log($"Loaded level: {level}, coins: {coins}, tutorial: {hasCompletedTutorial}, cloudsMove: {movingClouds}");
|
|
SC_2DCoin.totalCoins = coins;
|
|
Endlevel.level = level;
|
|
}
|
|
|
|
public static void DeletePlayer()
|
|
{
|
|
Deleteing = true;
|
|
level = 0;
|
|
coins = 0;
|
|
hasCompletedTutorial = false;
|
|
movingClouds = true;
|
|
|
|
// For MusicToggle.cs
|
|
PlayerPrefs.SetInt("MusicToggled", 1);
|
|
PlayerPrefs.Save();
|
|
|
|
// For SoundBar.cs
|
|
PlayerPrefs.SetFloat("SoundVolume", 0.75f);
|
|
PlayerPrefs.Save();
|
|
|
|
SaveSystem.SavePlayer();
|
|
Debug.Log("Deleted");
|
|
}
|
|
}
|