using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
|
/// <summary>
|
/// boss历练 和 跨服信息合并
|
/// </summary>
|
namespace vnxbqy.UI
|
{
|
public class BossTrialModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
|
{
|
public OperationBossTrial operationBossTrial = null;
|
public OperationCrossBossTrial operationBossTrialCross = null;
|
public static Operation operaType = Operation.default27;
|
public static Operation operaTypeCross = Operation.default33;
|
public static int rankType = 33; //本服个人排行
|
//public static int historyRankType = 35;
|
public static int crossRankType = 158; //跨服个人排行
|
public static int crossFamilyRankType = 160; //跨服仙盟排行
|
public static List<int> rankList = new List<int>() { rankType, crossRankType, crossFamilyRankType };
|
|
int regesitType = (int)NewDayActivityID.BossTrial;
|
int regesitCrossType = (int)NewDayActivityID.CrossBossTrial;
|
public bool IsOpen
|
{
|
get
|
{
|
//return OperationTimeHepler.Instance.SatisfyOpenCondition(operaType);
|
return OperationTimeHepler.Instance.SatisfyOpenCondition(operaType) &&
|
OperationTimeHepler.Instance.SatisfyOpenCondition(operaTypeCross, ILTimeUtility.ServerCrossNow);
|
}
|
}
|
|
//是否参与活动时间,由跨服封包决定,以跨服时间为准
|
public bool IsJoin
|
{
|
get
|
{
|
return OperationTimeHepler.Instance.SatisfyJoinCondition(operaTypeCross, ILTimeUtility.ServerCrossNow);
|
}
|
}
|
|
public bool IsPrepareTime
|
{
|
get
|
{
|
if (!IsOpen) return false;
|
return OperationTimeHepler.Instance.IsPrepareTime(operaTypeCross, ILTimeUtility.ServerCrossNow);
|
}
|
}
|
|
//是否展示结果时间, 以跨服时间为准(前提为以判断是活动中)
|
public bool IsResultShowTime
|
{
|
get
|
{
|
if (operationBossTrialCross == null)
|
return false;
|
return operationBossTrialCross.IsShowResultTime();
|
}
|
|
}
|
|
public bool IsAdvance
|
{
|
get
|
{
|
return false;
|
}
|
}
|
|
public bool priorityOpen
|
{
|
get
|
{
|
return false;
|
}
|
}
|
|
public event Action OnPlayerInfo;
|
public event Action<int> onStateUpdate;
|
public byte actNum; //对应界面
|
public int submitAllCount; //总提交凭证个数 用于排行榜 活动可以是一段时间内的总提交个数
|
public int submitCount; // 已提交凭证个数 活动可以配置每日重置
|
public int submitCountAward; // 提交凭证奖励领奖状态
|
public int subItemID; // 提交凭证物品ID
|
public int goodItemID = 621; //天玄丹 增强掉落
|
|
//查询第一名信息,界面快速切换查询回包和界面不一致 需多个ID记录
|
public int no1PlayerID = 0;
|
public int no1PlayerIDCross = 0;
|
public int no1PlayerIDCrossFamily = 0; //盟主
|
|
|
//排行榜名次信息
|
private int m_SelectRank = 0;
|
public int SelectRank
|
{
|
get { return m_SelectRank; }
|
set
|
{
|
m_SelectRank = value;
|
}
|
}
|
|
//排行榜奖励信息
|
private int m_SelectAwardRank = 0;
|
public int SelectAwardRank
|
{
|
get { return m_SelectAwardRank; }
|
set
|
{
|
m_SelectAwardRank = value;
|
}
|
}
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
public override void Init()
|
{
|
OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;
|
OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
|
OpenServerActivityCenter.Instance.Register(regesitType, this, (int)OpenServerActivityCenter.ActivityType.AT_Activity2);
|
OpenServerActivityCenter.Instance.Register(regesitCrossType, this, (int)OpenServerActivityCenter.ActivityType.AT_Activity2);
|
|
OperationTimeHepler.Instance.operationTimeUpdateEvent += operationTimeUpdateEvent;
|
packModel.refreshItemCountEvent += RefreshItemCountEvent;
|
|
RedpointCenter.Instance.redpointValueChangeEvent += OnRedpointChange;
|
subItemID = int.Parse(FuncConfigConfig.Get("BossTrial").Numerical1);
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
operationBossTrial = null;
|
operationBossTrialCross = null;
|
no1PlayerID = 0;
|
no1PlayerIDCross = 0;
|
no1PlayerIDCrossFamily = 0;
|
submitAllCount = 0;
|
submitCount = 0;
|
submitCountAward = 0;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
UpdateRedpoint();
|
}
|
|
public override void UnInit()
|
{
|
OperationTimeHepler.Instance.operationStartEvent -= OperationStartEvent;
|
OperationTimeHepler.Instance.operationEndEvent -= OperationEndEvent;
|
RedpointCenter.Instance.redpointValueChangeEvent -= OnRedpointChange;
|
OperationTimeHepler.Instance.operationTimeUpdateEvent -= operationTimeUpdateEvent;
|
packModel.refreshItemCountEvent -= RefreshItemCountEvent;
|
}
|
|
|
|
private void OperationEndEvent(Operation operationType, int state)
|
{
|
if (operationType == operaType && state == 0)
|
{
|
if (onStateUpdate != null)
|
{
|
onStateUpdate(regesitType);
|
}
|
WindowCenter.Instance.Close<BossTrialWin>();
|
}
|
}
|
|
private void OperationStartEvent(Operation operationType, int state)
|
{
|
if (operationType == operaType && state == 0)
|
{
|
if (onStateUpdate != null)
|
{
|
onStateUpdate(regesitType);
|
}
|
}
|
}
|
|
private void operationTimeUpdateEvent(Operation obj)
|
{
|
if (obj != operaType && obj != operaTypeCross)
|
return;
|
|
OperationBase operationBase1;
|
if (OperationTimeHepler.Instance.TryGetOperationTime(operaTypeCross, out operationBase1))
|
{
|
operationBossTrialCross = operationBase1 as OperationCrossBossTrial;
|
}
|
|
OperationBase operationBase;
|
if (OperationTimeHepler.Instance.TryGetOperationTime(operaType, out operationBase))
|
{
|
operationBossTrial = operationBase as OperationBossTrial;
|
}
|
|
if (operationBossTrialCross != null && operationBossTrial != null)
|
UpdateRedpoint();
|
WindowCenter.Instance.Close<BossTrialActWin>();
|
}
|
|
void OnRedpointChange(int id)
|
{
|
if (id == MainRedDot.RankActRepoint)
|
{
|
parentRedpoint.state = RedpointCenter.Instance.GetRedpointState(MainRedDot.RankActRepoint);
|
}
|
}
|
|
#region 服务端数据
|
|
|
public void UpdateHActBossTrialPlayerInfo(HAA68_tagMCActBossTrialPlayerInfo netPack)
|
{
|
actNum = netPack.ActNum;
|
submitAllCount = (int)netPack.SubmitCount;
|
submitCount = (int)netPack.SubmitAwardCount;
|
submitCountAward = (int)netPack.SubmitAwardState;
|
UpdateRedpoint();
|
OnPlayerInfo?.Invoke();
|
}
|
|
private void RefreshItemCountEvent(PackType packType, int index, int itemId)
|
{
|
if (itemId != subItemID) return;
|
if (!IsOpen) return;
|
UpdateRedpoint();
|
}
|
|
#endregion
|
|
#region 红点
|
Redpoint parentRedpoint = new Redpoint(MainRedDot.BossTrialRepoint);
|
public Redpoint redpoint = new Redpoint(MainRedDot.BossTrialRepoint, MainRedDot.BossTrialRepoint * 10);
|
|
public void UpdateRedpoint()
|
{
|
redpoint.state = RedPointState.None;
|
if (!IsOpen)
|
{
|
return;
|
}
|
|
int hasCnt = packModel.GetItemCountByID(PackType.Item, subItemID);
|
var keys = operationBossTrial.bossTrialSubmitInfo.Keys.ToList();
|
keys.Sort();
|
|
if (IsJoin)
|
{
|
//参与时间才需要提交红点
|
foreach (var tagetCnt in keys)
|
{
|
if (submitCount + hasCnt >= tagetCnt && submitCount < tagetCnt)
|
{
|
redpoint.state = RedPointState.Simple;
|
return;
|
}
|
}
|
}
|
|
foreach (var tagetCnt in keys)
|
{
|
if (submitCount < tagetCnt)
|
{
|
break;
|
}
|
if (GetSubmitAwardState(tagetCnt) == 1)
|
{
|
redpoint.state = RedPointState.Simple;
|
return;
|
}
|
}
|
|
}
|
|
//0 未达标 1 已达标未领取 2 已领取
|
public int GetSubmitAwardState(int tagetCnt)
|
{
|
if (submitCount < tagetCnt)
|
{
|
return 0;
|
}
|
if(((int)Math.Pow(2, operationBossTrial.bossTrialSubmitInfo[tagetCnt].index) & submitCountAward) == 0)
|
{
|
return 1;
|
}
|
return 2;
|
}
|
|
#endregion
|
|
//获取排行榜排名对应的奖励数据配置名次
|
public int GetRankDataIndex(int rank, Dictionary<int, ActBillboardAwards> rankInfo)
|
{
|
rank += 1;
|
var keys = rankInfo.Keys.ToList();
|
keys.Sort();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
if (rank <= keys[i])
|
{
|
return keys[i];
|
}
|
}
|
return -1;
|
}
|
|
public int GetPlayerId(RankData rankData)
|
{
|
// 检查输入数据是否为空
|
if (rankData == null)
|
return 0;
|
|
// 根据 SelectRank 的值选择对应的 ID
|
switch (SelectRank)
|
{
|
case 0:
|
case 1:
|
return (int)rankData.id;
|
case 2:
|
return (int)rankData.id2;
|
default:
|
return 0;
|
}
|
}
|
}
|
}
|
|