123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- //用来做本地数据存储的
- public class GameDataSetting {
- private const string LuminanceValue_Str = "LuminanceValue_Str";//亮度
- private const string BG_Sound_Switch_Str = "BG_Sound_Switch_Str";//背景音乐开关
- private const string Effect_Sound_Switch_Str = "Effect_Sound_Switch_Str";//音效开关
- private const string BG_Sound_Value_Str = "BG_Sound_Value_Str";//背景音量
- private const string Effect_Sound_Value_Str = "Effect_Sound_Value_Str";//特效音量
- private const string Cur_Instance_Value_Str = "Cur_Instance_Value_Str";//当前所在的关卡
- private const string Max_Instance_Value_Str = "Max_Instance_Value_Str";//最后的关卡完成情况
- private const string Instance_Point = "Instance_Point";//副本星星点数
- private const string Use_Ground_Map = "Use_Ground_Map";//使用地图
- private const string USER_ACCOUNT = "USER_ACCOUNT";
- private const string USER_PASSWORD = "USER_PASSWORD";
- #region 单利函数
- private static GameDataSetting _instance;
- public bool isConnectting = false;
- public static GameDataSetting Instance
- {
- get{
- if (_instance == null) {
- _instance = new GameDataSetting ();
- }
- return _instance;
- }
- }
- #endregion
- private GameDataSetting()
- {
- //CDebug.Log ("当前所在的关卡 " + CurInstanceValue );
- //CDebug.Log ("最后的关卡完成情况 " + MaxInstanceValue );
- }
- //清空所有记录
- public void ClearAll()
- {
- PlayerPrefs.DeleteAll ();
- }
- //亮度
- public float LuminanceValue
- {
- get
- {
- return PlayerPrefs.GetFloat (LuminanceValue_Str, 0.5f);
- }
- set
- {
- PlayerPrefs.SetFloat (LuminanceValue_Str, value);
- }
- }
- //背景音乐音量大小
- public float BgSoundValue
- {
- get
- {
- return PlayerPrefs.GetFloat (BG_Sound_Value_Str, 0.5f);
- }
- set
- {
- PlayerPrefs.SetFloat (BG_Sound_Value_Str, value);
- }
- }
- //特效音乐音量大小
- public float EffectSoundValue
- {
- get
- {
- return PlayerPrefs.GetFloat (Effect_Sound_Value_Str, 0.5f);
- }
- set
- {
- PlayerPrefs.SetFloat (Effect_Sound_Value_Str, value);
- }
- }
- //背景音乐开关
- public bool BGSoundSwitch
- {
- get
- {
- return PlayerPrefs.GetInt (BG_Sound_Switch_Str, 1) == 1;//默认是开启的
- }
- set
- {
- PlayerPrefs.SetInt (BG_Sound_Switch_Str, value ? 1:0 );
- }
- }
- //默认的用户账号
- public string DefaultUserAccount
- {
- get
- {
- return PlayerPrefs.GetString(USER_ACCOUNT, "");
- }
- set
- {
- PlayerPrefs.SetString(USER_ACCOUNT, value);
- }
- }
- //默认的用户账号
- public string DefaultUserPassword
- {
- get
- {
- return PlayerPrefs.GetString(USER_PASSWORD, "");
- }
- set
- {
- PlayerPrefs.SetString(USER_PASSWORD, value);
- }
- }
- //特效音乐开关
- public bool EffectSoundSwitch
- {
- get
- {
- return PlayerPrefs.GetInt (Effect_Sound_Switch_Str, 1) == 1;//默认是开启的
- }
- set
- {
- PlayerPrefs.SetInt (Effect_Sound_Switch_Str, value ? 1:0 );
- }
- }
- //当前所在的关卡
- public int CurInstanceValue
- {
- get
- {
- return PlayerPrefs.GetInt (Cur_Instance_Value_Str, 0);
- }
- set
- {
- CDebug.Log ("设置当前关卡" + value);
- PlayerPrefs.SetInt (Cur_Instance_Value_Str, value);
- }
- }
- //完成的最高的关卡
- public int MaxInstanceValue
- {
- get
- {
- return PlayerPrefs.GetInt (Max_Instance_Value_Str, -1);
- }
- set
- {
- PlayerPrefs.SetInt (Max_Instance_Value_Str, value);
- CDebug.Log ("最大关卡进度修改 " + value);
- }
- }
- public int GetAllPoint()
- {
- int v = 0;
- for (int i = 0; i < 5; i++) {
- v += GetInstancePoint (i);
- }
- return v;
- }
- public int GetInstancePoint(int index)
- {
- int value = 0;
- for (int i = 0; i < 3; i++) {
- if(GetInstanceTaskPoint (index, i))
- {
- value += 1;
- }
- }
- return value;
- }
- public bool GetInstanceTaskPoint(int instance_index, int task_index)
- {
- return PlayerPrefs.GetInt (InstanceTaskPoint(instance_index, task_index), 0) == 1;//
- }
- //设置副本任务的星星数量
- public void SetInstanceTaskPoint(int instance_index, int task_index)
- {
- PlayerPrefs.SetInt (InstanceTaskPoint(instance_index, task_index), 1);
- }
- private string InstanceTaskPoint(int instance_index, int task_index)
- {
- return Instance_Point + "_" +instance_index + "_" + task_index;
- }
- //使用地图
- public bool UseGroundMapSwitch
- {
- get
- {
- return true;
- return PlayerPrefs.GetInt (Use_Ground_Map, 1) == 1;//默认是开启的
- }
- set
- {
- PlayerPrefs.SetInt (Use_Ground_Map, value ? 1:0 );
- }
- }
- }
|