| | |
| | | [SerializeField] ScrollerController saleItemCtrl;
|
| | | [SerializeField] ScrollerController saleTimeCtrl;
|
| | | [SerializeField] Text opreationTimeText;
|
| | | [SerializeField] Image moneyIcon;
|
| | | [SerializeField] Text moneyNumText;
|
| | |
|
| | | StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
| | | FlashSaleModel model { get { return ModelCenter.Instance.GetModel<FlashSaleModel>(); } }
|
| | |
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | |
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | |
|
| | | GlobalTimeEvent.Instance.secondEvent += SecondEvent;
|
| | | TimeMgr.Instance.OnDayEvent += OnDayEvent;
|
| | | OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;
|
| | | storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
|
| | | OperationTimeHepler.Instance.operationTimeUpdateEvent += OperationTimeUpdateEvent;
|
| | | CreateOperationTimes();
|
| | | Display();
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | |
| | | model.SetDayRemind();
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | |
| | | GlobalTimeEvent.Instance.secondEvent -= SecondEvent;
|
| | | TimeMgr.Instance.OnDayEvent -= OnDayEvent;
|
| | | OperationTimeHepler.Instance.operationStartEvent -= OperationStartEvent;
|
| | | storeModel.RefreshBuyShopLimitEvent -= RefreshBuyShopLimitEvent;
|
| | | OperationTimeHepler.Instance.operationTimeUpdateEvent -= OperationTimeUpdateEvent;
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | | #endregion
|
| | |
|
| | | private void CreateOperationTimes()
|
| | | {
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashRushToBuy, out operationBase))
|
| | | {
|
| | | OperationFlashRushToBuy operation = operationBase as OperationFlashRushToBuy;
|
| | | saleTimeCtrl.Refresh();
|
| | | for(int i = 0; i < operation.times.Count; i++)
|
| | | {
|
| | | saleTimeCtrl.AddCell(ScrollerDataType.Header,i,CreateSaleItem);
|
| | | }
|
| | | saleTimeCtrl.Restart();
|
| | | }
|
| | | }
|
| | |
|
| | | public void CreateSaleItem(CellView cellView)
|
| | | {
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashRushToBuy, out operationBase))
|
| | | {
|
| | | OperationFlashRushToBuy operation = operationBase as OperationFlashRushToBuy;
|
| | | OperationFlashRushToBuy.FlashSale flashSale;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OperationTimeUpdateEvent(Operation type)
|
| | | {
|
| | | if (type == Operation.FlashSale)
|
| | | {
|
| | | Display();
|
| | | }
|
| | | }
|
| | | private void RefreshBuyShopLimitEvent()
|
| | | {
|
| | | Display();
|
| | | }
|
| | |
|
| | | private void Display()
|
| | | {
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashRushToBuy, out operationBase))
|
| | | {
|
| | | OperationFlashRushToBuy operation = operationBase as OperationFlashRushToBuy;
|
| | | opreationTimeText.text = StringUtility.Contact(Language.Get("ExpActivity_Text1"), operation.ToDisplayTime());
|
| | | OperationFlashRushToBuy.FlashSale flashSale;
|
| | | if (operation.TryGetFlashSale(TimeUtility.ServerNow, out flashSale))
|
| | | {
|
| | | if (flashSale.gifts.Length > 0)
|
| | | {
|
| | | var moneyType = flashSale.gifts[0].moneyType;
|
| | | moneyIcon.SetIconWithMoneyType(moneyType);
|
| | | moneyNumText.text = UIHelper.GetMoneyCnt(moneyType).ToString();
|
| | | }
|
| | | }
|
| | | }
|
| | | GetSurplusTime();
|
| | | }
|
| | |
|
| | | private void OperationStartEvent(Operation type, int state)
|
| | | {
|
| | | if (type == Operation.FlashRushToBuy && state == 0)
|
| | | {
|
| | | Display();
|
| | | }
|
| | | }
|
| | |
|
| | | private void SecondEvent()
|
| | | {
|
| | | GetSurplusTime();
|
| | | }
|
| | |
|
| | | private void OnDayEvent()
|
| | | {
|
| | | Display();
|
| | | }
|
| | |
|
| | | private string GetSurplusTime()
|
| | | {
|
| | | OperationBase operationBase;
|
| | | OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashRushToBuy, out operationBase);
|
| | | var seconds = 0;
|
| | | var inAdvance = false;
|
| | | if (operationBase != null)
|
| | | {
|
| | | if (operationBase.InAdvanceTime(TimeUtility.ServerNow))
|
| | | {
|
| | | inAdvance = true;
|
| | | seconds = operationBase.GetSecondsBeforeStart(TimeUtility.ServerNow);
|
| | | }
|
| | | else
|
| | | {
|
| | | OperationFlashRushToBuy operation = operationBase as OperationFlashRushToBuy;
|
| | | seconds = operation.GetResetSurplusTime();
|
| | | }
|
| | | }
|
| | | if (seconds > 0)
|
| | | {
|
| | | if (inAdvance)
|
| | | {
|
| | | return Language.Get("OperationAdvanceOpen", TimeUtility.SecondsToDHMSCHS(seconds));
|
| | | }
|
| | | else
|
| | | {
|
| | | return Language.Get("LimitGift1", TimeUtility.SecondsToDHMSCHS(seconds));
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | return Language.Get("ActivityEnd");
|
| | | }
|
| | | }
|
| | |
|
| | | }
|