234 lines
7.6 KiB
C#
234 lines
7.6 KiB
C#
|
using Thousandto.Cfg.Data;
|
|||
|
using Thousandto.Code.Center;
|
|||
|
using Thousandto.Code.Global;
|
|||
|
using Thousandto.Core.Asset;
|
|||
|
|
|||
|
using Thousandto.Core.Framework;
|
|||
|
using Thousandto.Core.Base;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using UnityEngine;
|
|||
|
using Thousandto.Core.Support;
|
|||
|
using Thousandto.Core.PostEffect;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
//游戏设置的数据
|
|||
|
public class GameSetting
|
|||
|
{
|
|||
|
//最大限制数量,超过此数量表示所有都显示
|
|||
|
public const int MaxPlayerCount = 30;
|
|||
|
public const int MinPlayerCount = 4;
|
|||
|
//最大限制数量,超过此数量表示所有都显示
|
|||
|
public const int MaxVFXCount = 30;
|
|||
|
public const int MinVFXCount = 4;
|
|||
|
//需要显示的杀气值,超过此杀气值的玩家都会显示
|
|||
|
public const int MaxPkValue = 200;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
private RoleSetting _roleSetting = new RoleSetting();
|
|||
|
//逻辑设置
|
|||
|
private LogicSetting _logicSetting = new LogicSetting();
|
|||
|
//挂机设置
|
|||
|
private MandateSetting _mandateSetting = new MandateSetting();
|
|||
|
//声音设置
|
|||
|
private SoundSetting _soundSetting = new SoundSetting();
|
|||
|
//性能设置
|
|||
|
private PerformanceSetting _performanceSetting = new PerformanceSetting();
|
|||
|
|
|||
|
//测试性能
|
|||
|
private TestPrefSetting _testPreSetting = new TestPrefSetting();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//通过索引的方式进行获取信息
|
|||
|
public int this[GameSettingKeyCode index]
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return GetSetting(index);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//角色设置
|
|||
|
public RoleSetting RoleSetting
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _roleSetting;
|
|||
|
}
|
|||
|
}
|
|||
|
#region//公共接口
|
|||
|
//配置信息初始化
|
|||
|
public void Initialize()
|
|||
|
{
|
|||
|
|
|||
|
//初始化
|
|||
|
_roleSetting.Initialize();
|
|||
|
_logicSetting.Initialize();
|
|||
|
_mandateSetting.Initialize();
|
|||
|
_soundSetting.Initialize();
|
|||
|
_performanceSetting.Initialize();
|
|||
|
_testPreSetting.Initialize();
|
|||
|
//加载默认配置
|
|||
|
LoadDefault(false);
|
|||
|
GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_PLAYER_BASE_ATTR_CHANGED, OnPlayerAttrChanged);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//加载默认配置
|
|||
|
public void LoadDefault(bool isforce)
|
|||
|
{
|
|||
|
//加载默认信息
|
|||
|
_roleSetting.LoadDefault(isforce, false);
|
|||
|
_logicSetting.LoadDefault(isforce, false);
|
|||
|
_mandateSetting.LoadDefault(isforce, false);
|
|||
|
_soundSetting.LoadDefault(isforce, false);
|
|||
|
_performanceSetting.LoadDefault(isforce, false);
|
|||
|
_testPreSetting.LoadDefault(isforce, false);
|
|||
|
GameSettingCore.Save();
|
|||
|
}
|
|||
|
|
|||
|
//进入场景后的调用 ,当进入场景后配置信息的一些处理
|
|||
|
public void EnterScene(GameScene scene)
|
|||
|
{
|
|||
|
_roleSetting.EnterScene(scene);
|
|||
|
_logicSetting.EnterScene(scene);
|
|||
|
_mandateSetting.EnterScene(scene);
|
|||
|
_soundSetting.EnterScene(scene);
|
|||
|
_performanceSetting.EnterScene(scene);
|
|||
|
_testPreSetting.EnterScene(scene);
|
|||
|
}
|
|||
|
|
|||
|
//卸载
|
|||
|
public void Uninitialize()
|
|||
|
{
|
|||
|
_roleSetting.Uninitialize();
|
|||
|
_logicSetting.Uninitialize();
|
|||
|
_mandateSetting.Uninitialize();
|
|||
|
_soundSetting.Uninitialize();
|
|||
|
_performanceSetting.Uninitialize();
|
|||
|
_testPreSetting.Uninitialize();
|
|||
|
GameSettingCore.Save();
|
|||
|
GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_PLAYER_BASE_ATTR_CHANGED, OnPlayerAttrChanged);
|
|||
|
}
|
|||
|
|
|||
|
//获取设置数据
|
|||
|
public int GetSetting(GameSettingKeyCode type)
|
|||
|
{
|
|||
|
return GameSettingCore.Get(type);
|
|||
|
}
|
|||
|
|
|||
|
//判断某个配置是否开启
|
|||
|
public bool IsEnabled(GameSettingKeyCode type)
|
|||
|
{
|
|||
|
return GameSettingCore.Get(type) > 0;
|
|||
|
}
|
|||
|
|
|||
|
//设置数据
|
|||
|
public void SetSetting(GameSettingKeyCode type, int value, bool sendEvent = true)
|
|||
|
{
|
|||
|
GameSettingCore.Set(type, value);
|
|||
|
if (sendEvent)
|
|||
|
{
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UPDATEGAMESETTING_FORM);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//应用设置
|
|||
|
public void ApplySetting()
|
|||
|
{
|
|||
|
GameSettingCore.RefreshSetting();
|
|||
|
}
|
|||
|
|
|||
|
//保存设置
|
|||
|
public void SaveSetting()
|
|||
|
{
|
|||
|
GameSettingCore.Save();
|
|||
|
_roleSetting.SaveData();
|
|||
|
}
|
|||
|
|
|||
|
//设置展示质量,并不保存
|
|||
|
public void SetQualityLevelUnSave(int level)
|
|||
|
{
|
|||
|
if(_performanceSetting != null) _performanceSetting.SetQualityLevelUnSave(level);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region //处理网络消息
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//发送设置信息消息
|
|||
|
public void SendSettingToServer(GameSettingKeyCode key,int value)
|
|||
|
{
|
|||
|
//Debug.LogError("SendSettingToServer:"+key+";;"+value);
|
|||
|
MSG_Setting.ReqSendSetting msg = new MSG_Setting.ReqSendSetting();
|
|||
|
var sinfo = new MSG_Setting.setting();
|
|||
|
sinfo.type = (int)key;
|
|||
|
sinfo.value = value > 0;
|
|||
|
msg.list.Add(sinfo);
|
|||
|
msg.Send();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//发送设置信息消息
|
|||
|
public void SendSettingToServer()
|
|||
|
{
|
|||
|
|
|||
|
GameSettingKeyCode[] serverSetting = new GameSettingKeyCode[] {
|
|||
|
GameSettingKeyCode.SitDownByLocal, //原地打坐 ---服务器 301
|
|||
|
GameSettingKeyCode.MandateAutoStrikeBack, //自动反击开关 ---服务器 306
|
|||
|
GameSettingKeyCode.MandateReborn, //角色死亡后原地复活开关 ---服务器 305
|
|||
|
GameSettingKeyCode.MandateAutoEatEquip, //挂机中自动吃装备, --服务器 309
|
|||
|
GameSettingKeyCode.MandateAutoJoinTeam, //挂机中自动计入队伍 --服务器 310
|
|||
|
GameSettingKeyCode.MandateAutoAddTime, //挂机中自动增加挂机 --服务器 311
|
|||
|
};
|
|||
|
|
|||
|
MSG_Setting.ReqSendSetting msg = new MSG_Setting.ReqSendSetting();
|
|||
|
for (int i = 0; i < serverSetting.Length; i++)
|
|||
|
{
|
|||
|
var sinfo = new MSG_Setting.setting();
|
|||
|
sinfo.type = (int)serverSetting[i];
|
|||
|
sinfo.value = GameCenter.GameSetting.GetSetting(serverSetting[i]) > 0;
|
|||
|
}
|
|||
|
msg.Send();
|
|||
|
}
|
|||
|
|
|||
|
//服务器配置信息接收
|
|||
|
public void GS2U_ResSettingInfo(MSG_Setting.ResSettingInfo result)
|
|||
|
{
|
|||
|
//这里已经不被调用了,根据消息ID,它的处理已经在Lua端了.
|
|||
|
/*
|
|||
|
for (int i = 0; i < result.list.Count; i++)
|
|||
|
{
|
|||
|
GameCenter.GameSetting.SetSetting((GameSettingKeyCode)result.list[i].type, result.list[i].value ? 1 : 0);
|
|||
|
}
|
|||
|
*/
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//私有函数处理
|
|||
|
private void OnPlayerAttrChanged(object obj, object sender)
|
|||
|
{
|
|||
|
BaseProperty propetry = obj as BaseProperty;
|
|||
|
if (propetry == null) return;
|
|||
|
var lp = LocalPlayerRoot.LocalPlayer;
|
|||
|
if (lp == null) return;
|
|||
|
|
|||
|
if (propetry.CurrentChangeBasePropType == RoleBaseAttribute.Level)
|
|||
|
{
|
|||
|
_roleSetting.OnRoleLevelChanged(lp.Level);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
}
|