You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
371 lines
11 KiB
C#
371 lines
11 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
using System.IO;
|
|
|
|
public class DataManager
|
|
{
|
|
//public static DataManager Instance { get; set; }
|
|
int val = 0;
|
|
private readonly string _pref_VAL = "VAL";
|
|
public int VAL
|
|
{
|
|
get => val;
|
|
set
|
|
{
|
|
val = value;
|
|
PlayerPrefs.SetInt(_pref_VAL, val);
|
|
}
|
|
}
|
|
int currentlevelindex = 0;
|
|
private readonly string _pref_CURRENTLEVELINDEX= "CURRENTLEVELINDEX";
|
|
public int CURRENTLEVELINDEX
|
|
{
|
|
get => currentlevelindex;
|
|
set
|
|
{
|
|
currentlevelindex = value;
|
|
PlayerPrefs.SetInt(_pref_CURRENTLEVELINDEX, currentlevelindex);
|
|
}
|
|
}
|
|
int maxlevelindex = 0;
|
|
private readonly string _pref_MAXLEVELINDEX = "MAXLEVELINDEX";
|
|
public int MAXLEVELINDEX
|
|
{
|
|
get => maxlevelindex;
|
|
set
|
|
{
|
|
maxlevelindex = value;
|
|
PlayerPrefs.SetInt(_pref_MAXLEVELINDEX, maxlevelindex);
|
|
}
|
|
}
|
|
|
|
|
|
//int currentdogindex = 0;
|
|
//private readonly string _pref_CURRENTDOGINDEX = "CURRENTDOGINDEX";
|
|
//public int CURRENTDOGINDEX
|
|
//{
|
|
// get => currentdogindex;
|
|
// set
|
|
// {
|
|
// currentdogindex = value;
|
|
// PlayerPrefs.SetInt(_pref_CURRENTDOGINDEX, currentdogindex);
|
|
// }
|
|
//}
|
|
//int currentactivepropindex = 0;
|
|
//private readonly string _pref_CURRENTACTIVEPROPINDEX = "CURRENTACTIVEPROPINDEX";
|
|
//public int CURRENTACTIVEPROPINDEX
|
|
//{
|
|
// get => currentactivepropindex;
|
|
// set
|
|
// {
|
|
// currentactivepropindex = value;
|
|
// PlayerPrefs.SetInt(_pref_CURRENTACTIVEPROPINDEX, currentactivepropindex);
|
|
// }
|
|
//}
|
|
|
|
//int currentzone = 0;
|
|
//private readonly string _pref_currentzone = "CurrentZone";
|
|
//public int CurrentZone
|
|
//{
|
|
// get => currentzone;
|
|
// set
|
|
// {
|
|
// currentzone = Mathf.Clamp(value, 0, 2);
|
|
// PlayerPrefs.SetInt(_pref_currentzone, currentzone);
|
|
// }
|
|
//}
|
|
|
|
//int interact_p_counter = 0;
|
|
//private readonly string _pref_INTERACT_P_COUNTER = "INTERACT_P_COUNTER";
|
|
//public int INTERACT_P_COUNTER
|
|
//{
|
|
// get => interact_p_counter;
|
|
// set
|
|
// {
|
|
// interact_p_counter = value;
|
|
// PlayerPrefs.SetInt(_pref_INTERACT_P_COUNTER, interact_p_counter);
|
|
// }
|
|
//}
|
|
//int interact_c_counter = 0;
|
|
//private readonly string _pref_INTERACT_C_COUNTER = "INTERACT_C_COUNTER";
|
|
//public int INTERACT_C_COUNTER
|
|
//{
|
|
// get => interact_c_counter;
|
|
// set
|
|
// {
|
|
// interact_c_counter = value;
|
|
// PlayerPrefs.SetInt(_pref_INTERACT_C_COUNTER, interact_c_counter);
|
|
// }
|
|
//}
|
|
//public bool IsTutorialCompleted
|
|
//{
|
|
// get => istutorialcompleted;
|
|
// set
|
|
// {
|
|
// istutorialcompleted = value;
|
|
// PlayerPrefs.SetInt(_pref_istutorialcompleted, istutorialcompleted ? 1 : 0);
|
|
// }
|
|
//}
|
|
//bool istutorialcompleted = false;
|
|
//private readonly string _pref_istutorialcompleted = "IsTutorialCompleted";
|
|
|
|
//// public bool IsTutorialCompleted
|
|
//// {
|
|
//// get => istutorialcompleted;
|
|
//// set
|
|
//// {
|
|
//// istutorialcompleted = value;
|
|
//// PlayerPrefs.SetInt(_pref_istutorialcompleted, (istutorialcompleted ? 0 : 1));
|
|
//// }
|
|
//// }
|
|
//int correctdecisioncounter = 0;
|
|
//private readonly string _pref_correctdecisioncounter = "CorrectDecisionCounter";
|
|
//public int CorrectDecisionCounter
|
|
//{
|
|
// get => correctdecisioncounter;
|
|
// set
|
|
// {
|
|
// correctdecisioncounter = value;
|
|
// PlayerPrefs.SetInt(_pref_correctdecisioncounter, correctdecisioncounter);
|
|
// }
|
|
//}
|
|
//int rp = 0;
|
|
//private readonly string _pref_rp = "RP";
|
|
|
|
//[SerializeField]
|
|
//public int RP
|
|
//{
|
|
// get => rp;
|
|
// set
|
|
// {
|
|
// rp = value;
|
|
// PlayerPrefs.SetInt(_pref_rp, rp);
|
|
// }
|
|
//}
|
|
//bool runningstatus;
|
|
//private readonly string _pref_runningstatus = "RunnigStatus";
|
|
//public bool RunnigStatus
|
|
//{
|
|
// get => runningstatus;
|
|
// set
|
|
// {
|
|
// runningstatus = value;
|
|
// PlayerPrefs.SetInt(_pref_runningstatus, (runningstatus ? 1 : 0));
|
|
// }
|
|
//}
|
|
//bool sfxstatus;
|
|
//private readonly string _pref_sfxstatus = "SFXStatus";
|
|
//public bool SFXStatus
|
|
//{
|
|
// get => sfxstatus;
|
|
// set
|
|
// {
|
|
// sfxstatus = value;
|
|
// PlayerPrefs.SetInt(_pref_sfxstatus, (sfxstatus ? 1 : 0));
|
|
// }
|
|
//}
|
|
//bool musicstatus;
|
|
//private readonly string _pref_musicstatus = "MusicStatusStatus";
|
|
//public bool MusicStatus
|
|
//{
|
|
// get => musicstatus;
|
|
// set
|
|
// {
|
|
// musicstatus = value;
|
|
// PlayerPrefs.SetInt(_pref_musicstatus, (musicstatus ? 1 : 0));
|
|
// }
|
|
//}
|
|
//int days = 0;
|
|
//private readonly string _pref_days = "Days";
|
|
//public int Days
|
|
//{
|
|
// get => days;
|
|
// set
|
|
// {
|
|
// days = value;
|
|
// PlayerPrefs.SetInt(_pref_days, days);
|
|
// }
|
|
//}
|
|
//bool ismaleselected;
|
|
//private readonly string _pref_ismaleselected = "IsMaleSelected";
|
|
//public bool IsMaleSelected
|
|
//{
|
|
// get => ismaleselected;
|
|
// set
|
|
// {
|
|
// ismaleselected = value;
|
|
// PlayerPrefs.SetInt(_pref_ismaleselected, (ismaleselected ? 1 : 0));
|
|
// }
|
|
//}
|
|
//int taskscompleted = 0;
|
|
//private readonly string _pref_taskscompleted = "TasksCompleted";
|
|
//public int TasksCompleted
|
|
//{
|
|
// get => taskscompleted;
|
|
// set
|
|
// {
|
|
// taskscompleted = value;
|
|
// PlayerPrefs.SetInt(_pref_taskscompleted, taskscompleted);
|
|
// }
|
|
//}
|
|
//int gems = 0;
|
|
//private readonly string _pref_gems = "Gems";
|
|
//public int Gems
|
|
//{
|
|
// get => gems;
|
|
// set
|
|
// {
|
|
// gems = value;
|
|
// PlayerPrefs.SetInt(_pref_gems, gems);
|
|
// }
|
|
//}
|
|
|
|
//int totalcurrentlevel = 0;
|
|
//private readonly string _pref_totalcurrentlevel = "TotalCurrentLevel";
|
|
//public int TotalCurrentLevel
|
|
//{
|
|
// get => totalcurrentlevel;
|
|
// set
|
|
// {
|
|
// totalcurrentlevel = value;
|
|
// PlayerPrefs.SetInt(_pref_totalcurrentlevel, totalcurrentlevel);
|
|
// }
|
|
//}
|
|
//int currentcounter = 0;
|
|
//private readonly string _pref_currentcounter = "CurrentCounter";
|
|
//public int CurrentCounter
|
|
//{
|
|
// get => currentcounter;
|
|
// set
|
|
// {
|
|
// currentcounter = value;
|
|
// PlayerPrefs.SetInt(_pref_currentcounter, currentcounter);
|
|
// }
|
|
//}
|
|
//int cash = 0;
|
|
//private readonly string _pref_cash = "Cash";
|
|
//public int Cash
|
|
//{
|
|
// get => cash;
|
|
// set
|
|
// {
|
|
// cash = value;
|
|
// PlayerPrefs.SetInt(_pref_cash, cash);
|
|
// }
|
|
//}
|
|
|
|
void LoadData()
|
|
{
|
|
//istutorialcompleted = PlayerPrefs.GetInt(_pref_istutorialcompleted, 0) == 0;
|
|
currentlevelindex= PlayerPrefs.GetInt(_pref_CURRENTLEVELINDEX, currentlevelindex);
|
|
maxlevelindex= PlayerPrefs.GetInt(_pref_MAXLEVELINDEX, maxlevelindex);
|
|
//cash = PlayerPrefs.GetInt(_pref_cash, cash);
|
|
//totalcurrentlevel = PlayerPrefs.GetInt(_pref_totalcurrentlevel, totalcurrentlevel);
|
|
//currentcounter = PlayerPrefs.GetInt(_pref_currentcounter, currentcounter);
|
|
|
|
//rp = PlayerPrefs.GetInt(_pref_rp, rp);
|
|
//gems = PlayerPrefs.GetInt(_pref_gems, gems);
|
|
//correctdecisioncounter = PlayerPrefs.GetInt(
|
|
// _pref_correctdecisioncounter,
|
|
// correctdecisioncounter
|
|
//);
|
|
|
|
//interact_c_counter = PlayerPrefs.GetInt(_pref_INTERACT_C_COUNTER, interact_c_counter);
|
|
//interact_p_counter = PlayerPrefs.GetInt(_pref_INTERACT_P_COUNTER, interact_p_counter);
|
|
//currentdogindex = PlayerPrefs.GetInt(_pref_CURRENTDOGINDEX, currentdogindex);
|
|
//currentactivepropindex = PlayerPrefs.GetInt(
|
|
// _pref_CURRENTACTIVEPROPINDEX,
|
|
// currentactivepropindex
|
|
//);
|
|
|
|
//currentzone = PlayerPrefs.GetInt(_pref_currentzone, currentzone);
|
|
//sfxstatus = PlayerPrefs.GetInt(_pref_sfxstatus, 1) == 1;
|
|
//musicstatus = PlayerPrefs.GetInt(_pref_musicstatus, 1) == 1;
|
|
//ismaleselected = PlayerPrefs.GetInt(_pref_ismaleselected, 1) == 1;
|
|
//runningstatus = PlayerPrefs.GetInt(_pref_runningstatus, 1) == 1;
|
|
//days = PlayerPrefs.GetInt(_pref_days, 1);
|
|
//taskscompleted = PlayerPrefs.GetInt(_pref_taskscompleted, taskscompleted);
|
|
//istutorialcompleted =
|
|
// PlayerPrefs.GetInt(_pref_istutorialcompleted, istutorialcompleted ? 1 : 0) == 1;
|
|
}
|
|
|
|
public void Checker()
|
|
{
|
|
LoadData();
|
|
//if (PlayerPrefs.GetInt(_pref_istutorialcompleted) == 1)
|
|
//{
|
|
// LoadData();
|
|
//}
|
|
//else
|
|
//{
|
|
// ResetData();
|
|
//}
|
|
}
|
|
|
|
DataManager()
|
|
{
|
|
Checker();
|
|
}
|
|
|
|
void ResetData()
|
|
{
|
|
currentlevelindex = 0;
|
|
maxlevelindex = 0;
|
|
//cash = 0;
|
|
//totalcurrentlevel = 0;
|
|
//currentcounter = 0;
|
|
//rp = 0;
|
|
//gems = 0;
|
|
//correctdecisioncounter = 0;
|
|
//interact_c_counter = 0;
|
|
//interact_p_counter = 0;
|
|
//days = 1;
|
|
//taskscompleted = 0;
|
|
//currentzone = 0;
|
|
//sfxstatus = PlayerPrefs.GetInt(_pref_sfxstatus, 1) == 1;
|
|
//musicstatus = PlayerPrefs.GetInt(_pref_musicstatus, 1) == 1;
|
|
//runningstatus = PlayerPrefs.GetInt(_pref_runningstatus, 1) == 1;
|
|
//ismaleselected = PlayerPrefs.GetInt(_pref_ismaleselected, 1) == 1;
|
|
//currentdogindex = -1;
|
|
//currentactivepropindex = -1;
|
|
}
|
|
|
|
private static DataManager instance;
|
|
public static DataManager Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
instance = new DataManager();
|
|
return instance;
|
|
}
|
|
}
|
|
// void Awake()
|
|
// {
|
|
// if (Instance == null)
|
|
// {
|
|
// //DontDestroyOnLoad(gameObject);
|
|
// Instance = this;
|
|
// }
|
|
// else if (Instance != this)
|
|
// {
|
|
// DestroySelf();
|
|
// }
|
|
// LoadData();
|
|
// }
|
|
|
|
// private void DestroySelf()
|
|
// {
|
|
// if (Application.isPlaying)
|
|
// {
|
|
// Destroy(this);
|
|
// }
|
|
// else
|
|
// {
|
|
// DestroyImmediate(this);
|
|
// }
|
|
// }
|
|
}
|