2024-11-26 15:44:50 +08:00
|
|
|
using System;
|
2024-11-05 18:15:49 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2024-11-08 18:21:41 +08:00
|
|
|
using System.IO;
|
2024-11-05 18:15:49 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public static class DataManager
|
|
|
|
{
|
|
|
|
public static int Level
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
return GetInt("Level");
|
2024-11-05 18:15:49 +08:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
SetInt("Level",value);
|
2024-11-05 18:15:49 +08:00
|
|
|
}
|
|
|
|
}
|
2024-11-08 18:21:41 +08:00
|
|
|
|
|
|
|
public static int chapter
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
return GetInt("chapter");
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
SetInt("chapter",value);
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool chapterLock(int id)
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
return GetInt("chapterUnLock"+id)==1;
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void chapterLock(int id, bool bo)
|
|
|
|
{
|
2024-11-26 15:44:50 +08:00
|
|
|
SetInt("chapterUnLock"+id,bo?1:0);
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
2024-11-26 15:44:50 +08:00
|
|
|
|
2024-11-08 18:21:41 +08:00
|
|
|
|
|
|
|
private static Dictionary<int, bool> _directory=new Dictionary<int, bool>();
|
|
|
|
public static bool LevelOpen(int id)
|
|
|
|
{
|
|
|
|
if (_directory.TryGetValue(id, out var open)) return open;
|
2024-11-26 15:44:50 +08:00
|
|
|
var bo = GetInt("level"+id.ToString())==1;
|
2024-11-21 10:26:47 +08:00
|
|
|
if (id==0)
|
|
|
|
{
|
|
|
|
bo = true;
|
|
|
|
}
|
2024-11-08 18:21:41 +08:00
|
|
|
_directory.Add(id,bo);
|
|
|
|
|
|
|
|
return _directory[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SetLevelOpen(int id,bool bo)
|
|
|
|
{
|
|
|
|
_directory[id] = bo;
|
|
|
|
|
2024-11-26 15:44:50 +08:00
|
|
|
SetInt("level"+id.ToString(),bo?1:0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int HighestRecordPoints(int id)
|
|
|
|
{
|
|
|
|
return GetInt("HighestPoints"+id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int LastTimePoints(int id)
|
|
|
|
{
|
|
|
|
return GetInt("LastPoints"+id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SetPointsData(int id, int num)
|
|
|
|
{
|
|
|
|
if (GetInt("HighestPoints"+id)<num)
|
|
|
|
{
|
|
|
|
SetInt("HighestPoints"+id,num);
|
|
|
|
}
|
|
|
|
SetInt("LastPoints" + id, num);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 任务数据存储
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="eventID"></param>
|
|
|
|
/// <param name="bo"></param>
|
|
|
|
public static void SetTask(int id,int eventID,bool bo)
|
|
|
|
{
|
|
|
|
SetInt(id + "_" + eventID, bo ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool GetTask(int id,int eventID)
|
|
|
|
{
|
|
|
|
return GetInt(id + "_" + eventID) == 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SaveAllStarNum()
|
|
|
|
{
|
|
|
|
int num = 0;
|
|
|
|
foreach (var bChapter in JsonTab.Instance.tables.Chapter.DataList)
|
|
|
|
{
|
|
|
|
foreach (var levelId in bChapter.Contain)
|
|
|
|
{
|
|
|
|
var lData = JsonTab.Instance.tables.Level.Get(levelId);
|
|
|
|
if (GetTask(lData.ID, lData.Maintasks))
|
|
|
|
{
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
foreach (var additionaltask in lData.Additionaltasks)
|
|
|
|
{
|
|
|
|
if (GetTask(lData.ID, additionaltask))
|
|
|
|
{
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetInt("star", num);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int GetStar()
|
|
|
|
{
|
|
|
|
return GetInt("star")-GetSpend();
|
|
|
|
}
|
|
|
|
public static int GetAllStar()
|
|
|
|
{
|
|
|
|
return GetInt("star");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SetSpend(int num)
|
|
|
|
{
|
|
|
|
SetInt("Spend",num);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int GetSpend()
|
|
|
|
{
|
|
|
|
return GetInt("Spend");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SetHomeFurnitureID(string key,int id)
|
|
|
|
{
|
|
|
|
SetInt("Furniture-" + key, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int GetHomeFurnitureID(string key)
|
|
|
|
{
|
|
|
|
return GetInt("Furniture-" + key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void SetInt(string key, int num)
|
|
|
|
{
|
|
|
|
PlayerPrefs.SetInt(key, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int GetInt(string key)
|
|
|
|
{
|
|
|
|
return PlayerPrefs.GetInt(key);
|
2024-11-08 18:21:41 +08:00
|
|
|
}
|
2024-11-05 18:15:49 +08:00
|
|
|
}
|