| | |
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | | public class FlashRushToBuyModel : Model,IBeforePlayerDataInitialize,IAfterPlayerDataInitialize,IPlayerLoginOk
|
| | | public class FlashRushToBuyModel : Model,IBeforePlayerDataInitialize,IPlayerLoginOk,IOpenServerActivity
|
| | | {
|
| | | StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
| | | public override void Init()
|
| | | {
|
| | | |
| | | OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;
|
| | | OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
|
| | | OperationTimeHepler.Instance.operationAdvanceEvent += OperationAdvanceEvent;
|
| | | TimeMgr.Instance.OnDayEvent += OnDayEvent;
|
| | | OpenServerActivityCenter.Instance.Register(4, this);
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | | {
|
| | |
|
| | | }
|
| | | public void OnAfterPlayerDataInitialize()
|
| | | {
|
| | |
|
| | | }
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | |
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | | OperationTimeHepler.Instance.operationStartEvent -= OperationStartEvent;
|
| | | OperationTimeHepler.Instance.operationEndEvent -= OperationEndEvent;
|
| | | OperationTimeHepler.Instance.operationAdvanceEvent -= OperationAdvanceEvent;
|
| | | TimeMgr.Instance.OnDayEvent -= OnDayEvent;
|
| | | }
|
| | |
|
| | | public bool IsOpen
|
| | | {
|
| | | get
|
| | | {
|
| | | return OperationTimeHepler.Instance.SatisfyOpenCondition(Operation.FlashRushToBuy);
|
| | | }
|
| | | }
|
| | |
|
| | | public bool priorityOpen
|
| | | {
|
| | | get
|
| | | {
|
| | | return flashSaleRedpoint.state == RedPointState.Simple;
|
| | | }
|
| | | }
|
| | |
|
| | | public bool IsAdvance
|
| | | {
|
| | | get
|
| | | {
|
| | | return OperationTimeHepler.Instance.SatisfyAdvanceCondition(Operation.FlashRushToBuy);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public OperationFlashRushToBuy.FlashSale presentFlashSale { get; private set; }
|
| | | public void UpdateSelectFlashSaleTime(int index)
|
| | | {
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashRushToBuy, out operationBase))
|
| | | {
|
| | | OperationFlashRushToBuy operation = operationBase as OperationFlashRushToBuy;
|
| | | OperationFlashRushToBuy.FlashSale flashSale;
|
| | | operation.TryGetFlashSale(TimeUtility.ServerNow, out flashSale);
|
| | | presentFlashSale = flashSale;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OperationEndEvent(Operation type, int state)
|
| | | {
|
| | | if (type == Operation.FlashSale && state == 0)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | onStateUpate(4);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OperationAdvanceEvent(Operation type)
|
| | | {
|
| | | if (type == Operation.FlashSale)
|
| | | {
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | onStateUpate(4);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OperationStartEvent(Operation type, int state)
|
| | | {
|
| | | if (type == Operation.FlashSale && state == 0)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | onStateUpate(4);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnDayEvent()
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | public void SetDayRemind()
|
| | | {
|
| | | if (flashSaleRedpoint.state == RedPointState.Simple)
|
| | | {
|
| | | DayRemind.Instance.SetDayRemind(DayRemind.FLASHSALE_REDPOINT, true);
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | public void SendBuyFlashSale(OperationFlashSale.FlashSaleGift gift)
|
| | | {
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashSale, out operationBase))
|
| | | {
|
| | | OperationFlashSale operation = operationBase as OperationFlashSale;
|
| | | if (operation.InAdvanceTime(TimeUtility.ServerNow))
|
| | | {
|
| | | var seconds = operation.GetSecondsBeforeStart(TimeUtility.ServerNow);
|
| | | SysNotifyMgr.Instance.ShowTip("FlashSaleAdvanceLimit", TimeUtility.SecondsToHMS(seconds));
|
| | | return;
|
| | | }
|
| | | if (!operation.InTime(TimeUtility.ServerNow))
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("ActiveOutTime");
|
| | | return;
|
| | | }
|
| | | if (!gift.Equals(default(OperationFlashSale.FlashSaleGift)))
|
| | | {
|
| | | var buyInfo = storeModel.GetBuyShopLimit((uint)gift.id);
|
| | | var buyCount = 0;
|
| | | if (buyInfo != null)
|
| | | {
|
| | | buyCount = buyInfo.BuyCnt;
|
| | | }
|
| | | if (buyCount >= gift.limitNum)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (UIHelper.GetMoneyCnt(gift.moneyType) < (ulong)gift.moneyNumber)
|
| | | {
|
| | | switch (gift.moneyType)
|
| | | {
|
| | | case 1:
|
| | | if (VersionConfig.Get().isBanShu)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GoldErr");
|
| | | return;
|
| | | }
|
| | | WindowCenter.Instance.Open<RechargeTipWin>();
|
| | | break;
|
| | | default:
|
| | | SysNotifyMgr.Instance.ShowTip("LackMoney", gift.moneyType);
|
| | | break;
|
| | | }
|
| | | return;
|
| | | }
|
| | | if (gift.moneyType == 1)
|
| | | {
|
| | | ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),
|
| | | Language.Get("OSTimeLimitGiftConfirm", gift.moneyNumber), (bool isOk) =>
|
| | | {
|
| | | if (isOk)
|
| | | {
|
| | | C0803_tagCBuyItemList pak = new C0803_tagCBuyItemList();
|
| | | pak.NPCID = 0;
|
| | | pak.BuyItemIndex = (ushort)gift.id;
|
| | | pak.BuyCount = 1;
|
| | | GameNetSystem.Instance.SendInfo(pak);
|
| | | }
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | C0803_tagCBuyItemList pak = new C0803_tagCBuyItemList();
|
| | | pak.NPCID = 0;
|
| | | pak.BuyItemIndex = (ushort)gift.id;
|
| | | pak.BuyCount = 1;
|
| | | GameNetSystem.Instance.SendInfo(pak);
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("ActiveOutTime");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public bool HasNotBuyGift()
|
| | | {
|
| | | OperationBase operationBase;
|
| | | OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashSale, out operationBase);
|
| | | if (operationBase != null && operationBase.InTime(TimeUtility.ServerNow))
|
| | | {
|
| | | OperationFlashSale operation = operationBase as OperationFlashSale;
|
| | | OperationFlashSale.FlashSale flashShop;
|
| | | if (operation.TryGetFlashSale(TimeUtility.ServerNow, out flashShop))
|
| | | {
|
| | | for (int i = 0; i < flashShop.gifts.Length; i++)
|
| | | {
|
| | | var gift = flashShop.gifts[i];
|
| | | var buyInfo = storeModel.GetBuyShopLimit((uint)gift.id);
|
| | | if (buyInfo == null || buyInfo.BuyCnt < gift.limitNum)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public Redpoint flashSaleRedpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20904);
|
| | |
|
| | | public event Action<int> onStateUpate;
|
| | |
|
| | | private void UpdateRedpoint()
|
| | | {
|
| | | flashSaleRedpoint.state = RedPointState.None;
|
| | | if (IsOpen && HasNotBuyGift() && !DayRemind.Instance.GetDayRemind(DayRemind.FLASHSALE_REDPOINT))
|
| | | {
|
| | | flashSaleRedpoint.state = RedPointState.Simple;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|