//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, July 18, 2018
|
//--------------------------------------------------------
|
using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
|
|
public class MergeServerLimitedTimePackageModel : ILModel<MergeServerLimitedTimePackageModel>
|
{
|
public ILOpenServerActivityProxy activity;
|
public Operation operationType = Operation.default13;
|
public const int activityType = (int)OpenServerActivityCenter.ActivityType.AT_HFHD;
|
public const int activityID = 6;
|
|
int m_SelectIndex = 0;
|
public int selectIndex
|
{
|
get { return m_SelectIndex; }
|
set
|
{
|
if (m_SelectIndex != value)
|
{
|
if (selectUpdate != null)
|
{
|
selectUpdate(value);
|
}
|
}
|
m_SelectIndex = value;
|
}
|
}
|
public event Action<int> selectUpdate;
|
public Dictionary<int, int> DicBuyPackage = new Dictionary<int, int>();
|
public event Action UpdateLimitedTimePackageItem;
|
public event Action<int> onStateUpdate;
|
protected override void Init()
|
{
|
GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
|
GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
|
activity = new ILOpenServerActivityProxy(IsOpen, IsAdvance, priorityOpen);
|
OpenServerActivityCenter.Instance.Register(activityID, activity, activityType);
|
OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
|
}
|
|
public Redpoint redPointStre1 = new Redpoint(MainRedPoint.hfhdRedPoint, MainRedPoint.hfhdRedPoint * 100 + activityID);
|
public bool IsOpen()
|
{
|
return OperationTimeHepler.Instance.SatisfyOpenCondition(operationType);
|
}
|
|
public bool IsAdvance()
|
{
|
return OperationTimeHepler.Instance.SatisfyOpenCondition(operationType);
|
}
|
|
public bool priorityOpen()
|
{
|
return false;
|
}
|
|
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
DicBuyPackage.Clear();
|
}
|
protected override void UnInit()
|
{
|
GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
|
GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
|
|
}
|
public void OnPlayerLoginOk()
|
{
|
OperationTimeHepler.Instance.operationStartEvent -= operationStartEvent;
|
OperationTimeHepler.Instance.operationStartEvent += operationStartEvent;
|
OperationTimeHepler.Instance.operationAdvanceEvent -= operationAdvanceEvent;
|
OperationTimeHepler.Instance.operationAdvanceEvent += operationAdvanceEvent;
|
IsShowTip();
|
|
}
|
|
|
|
private void operationStartEvent(Operation arg1, int arg2)
|
{
|
if (arg1 == operationType)
|
{
|
IsShowTip();
|
if (arg2 == 0 && onStateUpdate != null)
|
{
|
onStateUpdate(activityID);
|
}
|
}
|
}
|
private void operationAdvanceEvent(Operation obj)
|
{
|
if (obj == operationType)
|
{
|
// IsShowTip();
|
if (onStateUpdate != null)
|
{
|
onStateUpdate(activityID);
|
}
|
}
|
}
|
private void OperationEndEvent(Operation arg1, int arg2)
|
{
|
if (arg1 == operationType && arg2 == 0)
|
{
|
if (onStateUpdate != null)
|
{
|
onStateUpdate(activityID);
|
}
|
}
|
}
|
|
public void IsShowTip()
|
{
|
if (OperationTimeHepler.Instance.SatisfyAdvanceCondition(operationType))
|
{
|
return;
|
}
|
int GetDayOfYear = DateTime.Now.DayOfYear;
|
int day = LocalSave.GetInt("IsMergeOpenLimitedTime");
|
bool Isbool = !IsExpired();
|
if (day != GetDayOfYear && !IsExpired())
|
{
|
// LocalSave.SetInt("IsOpenLimitedTime", GetDayOfYear);
|
redPointStre1.state = RedPointState.Simple;
|
}
|
else
|
{
|
redPointStre1.state = RedPointState.None;
|
}
|
|
}
|
public void BuyCoutList(HAA13_tagMCFlashGiftbagPlayerInfo Info)
|
{
|
OperationBase operationBase = null;
|
if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
|
{
|
return;
|
}
|
GiftPackageClass operation = operationBase as GiftPackageClass;
|
if (20 != Info.ActNum)
|
{
|
return;
|
}
|
|
for (int i = 0; i < Info.Count; i++)
|
{
|
if (DicBuyPackage.ContainsKey((int)Info.BuyCountList[i].GiftbagID))
|
{
|
DicBuyPackage[(int)Info.BuyCountList[i].GiftbagID] = (int)Info.BuyCountList[i].BuyCount;
|
}
|
else
|
{
|
DicBuyPackage.Add((int)Info.BuyCountList[i].GiftbagID, (int)Info.BuyCountList[i].BuyCount);
|
}
|
}
|
if (UpdateLimitedTimePackageItem != null)
|
{
|
UpdateLimitedTimePackageItem();
|
}
|
|
}
|
|
|
public bool IsExpired(int index = 0)
|
{
|
return !(OperationTimeHepler.Instance.SatisfyOpenCondition(operationType)
|
|| OperationTimeHepler.Instance.SatisfyAdvanceCondition(operationType));
|
//bool IsSatisfyAliveCondition = false;
|
//IsSatisfyAliveCondition = (OperationTimeHepler.Instance.SatisfyOpenCondition(operationType)
|
// || OperationTimeHepler.Instance.SatisfyAdvanceCondition(operationType));
|
//bool IsBuyBool = false;
|
//OperationBase operationBase;
|
//if (OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
|
//{
|
// GiftPackageClass operation = operationBase as GiftPackageClass;
|
// GiftPackageClass.Gift_Package gift;
|
// if (operation.TryGetGift(TimeUtility.ServerNow, out gift))
|
// {
|
// if (gift.gifts.Length > 0)
|
// {
|
// int BuyCountLimit = gift.gifts[index].limitNum;//限购数量
|
// int GiftID = gift.gifts[index].id;//礼包ID
|
// if (DicBuyPackage.ContainsKey(GiftID) && DicBuyPackage[GiftID] >= BuyCountLimit)
|
// {
|
// IsBuyBool = true;
|
// }
|
// }
|
// }
|
//}
|
//if (IsSatisfyAliveCondition)
|
//{
|
// return false;
|
//}
|
//else
|
//{
|
// return true;
|
//}
|
}
|
|
}
|