151 lines
4.0 KiB
C#
151 lines
4.0 KiB
C#
|
using System;
|
|||
|
using Thousandto.Cfg.Data;
|
|||
|
using Thousandto.Code.Center;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
//功能红点对象
|
|||
|
public class RedPointFunction
|
|||
|
{
|
|||
|
#region//私有变量
|
|||
|
//功能ID
|
|||
|
private int _funcID = 0;
|
|||
|
//功能数据
|
|||
|
private MainFunctionInfo _funcInfo = null;
|
|||
|
//条件数据
|
|||
|
private Dictionary<long, List<RedPointConditionBase>> _conditions = new Dictionary<long, List<RedPointConditionBase>>();
|
|||
|
//是否已经达成
|
|||
|
private bool _isReach = false;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//属性
|
|||
|
public int FuncID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _funcID;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public bool IsReach
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _isReach;
|
|||
|
}
|
|||
|
}
|
|||
|
public int CurConditionCount
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _conditions.Count;
|
|||
|
}
|
|||
|
}
|
|||
|
public Dictionary<long, List<RedPointConditionBase>> Conditions
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _conditions;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//函数
|
|||
|
//构造函数
|
|||
|
public RedPointFunction(int id)
|
|||
|
{
|
|||
|
_funcID = id;
|
|||
|
_funcInfo = GameCenter.MainFunctionSystem.GetFunctionInfo(_funcID);
|
|||
|
}
|
|||
|
//添加条件
|
|||
|
public void AddConditions(long dataID, params RedPointConditionBase[] conditions)
|
|||
|
{
|
|||
|
if (conditions == null || conditions.Length <= 0)
|
|||
|
return;
|
|||
|
|
|||
|
List<RedPointConditionBase> newCons = new List<RedPointConditionBase>(conditions.Length);
|
|||
|
for (int i = 0; i < conditions.Length; ++i)
|
|||
|
{
|
|||
|
newCons.Add(conditions[i]);
|
|||
|
if (conditions[i].Type == RedPointConditionType.Equip)
|
|||
|
GameCenter.RedPointSystem.IsRefreshEquipCon = true;
|
|||
|
}
|
|||
|
_conditions[dataID] = newCons;
|
|||
|
Check();
|
|||
|
}
|
|||
|
//删除条件
|
|||
|
public void Remove(long dataID)
|
|||
|
{
|
|||
|
if (_conditions.ContainsKey(dataID))
|
|||
|
{
|
|||
|
_conditions.Remove(dataID);
|
|||
|
}
|
|||
|
|
|||
|
Check();
|
|||
|
}
|
|||
|
//检查功能是否达成
|
|||
|
public void Check()
|
|||
|
{
|
|||
|
if(_funcInfo != null)
|
|||
|
{
|
|||
|
var iter = _conditions.GetEnumerator();
|
|||
|
try
|
|||
|
{
|
|||
|
_isReach = false;
|
|||
|
while (iter.MoveNext())
|
|||
|
{
|
|||
|
bool reach = true;
|
|||
|
for (int i = 0; i < iter.Current.Value.Count; ++i)
|
|||
|
{
|
|||
|
if (!iter.Current.Value[i].IsReach)
|
|||
|
{
|
|||
|
reach = false;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (reach)
|
|||
|
{
|
|||
|
_isReach = true;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
iter.Dispose();
|
|||
|
}
|
|||
|
|
|||
|
_funcInfo.IsShowRedPoint = _isReach;
|
|||
|
}
|
|||
|
}
|
|||
|
//清除掉所有数据
|
|||
|
public void Clear()
|
|||
|
{
|
|||
|
if (_funcInfo != null)
|
|||
|
{
|
|||
|
_funcInfo.IsShowRedPoint = false;
|
|||
|
}
|
|||
|
}
|
|||
|
//判断某个条件是否达成
|
|||
|
public bool OneConditionsIsReach(long dataID)
|
|||
|
{
|
|||
|
List<RedPointConditionBase> dataList = null;
|
|||
|
if(_conditions.TryGetValue(dataID, out dataList))
|
|||
|
{
|
|||
|
for (int i = 0; i < dataList.Count; ++i)
|
|||
|
{
|
|||
|
if (!dataList[i].IsReach)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|