using System;  
 | 
using System.Collections.Generic;  
 | 
using System.Linq;  
 | 
using System.Text;  
 | 
  
 | 
namespace Snxxz.UI  
 | 
{  
 | 
      
 | 
    public class OpenServerActivityNotifyModel : Model,IBeforePlayerDataInitialize,IPlayerLoginOk  
 | 
    {  
 | 
        public override void Init()  
 | 
        {  
 | 
            
 | 
        }  
 | 
  
 | 
        public void OnBeforePlayerDataInitialize()  
 | 
        {  
 | 
            FlashRushToBuyActivityClose();  
 | 
            TimeMgr.Instance.OnMinuteEvent -= UpdateMinute;  
 | 
            OperationTimeHepler.Instance.operationStartEvent -= OperationStartEvent;  
 | 
            OperationTimeHepler.Instance.operationEndEvent -= OperationEndEvent;  
 | 
            OperationTimeHepler.Instance.operationTimeUpdateEvent -= OperationTimeEvent;  
 | 
            OperationTimeHepler.Instance.operationServerCloseEvent -= OperationServerCloseEvent;  
 | 
            NewBieCenter.Instance.guideCompletedEvent -= GuideCompletedEvent;  
 | 
            WindowCenter.Instance.windowBeforeOpenEvent -= UpdateWindowOpen;  
 | 
        }  
 | 
  
 | 
        public void OnPlayerLoginOk()  
 | 
        {  
 | 
            if (!WindowCenter.Instance.IsOpen<OpenServerActivityNotifyWin>())  
 | 
            {  
 | 
                WindowCenter.Instance.Open<OpenServerActivityNotifyWin>();  
 | 
            }  
 | 
            OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;  
 | 
            OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;  
 | 
            OperationTimeHepler.Instance.operationTimeUpdateEvent += OperationTimeEvent;  
 | 
            OperationTimeHepler.Instance.operationServerCloseEvent += OperationServerCloseEvent;  
 | 
            NewBieCenter.Instance.guideCompletedEvent += GuideCompletedEvent;  
 | 
            TimeMgr.Instance.OnMinuteEvent += UpdateMinute;  
 | 
            WindowCenter.Instance.windowBeforeOpenEvent += UpdateWindowOpen;  
 | 
            SetFlashRushToBuyNotify();  
 | 
        }  
 | 
  
 | 
        public override void UnInit()  
 | 
        {  
 | 
            
 | 
        }  
 | 
  
 | 
        private void UpdateWindowOpen(Window win)  
 | 
        {  
 | 
            if (win.name != "MainInterfaceWin") return;  
 | 
  
 | 
            if (!WindowCenter.Instance.IsOpen<OpenServerActivityNotifyWin>())  
 | 
            {  
 | 
                WindowCenter.Instance.Open<OpenServerActivityNotifyWin>();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        private void UpdateMinute()  
 | 
        {  
 | 
            SetFlashRushToBuyNotify();  
 | 
        }  
 | 
  
 | 
          
 | 
        private void OperationTimeEvent(Operation type)  
 | 
        {  
 | 
            switch (type)  
 | 
            {  
 | 
                case Operation.MultipleExp:  
 | 
                    break;  
 | 
                case Operation.ConsumeRebate:  
 | 
                    break;  
 | 
                case Operation.FlashSale:  
 | 
                    break;  
 | 
                case Operation.BossReborn:  
 | 
                    break;  
 | 
                case Operation.GiftPackage:  
 | 
                    break;  
 | 
                case Operation.FairyCeremony:  
 | 
                    break;  
 | 
                case Operation.MultipRealmPoint:  
 | 
                    break;  
 | 
                case Operation.HolidayFlashRushToBuy:  
 | 
                case Operation.FlashRushToBuy:  
 | 
                case Operation.default12:  
 | 
                    SetFlashRushToBuyNotify();  
 | 
                    break;  
 | 
                case Operation.max:  
 | 
                    break;  
 | 
            }  
 | 
        }  
 | 
  
 | 
          
 | 
        private void OperationStartEvent(Operation type, int state)  
 | 
        {  
 | 
            switch (type)  
 | 
            {  
 | 
                case Operation.MultipleExp:  
 | 
                    break;  
 | 
                case Operation.ConsumeRebate:  
 | 
                    break;  
 | 
                case Operation.FlashSale:  
 | 
                    break;  
 | 
                case Operation.BossReborn:  
 | 
                    break;  
 | 
                case Operation.GiftPackage:  
 | 
                    break;  
 | 
                case Operation.FairyCeremony:  
 | 
                    break;  
 | 
                case Operation.MultipRealmPoint:  
 | 
                    break;  
 | 
                case Operation.HolidayFlashRushToBuy:  
 | 
                case Operation.FlashRushToBuy:  
 | 
                case Operation.default12:  
 | 
                    SetFlashRushToBuyNotify();  
 | 
                    break;  
 | 
                case Operation.max:  
 | 
                    break;  
 | 
            }  
 | 
        }  
 | 
  
 | 
          
 | 
        private void OperationServerCloseEvent(Operation type)  
 | 
        {  
 | 
            switch (type)  
 | 
            {  
 | 
                case Operation.MultipleExp:  
 | 
                    break;  
 | 
                case Operation.ConsumeRebate:  
 | 
                    break;  
 | 
                case Operation.FlashSale:  
 | 
                    break;  
 | 
                case Operation.BossReborn:  
 | 
                    break;  
 | 
                case Operation.GiftPackage:  
 | 
                    break;  
 | 
                case Operation.FairyCeremony:  
 | 
                    break;  
 | 
                case Operation.MultipRealmPoint:  
 | 
                    break;  
 | 
                case Operation.HolidayFlashRushToBuy:  
 | 
                case Operation.FlashRushToBuy:  
 | 
                case Operation.default12:  
 | 
                    FlashRushToBuyActivityClose();  
 | 
                    break;  
 | 
                case Operation.max:  
 | 
                    break;  
 | 
            }  
 | 
        }  
 | 
  
 | 
          
 | 
        private void OperationEndEvent(Operation type, int state)  
 | 
        {  
 | 
            switch (type)  
 | 
            {  
 | 
                case Operation.MultipleExp:  
 | 
                    break;  
 | 
                case Operation.ConsumeRebate:  
 | 
                    break;  
 | 
                case Operation.FlashSale:  
 | 
                    break;  
 | 
                case Operation.BossReborn:  
 | 
                    break;  
 | 
                case Operation.GiftPackage:  
 | 
                    break;  
 | 
                case Operation.FairyCeremony:  
 | 
                    break;  
 | 
                case Operation.MultipRealmPoint:  
 | 
                    break;  
 | 
                case Operation.HolidayFlashRushToBuy:  
 | 
                case Operation.FlashRushToBuy:  
 | 
                case Operation.default12:  
 | 
                    FlashRushToBuyActivityClose();  
 | 
                    break;  
 | 
                case Operation.max:  
 | 
                    break;  
 | 
            }  
 | 
        }  
 | 
  
 | 
        private void GuideCompletedEvent(int id)  
 | 
        {  
 | 
            SetFlashRushToBuyNotify();  
 | 
        }  
 | 
  
 | 
        #region 限时抢购  
 | 
        public event Action UpdateFlashRushToBuyEvent;  
 | 
        FlashRushToBuyModel rushToBuyModel { get { return ModelCenter.Instance.GetModel<FlashRushToBuyModel>(); } }  
 | 
        HolidayFlashRushToBuyModel holidayRushToBuyModel { get { return ModelCenter.Instance.GetModel<HolidayFlashRushToBuyModel>(); } }  
 | 
  
 | 
        public List<OperationFlashRushToBuy.FlashSaleShop> flashSaleShops = new List<OperationFlashRushToBuy.FlashSaleShop>();  
 | 
          
 | 
          
 | 
        public void SetFlashRushToBuyNotify()  
 | 
        {  
 | 
            if (NewBieCenter.Instance.inGuiding) return;  
 | 
  
 | 
            OperationFlashRushToBuy.FlashSaleShop saleShop = null;  
 | 
            bool isPush = rushToBuyModel.CheckIsPush(out saleShop);  
 | 
            bool updateEvent = false;  
 | 
            if(isPush && !flashSaleShops.Contains(saleShop))  
 | 
            {  
 | 
                flashSaleShops.Add(saleShop);  
 | 
                updateEvent = true;  
 | 
            }  
 | 
  
 | 
            OperationFlashRushToBuy.FlashSaleShop saleShop1 = null;  
 | 
            isPush = holidayRushToBuyModel.CheckIsPush(out saleShop1);  
 | 
            if (isPush && !flashSaleShops.Contains(saleShop1))  
 | 
            {  
 | 
                flashSaleShops.Add(saleShop1);  
 | 
                updateEvent = true;  
 | 
            }  
 | 
            int code = ILRuntimeUtility.Instance.ModelInvoke<int>("MergeServerFlashRushToBuyModel", "CheckIsPush");  
 | 
            if (code != 0)  
 | 
            {  
 | 
                bool findNotify = false;  
 | 
                for (int i = 0; i < flashSaleShops.Count; i++)  
 | 
                {  
 | 
                    //用dayIndex 来做特殊识别  
 | 
                    if (flashSaleShops[i].ActNum == 20 && flashSaleShops[i].dayIndex == code)  
 | 
                    {  
 | 
                        findNotify = true;  
 | 
                        break;  
 | 
                    }  
 | 
                }  
 | 
  
 | 
                if (!findNotify)  
 | 
                {  
 | 
                    OperationFlashRushToBuy.FlashSaleShop saleShop2 = new OperationFlashRushToBuy.FlashSaleShop();  
 | 
                    saleShop2.dayIndex = code;  
 | 
                    saleShop2.ActNum = 20;  
 | 
                    flashSaleShops.Add(saleShop2);  
 | 
                    updateEvent = true;  
 | 
                }  
 | 
              
 | 
            }  
 | 
  
 | 
            if (updateEvent)  
 | 
            {  
 | 
                UpdateFlashRushToBuyEvent?.Invoke();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        public void FlashRushToBuyActivityClose()  
 | 
        {  
 | 
            flashSaleShops.Clear();  
 | 
            closeflashSaleShops.Clear();  
 | 
            if (UpdateFlashRushToBuyEvent != null)  
 | 
            {  
 | 
                UpdateFlashRushToBuyEvent();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        public List<OperationFlashRushToBuy.FlashSaleShop> closeflashSaleShops = new List<OperationFlashRushToBuy.FlashSaleShop>();  
 | 
        public void SetCloseFlashRushToBuyList()  
 | 
        {  
 | 
            if(flashSaleShops.Count > 0)  
 | 
            {  
 | 
                closeflashSaleShops.Add(flashSaleShops[flashSaleShops.Count - 1]);  
 | 
            }  
 | 
        }  
 | 
  
 | 
        #endregion  
 | 
  
 | 
    }  
 | 
}  
 |