354 lines
9.1 KiB
C#
354 lines
9.1 KiB
C#
|
using Thousandto.Cfg.Data;
|
|||
|
using Thousandto.Code.Center;
|
|||
|
using Thousandto.Code.Global;
|
|||
|
using Thousandto.Plugins.Common;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
using System.Text;
|
|||
|
using Thousandto.Core.Base;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
public class MainFuncUpdateType
|
|||
|
{
|
|||
|
public const int None = 0;
|
|||
|
public const int Visible = 1; //刷新显示状态
|
|||
|
public const int RedPoint = 2; //刷新红点
|
|||
|
public const int Effect = 3; //刷新特效
|
|||
|
public const int LitterName = 4; //副标题
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 主功能信息
|
|||
|
/// </summary>
|
|||
|
public class MainFunctionInfo
|
|||
|
{
|
|||
|
//提醒值
|
|||
|
private bool _alertFlag = false;
|
|||
|
//是否显示
|
|||
|
private bool _isVisible = true;
|
|||
|
//当前功能是否已经开启
|
|||
|
private bool _isEbanled = true;
|
|||
|
//是否有特效显示出来
|
|||
|
private bool _isEffectShow = false;
|
|||
|
//特效是否跟随红点显示
|
|||
|
private bool _isEffectByAlert = false;
|
|||
|
//配置信息
|
|||
|
private DeclareFunctionStart _cfg;
|
|||
|
//父功能
|
|||
|
private MainFunctionInfo _parent = null;
|
|||
|
//子功能列表
|
|||
|
private List<MainFunctionInfo> _childList = new List<MainFunctionInfo>();
|
|||
|
//副标题,通过外部设置
|
|||
|
private string _littleName = string.Empty;
|
|||
|
//是否已经领取奖励
|
|||
|
private bool _isGetAward = false;
|
|||
|
|
|||
|
//配置
|
|||
|
public DeclareFunctionStart Cfg
|
|||
|
{
|
|||
|
get { return _cfg; }
|
|||
|
}
|
|||
|
|
|||
|
//图标信息
|
|||
|
public string Icon
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _cfg.MainIcon;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//显示的文本信息
|
|||
|
public string Text
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _cfg.FunctionName;
|
|||
|
}
|
|||
|
}
|
|||
|
//按钮的顺序
|
|||
|
public int SortNum
|
|||
|
{
|
|||
|
get { return _cfg.FunctionSortNum; }
|
|||
|
}
|
|||
|
|
|||
|
//功能是否可以在跨服中使用
|
|||
|
public bool FuncationInCross
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _cfg.FunctionInCross != 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 是否在主界面上显示
|
|||
|
/// </summary>
|
|||
|
public bool IsVisible
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (Cfg.OpenMenu != 0)
|
|||
|
{
|
|||
|
//打开菜单的功能,判断子功能是否开启
|
|||
|
for (int i = 0; i < _childList.Count; ++i)
|
|||
|
{
|
|||
|
if (_childList[i].IsVisible)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
return _isVisible && IsEnable && (FuncationInCross || GameCenter.GameSceneSystem.ActivedScene == null ||
|
|||
|
GameCenter.GameSceneSystem.ActivedScene.Cfg.MapType == 0);
|
|||
|
}
|
|||
|
}
|
|||
|
//自身是否visible
|
|||
|
public bool SelfIsVisible
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isVisible;
|
|||
|
}
|
|||
|
}
|
|||
|
//是否在跨服中不可用
|
|||
|
public bool IsCanNotUseInCross
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (!FuncationInCross && GameCenter.GameSceneSystem.ActivedScene != null && GameCenter.GameSceneSystem.ActivedScene.Cfg.MapType != 0)
|
|||
|
{
|
|||
|
//跨服中不可使用
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//功能是否已经开启
|
|||
|
public bool IsEnable
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isEbanled;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//是否显示红点
|
|||
|
public bool IsShowRedPoint
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return IsVisible && (_alertFlag || CheckChildAlertFlag());
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_alertFlag != value)
|
|||
|
{
|
|||
|
_alertFlag = value;
|
|||
|
DoAlertFlagChanged();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//是否显示效果
|
|||
|
public bool IsEffectShow
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isEffectShow;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//特效是否跟随红点显示
|
|||
|
public bool IsEffectByAlert
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isEffectByAlert;
|
|||
|
}
|
|||
|
}
|
|||
|
//功能ID
|
|||
|
public int ID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _cfg.FunctionId;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//父功能
|
|||
|
public MainFunctionInfo Parent
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _parent;
|
|||
|
}
|
|||
|
}
|
|||
|
//子功能列表
|
|||
|
public List<MainFunctionInfo> ChildList
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _childList;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//副标题,通过外部设置
|
|||
|
public string LittleName
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _littleName;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//是否已经领取奖励
|
|||
|
public bool IsGetAward
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isGetAward;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//当前刷新的数据类型
|
|||
|
public int CurUpdateType { get; private set; }
|
|||
|
|
|||
|
#region//构造函数
|
|||
|
public MainFunctionInfo(DeclareFunctionStart cfg)
|
|||
|
{
|
|||
|
_cfg = cfg;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region //私有函数
|
|||
|
//检测子节点的红点
|
|||
|
private bool CheckChildAlertFlag()
|
|||
|
{
|
|||
|
for (int i = 0; i < _childList.Count; ++i)
|
|||
|
{
|
|||
|
if (_childList[i].IsVisible && (_childList[i]._alertFlag || _childList[i].CheckChildAlertFlag()))
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
//执行红点改变
|
|||
|
private void DoAlertFlagChanged()
|
|||
|
{
|
|||
|
DoRefresh(MainFuncUpdateType.RedPoint);
|
|||
|
if (_parent != null)
|
|||
|
{
|
|||
|
_parent.DoAlertFlagChanged();
|
|||
|
}
|
|||
|
}
|
|||
|
//刷新回调
|
|||
|
private void DoRefresh(int updateType)
|
|||
|
{
|
|||
|
CurUpdateType = updateType;
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_FUNCTION_UPDATE, this);
|
|||
|
CurUpdateType = MainFuncUpdateType.None;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//公共接口函数
|
|||
|
//点击此功能的回调
|
|||
|
public void OnClickHandler(object param)
|
|||
|
{
|
|||
|
SetEffectEnabled(false);
|
|||
|
GameCenter.MainFunctionSystem.DoFunctionCallBack(_cfg.FunctionId, param);
|
|||
|
}
|
|||
|
//设置父节点
|
|||
|
public void SetParent(MainFunctionInfo parent)
|
|||
|
{
|
|||
|
_parent = parent;
|
|||
|
}
|
|||
|
//添加子节点
|
|||
|
public void AddChild(MainFunctionInfo child)
|
|||
|
{
|
|||
|
if (!_childList.Contains(child))
|
|||
|
{
|
|||
|
_childList.Add(child);
|
|||
|
}
|
|||
|
}
|
|||
|
//设置是否显示
|
|||
|
public void SetIsVisible(bool b)
|
|||
|
{
|
|||
|
if (_isVisible != b)
|
|||
|
{
|
|||
|
_isVisible = b;
|
|||
|
DoRefresh(MainFuncUpdateType.Visible);
|
|||
|
if (_parent != null && _parent.Cfg.OpenMenu != 0)
|
|||
|
{
|
|||
|
_parent.DoRefresh(MainFuncUpdateType.Visible);
|
|||
|
}
|
|||
|
if (IsShowRedPoint)
|
|||
|
{
|
|||
|
//功能开启时检测一次红点
|
|||
|
DoAlertFlagChanged();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//设置功能是否已经开启
|
|||
|
public void SetEnabled(bool value)
|
|||
|
{
|
|||
|
if (_isEbanled != value)
|
|||
|
{
|
|||
|
_isEbanled = value;
|
|||
|
DoRefresh(MainFuncUpdateType.Visible);
|
|||
|
if (_parent != null && _parent.Cfg.OpenMenu != 0)
|
|||
|
{
|
|||
|
_parent.DoRefresh(MainFuncUpdateType.Visible);
|
|||
|
}
|
|||
|
if (IsShowRedPoint)
|
|||
|
{
|
|||
|
//功能开启时检测一次红点
|
|||
|
DoAlertFlagChanged();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//设置效果开启
|
|||
|
public void SetEffectEnabled(bool value)
|
|||
|
{
|
|||
|
if (_isEffectShow != value)
|
|||
|
{
|
|||
|
_isEffectShow = value;
|
|||
|
DoRefresh(MainFuncUpdateType.Effect);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//设置效果开启
|
|||
|
public void SetEffectByAlert(bool value)
|
|||
|
{
|
|||
|
if (_isEffectByAlert != value)
|
|||
|
{
|
|||
|
_isEffectByAlert = value;
|
|||
|
DoRefresh(MainFuncUpdateType.Effect);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//设置副标题
|
|||
|
public void SetLittleName(string name)
|
|||
|
{
|
|||
|
if (_littleName != name)
|
|||
|
{
|
|||
|
_littleName = name;
|
|||
|
DoRefresh(MainFuncUpdateType.LitterName);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//设置是否已经领取奖励
|
|||
|
public void SetGetAward(bool b)
|
|||
|
{
|
|||
|
_isGetAward = b;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|