1592 lines
49 KiB
C#
1592 lines
49 KiB
C#
using UnityEngine;
|
||
using System.Collections.Generic;
|
||
using Games.ChatHistory;
|
||
using Games.Events;
|
||
using Games.GlobeDefine;
|
||
using Games.LogicObj;
|
||
using GCGame.Table;
|
||
using UnityEngine.Events;
|
||
|
||
public class PlayerPreferenceData
|
||
{
|
||
public static int DefalutInt = -1;
|
||
|
||
private const string keyAccount = "UserAccount"; // 上次登录的用户名,两个作用,测试登陆,记住上次账号,正常登陆,记录上次的UID
|
||
private static string keyPsw = "UserPsw"; // 上次登录的密码
|
||
private static string keyLastServerID = "LastServerID"; // 上次登录的服务器
|
||
private static string keyLastRoleID = "LastRoleID"; // 上次登录玩家的GUID
|
||
private static string keyLeftTabChoose = "LeftTabChoose"; // 玩家左侧标签选择
|
||
private static string keyLeftTabControl = "LeftTabControl"; // 任务追踪折叠标记
|
||
private static string keyDailyMissionGuideFlag = "DailyMissionGuideFlag"; // 日常任务教学标记
|
||
private static string keySystemNameBoard = "SystemNameBoard"; // 是否显示名字板
|
||
private static string keySystemMusic = "SystemMusic"; // 是否开启音乐
|
||
private static string keySystemSoundEffect = "SystemSoundEffect"; // 是否开启音效
|
||
private static string keySystemShock = "SystemShock"; // 是否开启震动
|
||
private static string keySystemCameraShake = "SystemCameraShake"; // 是否开启屏幕震动
|
||
private static string keySystemSoundVolume = "SystemSoundVolume"; // 音量
|
||
//private static string keySystemTableau = "SystemTableau"; // 图像品质
|
||
//private static string keySystemFloodlight = "SystemFloodlight"; // 全拼泛光
|
||
//private static string keySystemScreenMove = "SystemScreenMovet"; // 全拼泛光
|
||
private static string keySystemWallVision = "SystemWallVision"; // 遮挡可见
|
||
private static string keySystemRoleEffect = "SystemRoleEffect"; // 角色特效
|
||
private static string keySystemSkillEffect = "SystemSkillEffect"; // 技能特效
|
||
private static string keySystemDamageBoard = "SystemDamageBoard"; // 伤害板
|
||
|
||
private static string keySystemEffectLimit = "SystemEffectLimit"; // 特效密度
|
||
private static string keySystemTerrainQuality = "SystemTerrainQuality"; // 地形质量
|
||
|
||
private static string keySystemHighResolution = "SystemHighResolution"; // 高分辨率模式
|
||
|
||
private static string keySystemHighFrameRate = "SystemHighFrameRate"; // 高帧率模式
|
||
|
||
// 其他玩家隐藏配置
|
||
private const string keySystemOtherHideMask = "SystemOtherHideMask"; // 其他玩家部件隐藏掩码
|
||
|
||
private const string keySystemHideFellow = "SystemHideFellow"; // 隐藏宠物
|
||
|
||
//private static string keySystemQualityNormal = "keySystemQualityNormal"; // 法线
|
||
|
||
private static string keySystemQualityTexQuality = "keySystemQualityTexQuality"; // 高质量贴图
|
||
private static string keySystemWaterEffect = "SystemWaterEffect"; // 水特效
|
||
private static string keySystemQualityEnlighten = "keySystemQualityEnlighten"; // 环境光
|
||
private static string keySystemQualityDistortion = "keySystemQualityDistortion"; // 特效扭曲
|
||
private static string keySystemQualityDymShadow = "keySystemQualityDymShadow"; // 动态阴影
|
||
private static string keySystemQualityFog = "keySystemQualityFog"; // 雾
|
||
private static string keySystemQualityAntiAliasing = "keySystemQualityAntiAliasing"; // 抗锯齿
|
||
|
||
private static string keyChannelConfig_World = "keyChannelConfig_World";
|
||
private static string keyChannelConfig_Tell = "keyChannelConfig_Tell";
|
||
private static string keyChannelConfig_Normal = "keyChannelConfig_Normal";
|
||
private static string keyChannelConfig_Team = "keyChannelConfig_Team";
|
||
private static string keyChannelConfig_Guild = "keyChannelConfig_Guild";
|
||
private static string keyChannelConfig_Master = "keyChannelConfig_Master";
|
||
private static string keyChannelConfig_Friend = "keyChannelConfig_Friend";
|
||
private static string keyChannelConfig_System = "keyChannelConfig_System";
|
||
private static string keyChannelConfig_CloseFriendMenu = "keyChannelConfig_CloseFriendMenu";
|
||
private static string keyUseJoyStick = "keyUseJoyStick";
|
||
private static string keyUseScreenClick = "keyUseScreenClick";
|
||
private static string keyAutoTeamFollow = "keyAutoTeamFollow";
|
||
private static string keyRefuseTeam = "keyRefuseTeam";
|
||
private static string keyRefuseFriend = "keyRefuseFriend";
|
||
private static string keySwitchTargetToPet = "keySwitchTargetToPet";
|
||
private static string keyAutoRefitEquip = "keyAutoRefitEquip";
|
||
private static string keyAutoJoinTeam = "keyAutoJoinTeam";
|
||
private static string keyAutoAllowTeam = "keyAutoAllowTeam";
|
||
|
||
private static string keyAutoVoiceWiFi = "keyAutoVoiceWiFi";
|
||
private static string keyAutoVoiceGuild = "keyAutoVoiceGuild";
|
||
private static string keyAutoVoiceWorld = "keyAutoVoiceWorld";
|
||
private static string keyAutoVoiceTeam = "keyAutoVoiceTeam";
|
||
private static string keyAutoVoiceNearBy = "keyAutoVoiceNearBy";
|
||
|
||
private static string keyAppFirstRun = "keyAppFirstRun";
|
||
private static string keySystemHideOtherPlayer = "SystemHideOtherPlayer";
|
||
private static string keyUserID = "userid";
|
||
private static string keyCMBIUserID = "CYMG_KEY_userid";
|
||
private static string keyShowFashion = "ShowFashion";
|
||
private static string keyBelleActiveTip = "keyBelleActiveTip";
|
||
private static string keyNewPlayerGuideClose = "keyNewPlayerGuideClose";
|
||
//private static string keyDeathPushSetting = "keyDeathPushSetting";
|
||
//private static string keyKillNpcExpSetting = "keyKillNpcExpSetting";
|
||
private static string keyRefuseAllAddFriend = "keyRefuseAllAddFriend";
|
||
private static string keyChatFrameShowChannels = "keyChatFrameShowChannels";
|
||
private static string keyChatFriendHistory = "keyChatFriendHistory";
|
||
|
||
private static string keyXPNewPlayerGuide = "keyXPNewPlayerGuide"; //Xp新手指引标记
|
||
private static string keySystemIsPushRestaurant = "SystemIsPushRestaurant"; // 遮挡可见
|
||
private static string keyBelleMatrixTipLevel = "BelleMatrixTipLevel"; // 美人阵法激活提示
|
||
|
||
private static string keyMissionRead = "MissionReadFlag";
|
||
private static string keyCurSkillPage = "CurSkillPage";
|
||
|
||
//血蓝ID 百分比 是否开启
|
||
//private static string keyAutoUseBloodItemId = "AutoUseBloodItemId";
|
||
//private static string keyAutoUseBlueItemId = "AutoUseBlueItemId";
|
||
//private static string keyAutoUseBloodItemPercent = "AutoUseBloodItemPercent";
|
||
//private static string keyAutoUseBlueItemPercent = "AutoUseBlueItemPercent";
|
||
//private static string keyIsAutoUseBloodItemOn = "IsAutoUseBloodItemOn";
|
||
//private static string keyIsAutoUseBlueItemOn = "IsAutopUseBlueItemOn";
|
||
|
||
//快捷使用血蓝ID
|
||
private static string keyShortCutItemId = "ShortItemId";
|
||
|
||
//交易市场,搜索历史
|
||
private static string keyMarketSearchHistory = "MarketSearchHistory";
|
||
|
||
// 是否将地表法线数目减少为两张
|
||
private const string _keyUseT2M = "KeyUseT2M";
|
||
|
||
public static int ShortCutItemId
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyShortCutItemId, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyShortCutItemId, -1); //默认返回的是-1;
|
||
}
|
||
}
|
||
|
||
// 适配单个PC多开的情况,keyAccount会增加一个路径hash码来区分多个Unity
|
||
public static string LastAccount
|
||
{
|
||
set
|
||
{
|
||
// 保存两份 - 新同步的客户端可以继承上个客户端输入的账号名
|
||
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
|
||
var account = keyAccount + Animator.StringToHash(Application.dataPath);
|
||
PlayerPrefs.SetString(account, value);
|
||
#endif
|
||
PlayerPrefs.SetString(keyAccount, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
|
||
var account = keyAccount + Animator.StringToHash(Application.dataPath);
|
||
if (PlayerPrefs.HasKey(account))
|
||
return PlayerPrefs.GetString(account, null);
|
||
else
|
||
#endif
|
||
return PlayerPrefs.GetString(keyAccount, null);
|
||
}
|
||
}
|
||
|
||
public static string LastPsw
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetString(keyPsw, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetString(keyPsw, null);
|
||
}
|
||
}
|
||
|
||
public static int LastServer
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyLastServerID, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyLastServerID, -1);
|
||
}
|
||
}
|
||
|
||
public static ulong LastRoleGUID
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetString(keyLastRoleID, value.ToString());
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
string retStr = PlayerPrefs.GetString(keyLastRoleID, null);
|
||
if (null == retStr) return 0;
|
||
ulong retValue;
|
||
if (ulong.TryParse(retStr, out retValue))
|
||
{
|
||
return retValue;
|
||
}
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
public static int LeftTabChoose
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyLeftTabChoose, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyLeftTabChoose, 0);
|
||
}
|
||
}
|
||
|
||
public static int LeftTabControl
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyLeftTabControl, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyLeftTabControl, 0);
|
||
}
|
||
}
|
||
|
||
public static int DailyMissionGuideFlag
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyDailyMissionGuideFlag, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyDailyMissionGuideFlag, 0);
|
||
}
|
||
}
|
||
public static BooleanSetting SystemNameBoard = new BooleanSetting(keySystemNameBoard, true, a =>
|
||
{
|
||
if (WorldUIRoot.Instance != null)
|
||
WorldUIRoot.Instance.ResetShowHeadUi();
|
||
});
|
||
|
||
public static BooleanSetting SystemMusic = new BooleanSetting(keySystemMusic);
|
||
|
||
public static BooleanSetting SystemSoundEffect = new BooleanSetting(keySystemSoundEffect);
|
||
|
||
public static BooleanSetting SystemShock = new BooleanSetting(keySystemShock);
|
||
|
||
public static BooleanSetting SystemCameraShake = new BooleanSetting(keySystemCameraShake);
|
||
|
||
public static float SystemSoundVolum
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetFloat(keySystemSoundVolume, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetFloat(keySystemSoundVolume, 1.0f);
|
||
}
|
||
}
|
||
|
||
public static bool SystemWallVisionEnable
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keySystemWallVision, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keySystemWallVision, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static BooleanSetting SystemQualityTexQuality = new BooleanSetting(keySystemQualityTexQuality, action: QualityTexQuality);
|
||
|
||
public static BooleanSetting SystemWaterEffectEnable = new BooleanSetting(keySystemWaterEffect, action: WaterEffect);
|
||
|
||
public static BooleanSetting SystemQualityDistortion = new BooleanSetting(keySystemQualityDistortion, action: QualityDistortion);
|
||
|
||
public static BooleanSetting SystemQualityDymShadow = new BooleanSetting(keySystemQualityDymShadow, action: QualityDymShadow);
|
||
|
||
public static BooleanSetting SystemQualityFog = new BooleanSetting(keySystemQualityFog, action: QualityFog);
|
||
|
||
public static BooleanSetting SystemQualityAntiAliasing = new BooleanSetting(keySystemQualityAntiAliasing, action: QualityResolution);
|
||
|
||
public static BooleanSetting SystemQualityHighResolution =
|
||
new BooleanSetting(keySystemHighResolution, action: QualityResolution);
|
||
|
||
public static BooleanSetting SystemQualityHighFrameRate =
|
||
new BooleanSetting(keySystemHighFrameRate, action: QualityFrameRate);
|
||
|
||
public static BooleanSetting SystemRoleEffectEnable = new BooleanSetting(keySystemRoleEffect);
|
||
|
||
public static BooleanSetting SystemSkillEffectEnable = new BooleanSetting(keySystemSkillEffect);
|
||
|
||
public static BooleanSetting SystemDamageBoardEnable = new BooleanSetting(keySystemDamageBoard);
|
||
|
||
public static IntSetting SystemTerrainQuality = new IntSetting(keySystemTerrainQuality, action: QualityTerrainQuality);
|
||
|
||
public static EffectCountLimit effectCountLimit;
|
||
|
||
public static int ChannelConfig_World
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_World, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_World, 11000011);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_Tell
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_Tell, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_Tell, 10);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_Normal
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_Normal, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_Normal, 110);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_Team
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_Team, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_Team, 1010);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_Guild
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_Guild, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_Guild, 10010);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_Master
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_Master, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_Master, 100010);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_Friend
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_Friend, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_Friend, 1000000);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_System
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_System, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_System, 10000010);
|
||
}
|
||
}
|
||
|
||
public static int ChannelConfig_CloseFriendMenu
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyChannelConfig_CloseFriendMenu, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyChannelConfig_CloseFriendMenu, 1);
|
||
}
|
||
}
|
||
|
||
public static bool SystemUseJoyStick
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyUseJoyStick, value?1:0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyUseJoyStick, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemUseScreenClick
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyUseScreenClick, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyUseScreenClick, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemAutoTeamFollow
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoTeamFollow, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoTeamFollow, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemRefuseTeam
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyRefuseTeam, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyRefuseTeam, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemRefuseFriend
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyRefuseFriend, value ? 1 : 0);
|
||
GameManager.gameManager.PlayerDataPool.CommonData.AskSetCommonFlag((int)Games.UserCommonData.USER_COMMONFLAG.CF_FRIEND_NOTICE, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyRefuseFriend, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static BooleanSetting SystemSwitchTargetToPet = new BooleanSetting(keySwitchTargetToPet, true);
|
||
|
||
public static bool AutoRefitEquip
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoRefitEquip, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoRefitEquip, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool AutoJoinTeam
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoJoinTeam, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoJoinTeam, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool AutoAllowTeam
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoAllowTeam, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoAllowTeam, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemAutoVoiceWiFi
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoVoiceWiFi, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoVoiceWiFi, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemAutoVoiceGuild
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoVoiceGuild, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoVoiceGuild, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemAutoVoiceWorld
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoVoiceWorld, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoVoiceWorld, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemAutoVoiceTeam
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoVoiceTeam, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoVoiceTeam, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemAutoVoiceNearBy
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAutoVoiceNearBy, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAutoVoiceNearBy, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool IsAppFirstRun
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyAppFirstRun, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyAppFirstRun, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static string UserID
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetString(keyUserID, value);
|
||
PlayerPrefs.SetString(keyCMBIUserID, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
}
|
||
|
||
public static bool ShowFashion
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyShowFashion, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyShowFashion, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static int BelleActiveTipCount
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyBelleActiveTip, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyBelleActiveTip, 0);
|
||
}
|
||
}
|
||
|
||
public static bool NewPlayerGuideClose
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyNewPlayerGuideClose, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyNewPlayerGuideClose, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool RefuseAllAddFriend
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyRefuseAllAddFriend, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyRefuseAllAddFriend, 0) > 0;
|
||
}
|
||
}
|
||
|
||
public static bool SystemIsPushRestaurant
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keySystemIsPushRestaurant, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keySystemIsPushRestaurant, 1) > 0;
|
||
}
|
||
}
|
||
|
||
public static int BelleMatrixTipLevel
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyBelleMatrixTipLevel, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyBelleMatrixTipLevel, 1);
|
||
}
|
||
}
|
||
|
||
private static List<int> _MissionReadFlag = null;
|
||
public static bool GetMissionReadFlag(int missionID)
|
||
{
|
||
if (_MissionReadFlag == null)
|
||
{
|
||
_MissionReadFlag = new List<int>();
|
||
string readFlagData = PlayerPrefs.GetString(keyMissionRead, "");
|
||
string[] readFlags = readFlagData.Split(';');
|
||
foreach (var readFlagStr in readFlags)
|
||
{
|
||
if (!string.IsNullOrEmpty(readFlagStr))
|
||
{
|
||
_MissionReadFlag.Add(int.Parse(readFlagStr));
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
if (_MissionReadFlag.Contains(missionID))
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public static void SetMissionReadFlag(int missionID)
|
||
{
|
||
_MissionReadFlag.Add(missionID);
|
||
string missionFlagStr = "";
|
||
foreach (var readFlag in _MissionReadFlag)
|
||
{
|
||
missionFlagStr += readFlag + ";";
|
||
}
|
||
|
||
PlayerPrefs.SetString(keyMissionRead, missionFlagStr);
|
||
PlayerPrefs.Save();
|
||
}
|
||
|
||
private static List<int> _GuideFlags = null;
|
||
public static bool GetGuideFlag(int guideId)
|
||
{
|
||
if (_GuideFlags == null)
|
||
{
|
||
_GuideFlags = new List<int>();
|
||
string readFlagData = PlayerPrefs.GetString(keyXPNewPlayerGuide, "");
|
||
string[] readFlags = readFlagData.Split(';');
|
||
foreach (var readFlagStr in readFlags)
|
||
{
|
||
if (!string.IsNullOrEmpty(readFlagStr))
|
||
{
|
||
_GuideFlags.Add(int.Parse(readFlagStr));
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
if (_GuideFlags.Contains(guideId))
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public static void SetGuideFlag(int guideId)
|
||
{
|
||
if (GetGuideFlag(guideId))
|
||
return;
|
||
|
||
_GuideFlags.Add(guideId);
|
||
string guideFlagStr = "";
|
||
foreach (var readFlag in _GuideFlags)
|
||
{
|
||
guideFlagStr += readFlag + ";";
|
||
}
|
||
|
||
PlayerPrefs.SetString(keyXPNewPlayerGuide, guideFlagStr);
|
||
PlayerPrefs.Save();
|
||
}
|
||
|
||
public static int CurSkillPage
|
||
{
|
||
set
|
||
{
|
||
PlayerPrefs.SetInt(keyCurSkillPage, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
get
|
||
{
|
||
return PlayerPrefs.GetInt(keyCurSkillPage, -1);
|
||
}
|
||
}
|
||
|
||
#region 聊天
|
||
|
||
|
||
private static List<GC_CHAT.CHATTYPE> _ChatFrameChannels = null;
|
||
public static List<GC_CHAT.CHATTYPE> GetChatFrameChannels()
|
||
{
|
||
if (_ChatFrameChannels == null)
|
||
{
|
||
_ChatFrameChannels = new List<GC_CHAT.CHATTYPE>();
|
||
string channelData = PlayerPrefs.GetString(keyChatFrameShowChannels, "0;1;2;3;4;5;6;7;8;9;12;13;14");
|
||
string[] channelDatas = channelData.Split(';');
|
||
foreach (var channelStr in channelDatas)
|
||
{
|
||
if (!string.IsNullOrEmpty(channelStr))
|
||
{
|
||
int channelInt;
|
||
if (int.TryParse(channelStr, out channelInt))
|
||
{
|
||
_ChatFrameChannels.Add((GC_CHAT.CHATTYPE)channelInt);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
return _ChatFrameChannels;
|
||
}
|
||
|
||
public static void SetChatFrameChannels(List<GC_CHAT.CHATTYPE> chatFrameChannels)
|
||
{
|
||
_ChatFrameChannels = chatFrameChannels;
|
||
string channelStr = "";
|
||
foreach (var channel in _ChatFrameChannels)
|
||
{
|
||
channelStr += ((int)channel).ToString() + ";";
|
||
}
|
||
|
||
PlayerPrefs.SetString(keyChatFrameShowChannels, channelStr);
|
||
PlayerPrefs.Save();
|
||
}
|
||
|
||
public static char _FriendChatSplit = '&';
|
||
public static char _FriendChatSplit2 = '^';
|
||
public static char _FriendChatSplit3 = '|';
|
||
public static void SetFriendChatHistory(List<FriendChat> friendChatHistory)
|
||
{
|
||
string recordStr = "";
|
||
foreach (var friendChat in friendChatHistory)
|
||
{
|
||
string chatHistoryStr = "";
|
||
chatHistoryStr += friendChat.ChatGuid.ToString() + _FriendChatSplit;
|
||
chatHistoryStr += friendChat.ChatName.ToString() + _FriendChatSplit;
|
||
chatHistoryStr += friendChat.ChatIcon + _FriendChatSplit;
|
||
chatHistoryStr += friendChat.ChatLevel.ToString() + _FriendChatSplit;
|
||
chatHistoryStr += friendChat.ChatCombat.ToString() + _FriendChatSplit;
|
||
chatHistoryStr += friendChat.VIPLevel.ToString() + _FriendChatSplit;
|
||
chatHistoryStr += friendChat.PrivilegeVIP.ToString() + _FriendChatSplit;
|
||
if (friendChat.ChatList != null)
|
||
{
|
||
foreach (var chatRecord in friendChat.ChatList)
|
||
{
|
||
if (chatRecord._TempChatHistory == null)
|
||
{
|
||
chatRecord._ReadTip = 0;
|
||
}
|
||
else
|
||
{
|
||
chatRecord._ReadTip = chatRecord._TempChatHistory._ReadTip ? 1 : 0;
|
||
}
|
||
chatHistoryStr += ((int)chatRecord.RecordType).ToString() + _FriendChatSplit2 + chatRecord.ChatInfo + _FriendChatSplit2 + chatRecord._ReadTip
|
||
+ _FriendChatSplit2 + chatRecord._HeadType + _FriendChatSplit2 + chatRecord._ChatPopType + _FriendChatSplit;
|
||
}
|
||
}
|
||
recordStr += chatHistoryStr + _FriendChatSplit3;
|
||
}
|
||
if (Singleton<ObjManager>.GetInstance() != null && Singleton<ObjManager>.GetInstance().MainPlayer != null)
|
||
PlayerPrefs.SetString(keyChatFriendHistory + GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid, recordStr);
|
||
PlayerPrefs.Save();
|
||
}
|
||
|
||
public static List<FriendChat> GetFriendChatHistory()
|
||
{
|
||
List<FriendChat> historyList = new List<FriendChat>();
|
||
if (Singleton<ObjManager>.GetInstance() == null || Singleton<ObjManager>.GetInstance().MainPlayer == null)
|
||
return historyList;
|
||
string historyData = PlayerPrefs.GetString(keyChatFriendHistory + GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid, "");
|
||
|
||
var chatFriends = historyData.Split(_FriendChatSplit3);
|
||
foreach (var chatFriend in chatFriends)
|
||
{
|
||
if (string.IsNullOrEmpty(chatFriend))
|
||
continue;
|
||
|
||
var chatInfos = chatFriend.Split(_FriendChatSplit);
|
||
if (chatInfos.Length < 8)
|
||
continue;
|
||
|
||
ulong guid;
|
||
string name;
|
||
int level;
|
||
int combat;
|
||
int vip;
|
||
int privilegeVip;
|
||
if (ulong.TryParse(chatInfos[0], out guid)
|
||
&& int.TryParse(chatInfos[3], out level)
|
||
&& int.TryParse(chatInfos[4], out combat)
|
||
&& int.TryParse(chatInfos[5], out vip)
|
||
&& int.TryParse(chatInfos[6], out privilegeVip))
|
||
{
|
||
name = chatInfos[1];
|
||
FriendChat friendChat = new FriendChat();
|
||
friendChat.ChatGuid = guid;
|
||
friendChat.ChatName = name;
|
||
friendChat.ChatIcon = chatInfos[2];
|
||
friendChat.ChatLevel = level;
|
||
friendChat.ChatCombat = combat;
|
||
friendChat.VIPLevel = vip;
|
||
friendChat.PrivilegeVIP = privilegeVip;
|
||
friendChat.ChatList = new List<FriendChatRecord>();
|
||
|
||
for (int i = 5; i < chatInfos.Length; ++i)
|
||
{
|
||
var chatRecordStr = chatInfos[i].Split(_FriendChatSplit2);
|
||
if (chatRecordStr.Length != 5)
|
||
continue;
|
||
|
||
int chatType;
|
||
if (!int.TryParse(chatRecordStr[0], out chatType))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
int readTip;
|
||
if (!int.TryParse(chatRecordStr[2], out readTip))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
int headType = -1;
|
||
if (!int.TryParse(chatRecordStr[3], out headType))
|
||
continue;
|
||
|
||
int chatPopType = -1;
|
||
if (!int.TryParse(chatRecordStr[4], out chatPopType))
|
||
continue;
|
||
|
||
FriendChatRecord chatRecord = new FriendChatRecord();
|
||
chatRecord.RecordType = (FriendChatRecord.RECORD_TYPE)chatType;
|
||
chatRecord.ChatInfo = chatRecordStr[1];
|
||
chatRecord._ReadTip = readTip;
|
||
chatRecord._HeadType = headType;
|
||
chatRecord._ChatPopType = chatPopType;
|
||
friendChat.ChatList.Add(chatRecord);
|
||
}
|
||
historyList.Add(friendChat);
|
||
}
|
||
}
|
||
|
||
if (historyList.Count == 0)
|
||
{
|
||
FriendChat sysChat = new FriendChat();
|
||
sysChat.ChatGuid = 0;
|
||
sysChat.ChatName = StrDictionary.GetClientDictionaryString("#{5213}");
|
||
sysChat.ChatList = new List<FriendChatRecord>();
|
||
historyList.Add(sysChat);
|
||
|
||
//FriendChat helpChat = new FriendChat();
|
||
//helpChat.ChatGuid = 1;
|
||
//helpChat.ChatName = StrDictionary.GetClientDictionaryString("#{5214}");
|
||
//helpChat.ChatList = new List<FriendChatRecord>();
|
||
//historyList.Add(helpChat);
|
||
}
|
||
return historyList;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 交易市场
|
||
|
||
private static int _DefaultSaveSearchHistoryCnt = 8;
|
||
private static List<int> _MarketSearchHistorys = null;
|
||
public static List<int> GetMarketSearchHistory()
|
||
{
|
||
if (_MarketSearchHistorys == null)
|
||
{
|
||
_MarketSearchHistorys = new List<int>();
|
||
string valueData = PlayerPrefs.GetString(keyMarketSearchHistory, "");
|
||
string[] valueDatas = valueData.Split(';');
|
||
foreach (var valueStr in valueDatas)
|
||
{
|
||
if (!string.IsNullOrEmpty(valueStr))
|
||
{
|
||
int valueInt;
|
||
if (int.TryParse(valueStr, out valueInt))
|
||
{
|
||
_MarketSearchHistorys.Add(valueInt);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
return _MarketSearchHistorys;
|
||
}
|
||
|
||
public static void SetMarketSearchHistory(List<int> searchHistory)
|
||
{
|
||
_MarketSearchHistorys = searchHistory;
|
||
|
||
}
|
||
|
||
public static void SaveMarketSearchHistory()
|
||
{
|
||
if (_MarketSearchHistorys.Count > _DefaultSaveSearchHistoryCnt)
|
||
{
|
||
_MarketSearchHistorys.RemoveAt(0);
|
||
}
|
||
|
||
string valueStr = "";
|
||
foreach (var valueInt in _MarketSearchHistorys)
|
||
{
|
||
valueStr += ((int)valueInt).ToString() + ";";
|
||
}
|
||
|
||
PlayerPrefs.SetString(keyMarketSearchHistory, valueStr);
|
||
PlayerPrefs.Save();
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 画质设定
|
||
|
||
public static readonly EffectCountLimit[] effectCountLimits =
|
||
{
|
||
new EffectCountLimit(8, 12),
|
||
new EffectCountLimit(16, 24),
|
||
new EffectCountLimit(32, 48)
|
||
};
|
||
|
||
public static readonly ModelHideLevel[] modelHideLevels =
|
||
{
|
||
new ModelHideLevel
|
||
{
|
||
otherPlayerCount = GlobeVar.SHOW_PLAYER_NUM_MAX / 3,
|
||
hideFellow = true,
|
||
effectLimit = 0,
|
||
otherPlayerHideMask = (1 << ModelPart.mount) + (1 << ModelPart.wing) + (1 << ModelPart.aura),
|
||
},
|
||
new ModelHideLevel
|
||
{
|
||
otherPlayerCount = GlobeVar.SHOW_PLAYER_NUM_MAX / 2,
|
||
effectLimit = 1,
|
||
otherPlayerHideMask = 1 << ModelPart.wing,
|
||
},
|
||
new ModelHideLevel
|
||
{
|
||
otherPlayerCount = GlobeVar.SHOW_PLAYER_NUM_MAX,
|
||
effectLimit = 2,
|
||
}
|
||
};
|
||
|
||
public static readonly QualityLevelData[] qualityStandards =
|
||
{
|
||
// 低画质配置 - 效果全关
|
||
new QualityLevelData
|
||
{
|
||
highResolution = true,
|
||
},
|
||
// 中画质配置
|
||
new QualityLevelData
|
||
{
|
||
//water = true,
|
||
fog = true,
|
||
texQuality = true,
|
||
highResolution = true,
|
||
terrainQualityLevel = 1,
|
||
},
|
||
// 高画质配置 - 效果全开
|
||
new QualityLevelData
|
||
{
|
||
water = true,
|
||
distortion = true,
|
||
dynamicShadow = true,
|
||
fog = true,
|
||
// antiAntialiasing = true,
|
||
texQuality = true,
|
||
highResolution = true,
|
||
highFrame = true,
|
||
terrainQualityLevel = 2,
|
||
}
|
||
};
|
||
// 如果启用任意高配置功能,视为高配置;如果启用任意中配置功能,视为中配置。
|
||
public static int GetQualityLevel()
|
||
{
|
||
var result = -1;
|
||
for (var i = 0; i < qualityStandards.Length; i++)
|
||
{
|
||
if (qualityStandards[i].IsCurrentOrLower())
|
||
{
|
||
result = i;
|
||
break;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
private static bool _limitInit;
|
||
public static void InitLimit()
|
||
{
|
||
if (!_limitInit)
|
||
{
|
||
_limitInit = true;
|
||
EffectLimitLevel.onSettingUpdate += QualityEffectLimit;
|
||
QualityEffectLimit(EffectLimitLevel.current);
|
||
}
|
||
}
|
||
|
||
private static bool _graphicsInit;
|
||
public static void InitCurrentGraphics()
|
||
{
|
||
if (!_graphicsInit)
|
||
{
|
||
_graphicsInit = true;
|
||
SystemWaterEffectEnable.ApplySetting();
|
||
SystemQualityDistortion.ApplySetting();
|
||
SystemQualityDymShadow.ApplySetting();
|
||
SystemQualityFog.ApplySetting();
|
||
SystemQualityAntiAliasing.ApplySetting();
|
||
SystemQualityTexQuality.ApplySetting();
|
||
SystemTerrainQuality.ApplySetting();
|
||
SystemQualityHighFrameRate.ApplySetting();
|
||
SystemQualityHighResolution.ApplySetting();
|
||
}
|
||
}
|
||
|
||
public static void WaterEffect(bool isOn)
|
||
{
|
||
// 没有深度贴图支持的设备就让他调着玩
|
||
isOn = isOn && SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth);
|
||
ToggleShaderKeyword("WATER_DEPTH_OFF", !isOn);
|
||
CameraController.UseDepthTexture = isOn;
|
||
}
|
||
|
||
private static readonly string[] _distortionShaderNames =
|
||
{
|
||
"Shader Forge/Xn_Zs",
|
||
"Zhanyou/Particles/Niuqu",
|
||
"Shader Forge/XuanNvNiuQu",
|
||
};
|
||
|
||
public static void QualityDistortion(bool isOn)
|
||
{
|
||
// Hack: iOS 不允许开启扭曲,避开一个GrabPass的缓存bug。
|
||
#if UNITY_IPHONE || UNITY_IOS
|
||
isOn = false;
|
||
#endif
|
||
for (var i = 0; i < _distortionShaderNames.Length; i++)
|
||
{
|
||
var shaderName = _distortionShaderNames[i];
|
||
var shader = Shader.Find(shaderName);
|
||
if (shader != null)
|
||
shader.maximumLOD = isOn ? 1000 : 100;
|
||
}
|
||
}
|
||
|
||
public static void QualityDymShadow(bool isOn)
|
||
{
|
||
Obj_MainPlayer.UseDynamicShadow = isOn;
|
||
//if (isOn)
|
||
//{
|
||
// QualitySettings.SetQualityLevel(6);
|
||
// QualitySettings.shadowResolution = ShadowResolution.High;
|
||
//}
|
||
}
|
||
|
||
private static void ToggleShaderKeyword(string keyword, bool isOn)
|
||
{
|
||
var current = Shader.IsKeywordEnabled(keyword);
|
||
if (current != isOn)
|
||
{
|
||
if (isOn)
|
||
Shader.EnableKeyword(keyword);
|
||
else
|
||
Shader.DisableKeyword(keyword);
|
||
}
|
||
}
|
||
|
||
public static void QualityFog(bool isOn)
|
||
{
|
||
EventDispatcher.Instance.Dispatch(Games.Events.EventId.FogSettingUpdate, isOn);
|
||
}
|
||
|
||
public static bool useLowResolution { get; private set; }
|
||
public static void QualityResolution(bool isOn)
|
||
{
|
||
var antiAliasing = false;
|
||
var lowRes = !SystemQualityHighResolution;
|
||
// 反锯齿必须高分辨率才允许开启
|
||
if (!lowRes)
|
||
antiAliasing = SystemQualityAntiAliasing;
|
||
if (lowRes != useLowResolution)
|
||
{
|
||
useLowResolution = lowRes;
|
||
EventDispatcher.Instance.Dispatch(Games.Events.EventId.LowResolution, useLowResolution);
|
||
}
|
||
// 2019.04.08 - 干掉性价比低的抗锯齿配置,成倍增加渲染负担
|
||
//QualitySettings.antiAliasing = antiAliasing ? 2 : 0;
|
||
QualitySettings.antiAliasing = 0;
|
||
}
|
||
|
||
public static void QualityFrameRate(bool isOn)
|
||
{
|
||
Application.targetFrameRate = isOn ?
|
||
#if UNITY_EDITOR
|
||
-1 :
|
||
#else
|
||
GlobeVar.highFrameRate :
|
||
#endif
|
||
GlobeVar.lowFrameRate;
|
||
}
|
||
|
||
public static int CurrentFrameLock()
|
||
{
|
||
return SystemQualityHighFrameRate ? GlobeVar.highFrameRate : GlobeVar.lowFrameRate;
|
||
}
|
||
|
||
public static void QualityTexQuality(bool isOn)
|
||
{
|
||
ToggleShaderKeyword("CHARACTER_NORMAL_OFF", !isOn);
|
||
}
|
||
|
||
public static void QualityEffectLimit(int level)
|
||
{
|
||
effectCountLimit = effectCountLimits[level];
|
||
}
|
||
|
||
public static void QualityTerrainQuality(int level)
|
||
{
|
||
if (level > 1)
|
||
{
|
||
ToggleShaderKeyword("T4M_NORMAL_OFF", false);
|
||
ToggleShaderKeyword("T2M_NORMAL", false);
|
||
ToggleShaderKeyword("T4M_UNITY_GI_OFF", false);
|
||
}
|
||
else if (level > 0)
|
||
{
|
||
ToggleShaderKeyword("T4M_NORMAL_OFF", false);
|
||
ToggleShaderKeyword("T2M_NORMAL", true);
|
||
ToggleShaderKeyword("T4M_UNITY_GI_OFF", false);
|
||
}
|
||
else
|
||
{
|
||
ToggleShaderKeyword("T4M_NORMAL_OFF", true);
|
||
ToggleShaderKeyword("T2M_NORMAL", true);
|
||
ToggleShaderKeyword("T4M_UNITY_GI_OFF", true);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 动态画质配置
|
||
public static IntSetting EffectLimitLevel = new IntSetting(keySystemEffectLimit);
|
||
|
||
public static IntHideSetting OtherPlayerHideMask = new IntHideSetting(new IntSetting(keySystemOtherHideMask));
|
||
|
||
public static BoolHideSetting SystemHideFellow = new BoolHideSetting(new BooleanSetting(keySystemHideFellow, false));
|
||
|
||
public static IntSetting ShowOtherPlayerCount = new IntSetting(keySystemHideOtherPlayer, GlobeVar.SHOW_PLAYER_NUM_MAX);
|
||
#endregion
|
||
}
|
||
///// <summary>
|
||
///// 返回配置数值和动态数值中较小值的设置
|
||
///// </summary>
|
||
//public class MinIntSetting : HideSettingBase<int>
|
||
//{
|
||
// public override int value
|
||
// {
|
||
// get { return Mathf.Min(dynamicValue, staticSetting.current); }
|
||
// }
|
||
|
||
// public override void ResetDynamic()
|
||
// {
|
||
// dynamicValue = int.MaxValue;
|
||
// }
|
||
|
||
// public MinIntSetting(IntSetting intSetting) : base(intSetting)
|
||
// {
|
||
// dynamicValue = int.MaxValue;
|
||
// }
|
||
//}
|
||
|
||
/// <summary>
|
||
/// 融合配置文件以及运行时不保存修正的动态配置
|
||
/// </summary>
|
||
public abstract class HideSettingBase<T> where T : struct
|
||
{
|
||
public event UnityAction<T> onValueUpdate;
|
||
public readonly SettingBase<T> staticSetting;
|
||
|
||
public abstract T value { get; }
|
||
|
||
public T dynamicValue { get; protected set; }
|
||
|
||
protected HideSettingBase(SettingBase<T> settingBase)
|
||
{
|
||
staticSetting = settingBase;
|
||
}
|
||
|
||
public void SetDynamicValue(T newValue)
|
||
{
|
||
var before = value;
|
||
dynamicValue = newValue;
|
||
var after = value;
|
||
if (onValueUpdate != null && !before.Equals(after))
|
||
onValueUpdate.Invoke(after);
|
||
}
|
||
|
||
public virtual void ResetDynamic()
|
||
{
|
||
SetDynamicValue(default(T));
|
||
}
|
||
|
||
public void SetStaticValue(T newValue)
|
||
{
|
||
var before = value;
|
||
staticSetting.Set(newValue);
|
||
var after = value;
|
||
if (onValueUpdate != null && !before.Equals(after))
|
||
onValueUpdate.Invoke(after);
|
||
}
|
||
|
||
public static implicit operator T(HideSettingBase<T> value)
|
||
{
|
||
return value.value;
|
||
}
|
||
}
|
||
|
||
public class IntHideSetting : HideSettingBase<int>
|
||
{
|
||
public override int value
|
||
{
|
||
get { return staticSetting.current | dynamicValue; }
|
||
}
|
||
|
||
public IntHideSetting(IntSetting settingBase) : base(settingBase)
|
||
{
|
||
}
|
||
}
|
||
|
||
public class BoolHideSetting : HideSettingBase<bool>
|
||
{
|
||
public override bool value
|
||
{
|
||
get { return staticSetting.current || dynamicValue; }
|
||
}
|
||
|
||
public BoolHideSetting(BooleanSetting settingBase) : base(settingBase)
|
||
{
|
||
}
|
||
}
|
||
|
||
public abstract class SettingBase<T> where T : struct
|
||
{
|
||
private readonly string _key;
|
||
private readonly UnityAction<T> _action;
|
||
|
||
public T current
|
||
{
|
||
get
|
||
{
|
||
if (!_init)
|
||
{
|
||
_init = true;
|
||
_current = GetFromPlayerPref(_key, _current);
|
||
}
|
||
|
||
return _current;
|
||
}
|
||
private set
|
||
{
|
||
_current = value;
|
||
}
|
||
}
|
||
|
||
private T _current;
|
||
private bool _init;
|
||
public event UnityAction<T> onSettingUpdate;
|
||
|
||
protected SettingBase(string key, T defaultValue, UnityAction<T> action = null)
|
||
{
|
||
_key = key;
|
||
_current = defaultValue;
|
||
_action = action;
|
||
}
|
||
|
||
public void Set(T value)
|
||
{
|
||
if (!current.Equals(value))
|
||
{
|
||
current = value;
|
||
ApplySetting();
|
||
SetToPlayerPref(_key, value);
|
||
}
|
||
}
|
||
|
||
public void ApplySetting()
|
||
{
|
||
if (_action != null)
|
||
_action(current);
|
||
if (onSettingUpdate != null)
|
||
onSettingUpdate(current);
|
||
}
|
||
|
||
protected abstract T GetFromPlayerPref(string key, T defaultValue);
|
||
|
||
protected abstract void SetToPlayerPref(string key, T value);
|
||
|
||
public static implicit operator T(SettingBase<T> value)
|
||
{
|
||
return value.current;
|
||
}
|
||
|
||
public override string ToString()
|
||
{
|
||
return current.ToString();
|
||
}
|
||
}
|
||
|
||
public class BooleanSetting : SettingBase<bool>
|
||
{
|
||
public BooleanSetting(string key, bool defaultValue = true, UnityAction<bool> action = null) : base(key,
|
||
defaultValue, action)
|
||
{
|
||
}
|
||
|
||
protected override bool GetFromPlayerPref(string key, bool defaultValue)
|
||
{
|
||
return PlayerPrefs.GetInt(key, defaultValue ? 1 : 0) > 0;
|
||
}
|
||
|
||
protected override void SetToPlayerPref(string key, bool value)
|
||
{
|
||
PlayerPrefs.SetInt(key, value ? 1 : 0);
|
||
PlayerPrefs.Save();
|
||
}
|
||
}
|
||
|
||
public class IntSetting : SettingBase<int>
|
||
{
|
||
public IntSetting(string key, int defaultValue = default(int), UnityAction<int> action = null) : base(key,
|
||
defaultValue, action)
|
||
{
|
||
}
|
||
|
||
protected override int GetFromPlayerPref(string key, int defaultValue)
|
||
{
|
||
return PlayerPrefs.GetInt(key, defaultValue);
|
||
}
|
||
|
||
protected override void SetToPlayerPref(string key, int value)
|
||
{
|
||
PlayerPrefs.SetInt(key, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
}
|
||
|
||
public class FloatSetting : SettingBase<float>
|
||
{
|
||
public FloatSetting(string key, float defaultValue = default(float), UnityAction<float> action = null) : base(key,
|
||
defaultValue, action)
|
||
{
|
||
}
|
||
|
||
protected override float GetFromPlayerPref(string key, float defaultValue)
|
||
{
|
||
return PlayerPrefs.GetFloat(key, defaultValue);
|
||
}
|
||
|
||
protected override void SetToPlayerPref(string key, float value)
|
||
{
|
||
PlayerPrefs.SetFloat(key, value);
|
||
PlayerPrefs.Save();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 定义一个画质等级参数表
|
||
/// </summary>
|
||
public struct QualityLevelData
|
||
{
|
||
public bool water;
|
||
public bool distortion;
|
||
public bool dynamicShadow;
|
||
public bool fog;
|
||
public bool antiAntialiasing;
|
||
public bool texQuality;
|
||
public bool highFrame;
|
||
public bool highResolution;
|
||
public int terrainQualityLevel;
|
||
|
||
public bool MatchLevel(QualityLevelData levelData)
|
||
{
|
||
return water == levelData.water &&
|
||
distortion == levelData.distortion &&
|
||
dynamicShadow == levelData.dynamicShadow &&
|
||
fog == levelData.fog &&
|
||
antiAntialiasing == levelData.antiAntialiasing &&
|
||
texQuality == levelData.texQuality &&
|
||
terrainQualityLevel == levelData.terrainQualityLevel &&
|
||
highFrame == levelData.highFrame &&
|
||
highResolution == levelData.highResolution;
|
||
}
|
||
/// <summary>
|
||
/// 是否比当前画质配置更低
|
||
/// </summary>
|
||
public bool IsCurrentOrLower()
|
||
{
|
||
var result = (!PlayerPreferenceData.SystemWaterEffectEnable || water) &&
|
||
(!PlayerPreferenceData.SystemQualityDistortion || distortion) &&
|
||
(!PlayerPreferenceData.SystemQualityDymShadow || dynamicShadow) &&
|
||
(!PlayerPreferenceData.SystemQualityFog || fog) &&
|
||
(!PlayerPreferenceData.SystemQualityAntiAliasing || antiAntialiasing) &&
|
||
(!PlayerPreferenceData.SystemQualityTexQuality || texQuality) &&
|
||
(!PlayerPreferenceData.SystemQualityHighFrameRate || highFrame) &&
|
||
(!PlayerPreferenceData.SystemQualityHighResolution || highResolution) &&
|
||
PlayerPreferenceData.SystemTerrainQuality <= terrainQualityLevel;
|
||
return result;
|
||
}
|
||
|
||
public void MatchCurrent()
|
||
{
|
||
water = PlayerPreferenceData.SystemWaterEffectEnable;
|
||
distortion = PlayerPreferenceData.SystemQualityDistortion;
|
||
dynamicShadow = PlayerPreferenceData.SystemQualityDymShadow;
|
||
fog = PlayerPreferenceData.SystemQualityFog;
|
||
antiAntialiasing = PlayerPreferenceData.SystemQualityAntiAliasing;
|
||
texQuality = PlayerPreferenceData.SystemQualityTexQuality;
|
||
terrainQualityLevel = PlayerPreferenceData.SystemTerrainQuality;
|
||
highFrame = PlayerPreferenceData.SystemQualityHighFrameRate;
|
||
highResolution = PlayerPreferenceData.SystemQualityHighResolution;
|
||
}
|
||
|
||
public void ApplyToCurrent()
|
||
{
|
||
PlayerPreferenceData.SystemWaterEffectEnable.Set(water);
|
||
PlayerPreferenceData.SystemQualityDistortion.Set(distortion);
|
||
PlayerPreferenceData.SystemQualityDymShadow.Set(dynamicShadow);
|
||
PlayerPreferenceData.SystemQualityFog.Set(fog);
|
||
PlayerPreferenceData.SystemQualityAntiAliasing.Set(antiAntialiasing);
|
||
PlayerPreferenceData.SystemQualityTexQuality.Set(texQuality);
|
||
PlayerPreferenceData.SystemTerrainQuality.Set(terrainQualityLevel);
|
||
PlayerPreferenceData.SystemQualityHighFrameRate.Set(highFrame);
|
||
PlayerPreferenceData.SystemQualityHighResolution.Set(highResolution);
|
||
}
|
||
}
|
||
|
||
public struct ModelHideLevel
|
||
{
|
||
public bool hideFellow;
|
||
public int otherPlayerHideMask;
|
||
public int otherPlayerCount;
|
||
public int effectLimit;
|
||
|
||
public bool MatchLevel(ModelHideLevel levelData)
|
||
{
|
||
return hideFellow == levelData.hideFellow &&
|
||
otherPlayerHideMask == levelData.otherPlayerHideMask &&
|
||
otherPlayerCount == levelData.otherPlayerCount &&
|
||
effectLimit == levelData.effectLimit;
|
||
}
|
||
|
||
public void ApplyToStatic()
|
||
{
|
||
PlayerPreferenceData.SystemHideFellow.SetStaticValue(hideFellow);
|
||
PlayerPreferenceData.OtherPlayerHideMask.SetStaticValue(otherPlayerHideMask);
|
||
PlayerPreferenceData.ShowOtherPlayerCount.Set(otherPlayerCount);
|
||
PlayerPreferenceData.EffectLimitLevel.Set(effectLimit);
|
||
}
|
||
|
||
public void MatchCurrentStatic()
|
||
{
|
||
hideFellow = PlayerPreferenceData.SystemHideFellow.staticSetting.current;
|
||
otherPlayerHideMask = PlayerPreferenceData.OtherPlayerHideMask.staticSetting;
|
||
otherPlayerCount = PlayerPreferenceData.ShowOtherPlayerCount.current;
|
||
effectLimit = PlayerPreferenceData.EffectLimitLevel.current;
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 定义一个特效数目限制
|
||
/// </summary>
|
||
public struct EffectCountLimit
|
||
{
|
||
public readonly int commonCount;
|
||
public readonly int importantCount;
|
||
|
||
public EffectCountLimit(int common, int important)
|
||
{
|
||
commonCount = common;
|
||
importantCount = important;
|
||
}
|
||
}
|