少年修仙传客户端代码仓库
Client_PangDeRong
2018-10-15 75fad082a71c09da282ae25df7d5ac5fd577c852
System/OpenServerActivity/FlashRushToBuyModel.cs
@@ -25,6 +25,10 @@
        public void OnPlayerLoginOk()
        {
            if(!WindowCenter.Instance.IsOpen<OpenServerActivityNotifyWin>())
            {
                WindowCenter.Instance.Open<OpenServerActivityNotifyWin>();
            }
            //UpdateRedpoint();
        }
@@ -68,7 +72,7 @@
        public void SetDefaultSelectSaleTime()
        {
            OperationFlashRushToBuy operation = GetOperationFlashRushToBuy();
            if (!presentFlashShop.Equals(default(OperationFlashRushToBuy.FlashSaleShop)))
            if (presentFlashShop != null)
            {
                int seconds = 0;
                int buyState = operation.GetBuyTimeState(TimeUtility.ServerNow,presentFlashShop.dayIndex,presentFlashShop.timeIndex, out seconds);
@@ -99,7 +103,7 @@
        public void ResetFlashShop()
        {
            presentFlashShop = default(OperationFlashRushToBuy.FlashSaleShop);
            presentFlashShop = null;
        }
        #region 本地数据处理
@@ -107,7 +111,7 @@
        public event Action UpdateSelectSaleTimeEvent;
        public void UpdateSelectFlashSaleTime(int dayIndex,int timeIndex)
        {
            presentFlashShop = default(OperationFlashRushToBuy.FlashSaleShop);
            presentFlashShop = null;
            OperationFlashRushToBuy operation = GetOperationFlashRushToBuy();
            if(operation != null)
            {
@@ -134,29 +138,55 @@
        #endregion
        #region 协议
        public event Action UpdateAppointmentEvent;
        public event Action UpdateAllAppointmentEvent;
        public event Action<int> UpdateAppointmentEvent;
        public void UpdateFlashSaleAppointmentInfo(HAA18_tagMCFlashSaleAppointmentInfo appointmentInfo)
        {
            var operation = GetOperationFlashRushToBuy();
            if (operation == null) return;
            for(int i = 0; i < appointmentInfo.GoodsCount; i++)
            if (appointmentInfo.IsAll == 1)
            {
               for(int j = 0; j < operation.flashShops.Count; j++)
                for (int j = 0; j < operation.flashShops.Count; j++)
                {
                    var saleItems = operation.flashShops[j].items;
                    for (int k = 0; k < saleItems.Length; k++)
                    {
                       if(saleItems[k].shopGuid == appointmentInfo.GoodsList[i])
                        saleItems[k].isAppointment = 0;
                    }
                }
            }
            for (int i = 0; i < appointmentInfo.GoodsCount; i++)
            {
                var saleItemInfo = appointmentInfo.GoodsList[i];
                for (int j = 0; j < operation.flashShops.Count; j++)
                {
                    var saleItems = operation.flashShops[j].items;
                    for (int k = 0; k < saleItems.Length; k++)
                    {
                       if (saleItems[k].shopGuid == saleItemInfo.GoodsMark)
                        {
                            saleItems[k].isAppointment = 1;
                            if(saleItems[k].isAppointment != saleItemInfo.State)
                            {
                                saleItems[k].isAppointment = saleItemInfo.State;
                                if(UpdateAppointmentEvent != null)
                                {
                                    UpdateAppointmentEvent((int)saleItemInfo.GoodsMark);
                                }
                            }
                        }
                    }
                }
            }
            if(UpdateAppointmentEvent != null)
            if(appointmentInfo.IsAll == 1)
            {
                UpdateAppointmentEvent();
                if (UpdateAllAppointmentEvent != null)
                {
                    UpdateAllAppointmentEvent();
                }
            }
        }
        /// <summary>
        /// Value1  商品ID  Value2 全服购买次数
@@ -189,9 +219,10 @@
        /// </summary>
        /// <param name="seconds"></param>
        /// <returns></returns>
        public FlashRushToBuySate GetActivityState(out int seconds,out OperationTime operationTime)
        public FlashRushToBuySate GetActivityState(out int seconds,out OperationTime operationTime,out OperationFlashRushToBuy.FlashSaleShop saleShop)
        {
            seconds = 0;
            saleShop = null;
            operationTime = default(OperationTime);
            var operation = GetOperationFlashRushToBuy();
            if (!IsOpen || operation == null) return FlashRushToBuySate.NoOpen;
@@ -200,11 +231,19 @@
            int endState = 0;
            int openSeconds = 0;
            int endSeconds = 0;
            for(int i = 0; i < operation.flashShops.Count;i++)
            {
                OperationFlashRushToBuy.FlashSaleShop openSaleShop = operation.flashShops[i];
                operationTime = operation.times[openSaleShop.timeIndex];
                openState = operation.GetBuyTimeState(TimeUtility.ServerNow, openSaleShop.dayIndex, openSaleShop.timeIndex, out openSeconds);
                if(openState != 1)
                {
                    saleShop = openSaleShop;
                    break;
                }
            }
            if(operation.flashShops.Count > 0)
            {
                OperationFlashRushToBuy.FlashSaleShop openSaleShop = operation.flashShops[0];
                operationTime = operation.times[openSaleShop.timeIndex];
                openState = operation.GetBuyTimeState(TimeUtility.ServerNow, openSaleShop.dayIndex, openSaleShop.timeIndex,out openSeconds);
                OperationFlashRushToBuy.FlashSaleShop endSaleShop = operation.flashShops[operation.flashShops.Count - 1];
                endState = operation.GetBuyTimeState(TimeUtility.ServerNow, endSaleShop.dayIndex, endSaleShop.timeIndex, out endSeconds);
            }
@@ -214,6 +253,8 @@
                case -1:
                    seconds = openSeconds;
                    return FlashRushToBuySate.InAdvance;
                case 0:
                    return FlashRushToBuySate.Begining;
            }
            switch(endState)
@@ -229,6 +270,36 @@
            }
        }
        public bool CheckIsPush(out OperationFlashRushToBuy.FlashSaleShop saleShop)
        {
            int seconds = 0;
            OperationTime operationTime;
            saleShop = null;
            var buyState = GetActivityState(out seconds,out operationTime,out saleShop);
            switch (buyState)
            {
                case FlashRushToBuySate.NoOpen:
                    break;
                case FlashRushToBuySate.InAdvance:
                    if(saleShop != null && seconds <= 180)
                    {
                       for(int i = 0; i < saleShop.items.Length; i++)
                        {
                            if(saleShop.items[i].isAppointment == 1)
                            {
                                return true;
                            }
                        }
                    }
                    break;
                case FlashRushToBuySate.Begining:
                    return true;
                case FlashRushToBuySate.End:
                    break;
            }
            return false;
        }
        private void OperationEndEvent(Operation type, int state)
        {
            if (type == Operation.FlashRushToBuy && state == 0)