54 lines
1.1 KiB
C#
54 lines
1.1 KiB
C#
using PahlawanEnergi;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerProgressData : MonoBehaviour
|
|
{
|
|
public static PlayerProgressData instance;
|
|
|
|
[SerializeField] private SO_LevelProgress defaultProgress;
|
|
[SerializeField] private ProgressData data = new ProgressData();
|
|
|
|
public ProgressData Data => data;
|
|
|
|
private void Awake()
|
|
{
|
|
if(instance != null)
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
data = null;
|
|
data = LocalStorageManager.LoadLevelProgress();
|
|
if(data == null)
|
|
{
|
|
data = defaultProgress.GetProgressData();
|
|
}
|
|
|
|
}
|
|
|
|
public void PlayGame(int level, int score)
|
|
{
|
|
data.PlayGame(level, score);
|
|
LocalStorageManager.SaveLevelProgress(data);
|
|
}
|
|
|
|
public void ReadLearningMaterial(int id)
|
|
{
|
|
data.ReadLearningMaterial(id);
|
|
LocalStorageManager.SaveLevelProgress(data);
|
|
}
|
|
|
|
}
|