| | |
| | | public event Action<Operation> operationServerCloseEvent;//特殊情况下触发
|
| | | public event Action<Operation, int> operationEndEvent;//活动结束时间触发 第二个参数0--过活动时间触发 1--过活动天触发
|
| | | public event Action<Operation, int> operationStartEvent;//活动开始时间并且满足开启条件触发 第二个参数0--活动时间触发 1--活动天触发
|
| | | public event Action<Operation> operationAdvanceEvent;//活动提前开放事件
|
| | | public event Action<int> dayResetEvent;//活动重置事件0-0点 1-5点
|
| | | public event Action<Operation> operationAdvanceEvent;//活动在提前开启的时间内
|
| | | public OperationTimeHepler()
|
| | | {
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitializeEvent;
|
| | | GlobalTimeEvent.Instance.secondEvent += SecondEvent;
|
| | | TimeMgr.Instance.OnHourEvent += HourEvent;
|
| | | }
|
| | |
|
| | | private void BeforePlayerDataInitializeEvent()
|
| | |
| | | if (operationDict.ContainsKey((Operation)i))
|
| | | {
|
| | | var operation = operationDict[(Operation)i];
|
| | | if (operation.InDay(TimeUtility.ServerNow) && operation.SatisfyOpenCondition()
|
| | | && !operation.inDateNotify)
|
| | | if (!operation.inDateNotify && operation.SatisfyOpenCondition()
|
| | | && operation.InDay(TimeUtility.ServerNow))
|
| | | {
|
| | | operation.inDateNotify = true;
|
| | | operation.stepDateNotify = false;
|
| | |
| | | operationStartEvent((Operation)i, 1);
|
| | | }
|
| | | }
|
| | | else if (!operation.InDay(TimeUtility.ServerNow) && !operation.stepDateNotify)
|
| | | else if (!operation.stepDateNotify && !operation.InDay(TimeUtility.ServerNow))
|
| | | {
|
| | | operation.inDateNotify = false;
|
| | | operation.stepDateNotify = true;
|
| | |
| | | operationEndEvent((Operation)i, 1);
|
| | | }
|
| | | }
|
| | | if (operation.InTime(TimeUtility.ServerNow) && operation.SatisfyOpenCondition()
|
| | | && !operation.inTimeNotify)
|
| | | if (!operation.inTimeNotify && operation.SatisfyOpenCondition()
|
| | | && operation.InTime(TimeUtility.ServerNow))
|
| | | {
|
| | | operation.inTimeNotify = true;
|
| | | operation.stepTimeNotify = false;
|
| | | operation.inAdvanceNotify = false;
|
| | | DebugEx.LogFormat("{0} 活动时间开始", (Operation)i);
|
| | | if (operationStartEvent != null)
|
| | | {
|
| | | operationStartEvent((Operation)i, 0);
|
| | | }
|
| | | }
|
| | | else if (!operation.InTime(TimeUtility.ServerNow) && !operation.stepTimeNotify)
|
| | | else if (!operation.stepTimeNotify && !operation.InTime(TimeUtility.ServerNow))
|
| | | {
|
| | | operation.inTimeNotify = false;
|
| | | operation.stepTimeNotify = true;
|
| | | operation.inAdvanceNotify = false;
|
| | | DebugEx.LogFormat("{0} 活动时间结束", (Operation)i);
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | if (!operation.inAdvanceNotify && operation.InAdvanceTime(TimeUtility.ServerNow))
|
| | | if (!operation.inAdvanceNotify && operation.SatisfyOpenCondition()
|
| | | && operation.InAdvanceTime(TimeUtility.ServerNow))
|
| | | {
|
| | | operation.inAdvanceNotify = true;
|
| | | DebugEx.LogFormat("{0} 活动提前开启", (Operation)i);
|
| | | if (operationAdvanceEvent != null)
|
| | | {
|
| | | operationAdvanceEvent((Operation)i);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void HourEvent()
|
| | | {
|
| | | if (!(StageManager.Instance.CurrentStage is DungeonStage))
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (TimeUtility.Hour == 0 && dayResetEvent != null)
|
| | | {
|
| | | dayResetEvent(0);
|
| | | }
|
| | | if (TimeUtility.Hour == 5 && dayResetEvent != null)
|
| | | {
|
| | | dayResetEvent(1);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | OperationBase operation = null;
|
| | | operationDict.TryGetValue(Operation.MultipleExp, out operation);
|
| | | if (package.StartDate == null || package.StartDate.Equals(string.Empty)
|
| | | || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.MultipleExp))
|
| | | {
|
| | | operationDict.Remove(Operation.MultipleExp);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.MultipleExp);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.MultipleExp, 0);
|
| | | operationEndEvent(Operation.MultipleExp, 1);
|
| | | }
|
| | | ForceStopOperation(Operation.MultipleExp);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | operation.endDate = ParseOperationDate(package.EndtDate);
|
| | | operation.limitLv = package.LimitLV;
|
| | | (operation as OperationMultiExp).multiple = (int)package.AddExpRate + 10000;
|
| | | if (package.ActivityTimeCount == 0)
|
| | | for (int i = 0; i < package.ActivityTimeCount; i++)
|
| | | {
|
| | | operation.allDay = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < package.ActivityTimeCount; i++)
|
| | | {
|
| | | operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
|
| | | package.ActivityTime[i].EndtTime));
|
| | | }
|
| | | operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
|
| | | package.ActivityTime[i].EndtTime));
|
| | | }
|
| | | if (operationTimeUpdateEvent != null)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 消费返利
|
| | | /// </summary>
|
| | |
| | | {
|
| | | OperationBase operationBase = null;
|
| | | operationDict.TryGetValue(Operation.ConsumeRebate, out operationBase);
|
| | | if (package.StartDate == null || package.StartDate.Equals(string.Empty)
|
| | | || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.ConsumeRebate))
|
| | | {
|
| | | operationDict.Remove(Operation.ConsumeRebate);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.ConsumeRebate);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.ConsumeRebate, 0);
|
| | | operationEndEvent(Operation.ConsumeRebate, 1);
|
| | | }
|
| | | ForceStopOperation(Operation.ConsumeRebate);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | operation.limitLv = package.LimitLV;
|
| | | operation.startDate = ParseOperationDate(package.StartDate);
|
| | | operation.endDate = ParseOperationDate(package.EndtDate);
|
| | | operation.allDay = true;
|
| | | operation.dayReset = package.IsDayReset == 1;
|
| | | for (int i = 0; i < package.AwardDays; i++)
|
| | | {
|
| | | var _rebate = package.AwardDayInfo[i];
|
| | | OperationConsumeRebate.Rebate rebate = new OperationConsumeRebate.Rebate();
|
| | | for (int k = 0; k < _rebate.AwardCount; k++)
|
| | | {
|
| | | OperationConsumeRebate.RebateGrade rebateGrade = new OperationConsumeRebate.RebateGrade();
|
| | | rebateGrade.needGold = (int)_rebate.AwardInfo[k].NeedGold;
|
| | | rebateGrade.index = _rebate.AwardInfo[k].AwardIndex;
|
| | | for (int q = 0; q < _rebate.AwardInfo[k].AwardItemCount; q++)
|
| | | {
|
| | | var _item = _rebate.AwardInfo[k].AwardItem[q];
|
| | | rebateGrade.items.Add(new OperationConsumeRebate.Item()
|
| | | {
|
| | | itemId = (int)_item.ItemID,
|
| | | count = _item.ItemCount,
|
| | | isBind = _item.IsBind,
|
| | | });
|
| | | }
|
| | | rebate.rebateGrades.Add(rebateGrade);
|
| | | }
|
| | | operation.rebates.Add(rebate);
|
| | | }
|
| | | operation.ParseRebate(package);
|
| | | if (operationTimeUpdateEvent != null)
|
| | | {
|
| | | operationTimeUpdateEvent(Operation.ConsumeRebate);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 限时特惠
|
| | | /// </summary>
|
| | |
| | | operationDict.TryGetValue(Operation.FlashSale, out operationBase);
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.FlashSale))
|
| | | {
|
| | | operationDict.Remove(Operation.FlashSale);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.FlashSale);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.FlashSale, 0);
|
| | | operationEndEvent(Operation.FlashSale, 1);
|
| | | }
|
| | | ForceStopOperation(Operation.FlashSale);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | operation.limitLv = package.LimitLV;
|
| | | operation.startDate = ParseOperationDate(package.StartDate);
|
| | | operation.endDate = ParseOperationDate(package.EndtDate);
|
| | | operation.dateEnumerator = new OperationDateEnumerator(operation.startDate, operation.endDate);
|
| | | operation.dayReset = package.IsDayReset == 1;
|
| | | if (package.ActivityTimeCount == 0)
|
| | | operation.inAdvanceMinute = package.AdvanceMinutes;
|
| | | for (int i = 0; i < package.ActivityTimeCount; i++)
|
| | | {
|
| | | operation.allDay = true;
|
| | | operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
|
| | | package.ActivityTime[i].EndtTime));
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < package.ActivityTimeCount; i++)
|
| | | {
|
| | | operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
|
| | | package.ActivityTime[i].EndtTime));
|
| | | }
|
| | | }
|
| | |
|
| | | for (int i = 0; i < package.ShopCount; i++)
|
| | | {
|
| | | var flashShop = new OperationFlashSale.FlashSale();
|
| | | var shop = package.ShopInfo[i];
|
| | | flashShop.gifts = new OperationFlashSale.FlashSaleGift[shop.GiftbagCount];
|
| | | for (int k = 0; k < shop.GiftbagCount; k++)
|
| | | {
|
| | | var gift = new OperationFlashSale.FlashSaleGift();
|
| | | var pakGift = shop.GiftbagInfo[k];
|
| | | gift.id = (int)pakGift.GiftID;
|
| | | gift.limitNum = pakGift.BuyCountLimit;
|
| | | gift.moneyNumber = (int)pakGift.MoneyNumber;
|
| | | gift.moneyType = pakGift.MoneyType;
|
| | | gift.moneyOriginal = (int)pakGift.MoneyOriginal;
|
| | | gift.items = new OperationFlashSale.FlashSaleItem[pakGift.GiftItemCount];
|
| | | for (int q = 0; q < pakGift.GiftItemCount; q++)
|
| | | {
|
| | | var item = new OperationFlashSale.FlashSaleItem();
|
| | | item.itemId = (int)pakGift.ItemInfo[q].ItemID;
|
| | | item.isBind = pakGift.ItemInfo[q].IsBind;
|
| | | item.itemCount = pakGift.ItemInfo[q].ItemCount;
|
| | | item.isMainItem = pakGift.ItemInfo[q].IsMainItem == 1;
|
| | | gift.items[q] = item;
|
| | | }
|
| | | flashShop.gifts[k] = gift;
|
| | | }
|
| | | operation.flashShops.Add(flashShop);
|
| | | }
|
| | | operation.ParsePackage(package);
|
| | | if (operationTimeUpdateEvent != null)
|
| | | {
|
| | | operationTimeUpdateEvent(Operation.FlashSale);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 限时礼包
|
| | | /// </summary>
|
| | | /// <param name="package"></param>
|
| | | /// |
| | | public void UpdateGiftPackage(HAA12_tagMCFlashGiftbagInfo package)
|
| | | {
|
| | | OperationBase operationBase = null;
|
| | | operationDict.TryGetValue(Operation.GiftPackage, out operationBase);
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.GiftPackage))
|
| | | {
|
| | | operationDict.Remove(Operation.GiftPackage);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.GiftPackage);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.GiftPackage, 0);
|
| | | operationEndEvent(Operation.GiftPackage, 1);
|
| | | }
|
| | |
|
| | | ForceStopOperation(Operation.GiftPackage);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | operation.startDate = ParseOperationDate(package.StartDate);
|
| | | operation.endDate = ParseOperationDate(package.EndtDate);
|
| | | operation.dayReset = package.IsDayReset == 1;
|
| | | if (package.ActivityTimeCount == 0)
|
| | | operation.inAdvanceMinute = package.AdvanceMinutes;
|
| | | for (int i = 0; i < package.ActivityTimeCount; i++)
|
| | | {
|
| | | operation.allDay = true;
|
| | | operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
|
| | | package.ActivityTime[i].EndtTime));
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < package.ActivityTimeCount; i++)
|
| | | {
|
| | | operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime,
|
| | | package.ActivityTime[i].EndtTime));
|
| | | }
|
| | | }
|
| | | for (int i = 0; i < package.GiftbagTypeCount; i++)
|
| | | {
|
| | | var GiftbagType = new GiftPackageClass.Gift_Package();
|
| | | var Giftbag = package.GiftbagTypeInfo[i];
|
| | | GiftbagType.gifts = new GiftPackageClass.GiftPackageGift[Giftbag.GiftbagCount];
|
| | | for (int k = 0; k < Giftbag.GiftbagCount; k++)
|
| | | {
|
| | | var gift = new GiftPackageClass.GiftPackageGift();
|
| | | var pakGift = Giftbag.GiftbagInfo[k];
|
| | | gift.id = (int)pakGift.GiftID;
|
| | | gift.limitNum = pakGift.BuyCountLimit;
|
| | | gift.rmb = (int)pakGift.RMB;
|
| | | gift.rmbOriginal = (int)pakGift.RMBOriginal;
|
| | | gift.OrderInfo = pakGift.OrderInfo;
|
| | | gift.OrderInfoLength = pakGift.OrderInfoLen;
|
| | | gift.items = new GiftPackageClass.GiftPackageItem[pakGift.GiftItemCount];
|
| | |
|
| | | for (int q = 0; q < pakGift.GiftItemCount; q++)
|
| | | {
|
| | | var item = new GiftPackageClass.GiftPackageItem();
|
| | | item.itemId = (int)pakGift.ItemInfo[q].ItemID;
|
| | | item.isBind = pakGift.ItemInfo[q].IsBind;
|
| | | item.itemCount = pakGift.ItemInfo[q].ItemCount;
|
| | | item.isMainItem = pakGift.ItemInfo[q].IsMainItem == 1;
|
| | | gift.items[q] = item;
|
| | | }
|
| | | GiftbagType.gifts[k] = gift;
|
| | | }
|
| | | operation.giftpackage1.Add(GiftbagType);
|
| | | }
|
| | | operation.ParsePackage(package);
|
| | | if (operationTimeUpdateEvent != null)
|
| | | {
|
| | | operationTimeUpdateEvent(Operation.GiftPackage);
|
| | |
| | | {
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.BossReborn))
|
| | | {
|
| | | operationDict.Remove(Operation.BossReborn);
|
| | | }
|
| | |
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.BossReborn);
|
| | | }
|
| | |
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.BossReborn, 0);
|
| | | operationEndEvent(Operation.BossReborn, 1);
|
| | | }
|
| | | ForceStopOperation(Operation.BossReborn);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | |
|
| | | operationBase.Reset();
|
| | | operationBase.limitLv = package.LimitLV;
|
| | | operationBase.allDay = true;
|
| | | operationBase.startDate = ParseOperationDate(package.StartDate);
|
| | | operationBase.endDate = ParseOperationDate(package.EndtDate);
|
| | |
|
| | | operationBase.resetType = package.ResetType;
|
| | | ModelCenter.Instance.GetModel<BossRebornModel>().UpdateTaskBaseInfos(package.TaskInfo);
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | OperationBase operation = null;
|
| | | operationDict.TryGetValue(Operation.FairyCeremony, out operation);
|
| | | if (package.StartDate == null || package.StartDate.Equals(string.Empty)
|
| | | || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.FairyCeremony))
|
| | | {
|
| | | operationDict.Remove(Operation.FairyCeremony);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.FairyCeremony);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.FairyCeremony, 0);
|
| | | operationEndEvent(Operation.FairyCeremony, 1);
|
| | | }
|
| | | ForceStopOperation(Operation.FairyCeremony);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | operation.startDate = ParseOperationDate(package.StartDate);
|
| | | operation.endDate = ParseOperationDate(package.EndtDate);
|
| | | operation.limitLv = package.LimitLV;
|
| | | operation.allDay = true;
|
| | | if (operationTimeUpdateEvent != null)
|
| | | {
|
| | | operationTimeUpdateEvent(Operation.FairyCeremony);
|
| | |
| | | {
|
| | | OperationBase operation = null;
|
| | | operationDict.TryGetValue(Operation.MultipRealmPoint, out operation);
|
| | | if (package.StartDate == null || package.StartDate.Equals(string.Empty)
|
| | | || package.EndtDate == null || package.EndtDate.Equals(string.Empty))
|
| | | if (string.IsNullOrEmpty(package.StartDate) || string.IsNullOrEmpty(package.EndtDate))
|
| | | {
|
| | | if (operationDict.ContainsKey(Operation.MultipRealmPoint))
|
| | | {
|
| | | operationDict.Remove(Operation.MultipRealmPoint);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(Operation.MultipRealmPoint);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(Operation.MultipRealmPoint, 0);
|
| | | operationEndEvent(Operation.MultipRealmPoint, 1);
|
| | | }
|
| | | ForceStopOperation(Operation.MultipRealmPoint);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | operation.startDate = ParseOperationDate(package.StartDate);
|
| | | operation.endDate = ParseOperationDate(package.EndtDate);
|
| | | operation.limitLv = package.LimitLV;
|
| | | operation.allDay = true;
|
| | | (operation as OperationMultipleRealmPoint).multiplePractice = package.Multiple;
|
| | | if (operationTimeUpdateEvent != null)
|
| | | {
|
| | | operationTimeUpdateEvent(Operation.MultipRealmPoint);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | void ForceStopOperation(Operation operationType)
|
| | | {
|
| | | if (operationDict.ContainsKey(operationType))
|
| | | {
|
| | | operationDict.Remove(operationType);
|
| | | }
|
| | | if (operationServerCloseEvent != null)
|
| | | {
|
| | | operationServerCloseEvent(operationType);
|
| | | }
|
| | | if (operationEndEvent != null)
|
| | | {
|
| | | operationEndEvent(operationType, 0);
|
| | | operationEndEvent(operationType, 1);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | public bool SideOfTime(Operation type, out int side)
|
| | | {
|
| | | side = 0;
|
| | | OperationBase operation;
|
| | | if (TryGetOperationTime(type, out operation))
|
| | | {
|
| | | return operation.SideOfTime(TimeUtility.ServerNow, out side);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public int GetOperationSurplusTime(Operation type)
|
| | | {
|
| | | OperationBase operation;
|
| | |
| | | return 0;
|
| | | }
|
| | |
|
| | | public bool InOperationAdvance(Operation type)
|
| | | {
|
| | | OperationBase operation;
|
| | | if (TryGetOperationTime(type, out operation))
|
| | | {
|
| | | return operation.InAdvanceTime(TimeUtility.ServerNow);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public int GetOperationSecondsBeforeStart(Operation type)
|
| | | {
|
| | | OperationBase operation;
|
| | | if (TryGetOperationTime(type, out operation))
|
| | | {
|
| | | return operation.GetSecondsBeforeStart(TimeUtility.ServerNow);
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | public bool SatisfyOpenCondition(Operation type)
|
| | | {
|
| | | OperationBase operation;
|
| | | if (TryGetOperationTime(type, out operation))
|
| | | {
|
| | | return operation.SatisfyOpenCondition() && InOperationTime(type);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool SatisfyAdvanceCondition(Operation type)
|
| | | {
|
| | | OperationBase operation;
|
| | | if (TryGetOperationTime(type, out operation))
|
| | | {
|
| | | return operation.SatisfyOpenCondition() && InOperationAdvance(type);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public int IndexOfOperationDays(Operation type)
|
| | | {
|
| | | OperationBase operation;
|
| | | if (TryGetOperationTime(type, out operation))
|
| | | {
|
| | | return operation.IndexOfOpenDay(TimeUtility.ServerNow);
|
| | | }
|
| | | return -1;
|
| | | }
|
| | |
|
| | | OperationDate ParseOperationDate(string date)
|
| | | {
|
| | | string[] dateArray = date.Split('-');
|
| | |
| | | year = int.Parse(dateArray[0].Trim()),
|
| | | month = int.Parse(dateArray[1].Trim()),
|
| | | day = int.Parse(dateArray[2].Trim())
|
| | | };
|
| | | }
|
| | | else if (dateArray != null && dateArray.Length == 1)
|
| | | {
|
| | | var time = TimeUtility.openServerTime;
|
| | | if (time.Equals(default(DateTime)))
|
| | | {
|
| | | DebugEx.Log("服务期开服时间下发顺序有问题");
|
| | | }
|
| | | var days = 0;
|
| | | int.TryParse(date, out days);
|
| | | days = Mathf.Max(1, days);
|
| | | time = time.AddDays(days - 1);
|
| | | return new OperationDate()
|
| | | {
|
| | | year = time.Year,
|
| | | month = time.Month,
|
| | | day = time.Day,
|
| | | };
|
| | | }
|
| | | return default(OperationDate);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public class OperationDateEnumerator : IEnumerable, IEnumerator
|
| | | {
|
| | | OperationDate start;
|
| | | OperationDate end;
|
| | |
|
| | | public int index = -1;
|
| | |
|
| | | public OperationDateEnumerator(OperationDate _start,OperationDate _end)
|
| | | {
|
| | | this.start = _start;
|
| | | this.end = _end;
|
| | | }
|
| | |
|
| | | public object Current
|
| | | {
|
| | | get
|
| | | {
|
| | | var date = start;
|
| | | date.day += index;
|
| | | return date;
|
| | | }
|
| | | }
|
| | |
|
| | | public IEnumerator GetEnumerator()
|
| | | {
|
| | | return (IEnumerator)this;
|
| | | }
|
| | |
|
| | | public bool MoveNext()
|
| | | {
|
| | | index++;
|
| | | bool isIn = index <= (start - end);
|
| | | if (!isIn)
|
| | | {
|
| | | GetEnumerator().Reset();
|
| | | }
|
| | | return isIn;
|
| | | }
|
| | |
|
| | | public void Reset()
|
| | | {
|
| | | index = -1;
|
| | | }
|
| | | }
|
| | |
|
| | | public struct OperationDate
|
| | | {
|
| | | public int year;
|
| | |
| | | return !(x == y);
|
| | | }
|
| | |
|
| | | public static bool operator >(OperationDate x, OperationDate y)
|
| | | {
|
| | | if (x.year > y.year)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | if (x.year == y.year)
|
| | | {
|
| | | if (x.month > y.month)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | if (x.month == y.month)
|
| | | {
|
| | | return x.day > y.day;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public static bool operator <(OperationDate x, OperationDate y)
|
| | | {
|
| | | return !(x > y) && x != y;
|
| | | }
|
| | |
|
| | | public static bool operator >=(OperationDate x, OperationDate y)
|
| | | {
|
| | | return x > y || x == y;
|
| | | }
|
| | |
|
| | | public static bool operator <=(OperationDate x, OperationDate y)
|
| | | {
|
| | | return x < y || x == y;
|
| | | }
|
| | |
|
| | | public DateTime AddSeconds(int _seconds)
|
| | | {
|
| | | DateTime d = new DateTime(year, month, day);
|
| | | return d.AddTicks(_seconds * TimeSpan.TicksPerSecond);
|
| | | }
|
| | |
|
| | | public OperationDate AddDays(int _days)
|
| | | {
|
| | | DateTime d = new DateTime(year, month, day);
|
| | | d = d.AddDays(_days);
|
| | | return new OperationDate()
|
| | | {
|
| | | year = d.Year,
|
| | | month = d.Month,
|
| | | day = d.Day,
|
| | | };
|
| | | }
|
| | |
|
| | | public string ToDisplay(bool showYear = true)
|
| | |
| | |
|
| | | public bool InTime(DateTime time)
|
| | | {
|
| | | if (time.Hour < startHour || (time.Hour == startHour && time.Minute < startMinute))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (time.Hour > endHour || (time.Hour == endHour && time.Minute >= endMinute))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | return CompareTime(time) == 0;
|
| | | }
|
| | |
|
| | | public int SideOfTime(DateTime time)
|
| | | public int CompareTime(DateTime time)
|
| | | {
|
| | | if (time.Hour < startHour || (time.Hour == startHour && time.Minute < startMinute))
|
| | | {
|
| | |
| | | {
|
| | | DateTime d = new DateTime(y.Year, y.Month, y.Day, x.endHour, x.endMinute, 0);
|
| | | return Mathf.Max(0, (int)(d - y).TotalSeconds);
|
| | | }
|
| | | }
|
| | |
|
| | | public class OperationBase
|
| | | {
|
| | | public OperationDate startDate;
|
| | | public OperationDate endDate;
|
| | | public List<OperationTime> times = new List<OperationTime>();
|
| | | public OperationDateEnumerator dateEnumerator;
|
| | |
|
| | | public bool allDay = false;
|
| | |
|
| | | public bool stepTimeNotify = false;
|
| | | public bool stepDateNotify = false;
|
| | |
|
| | | public bool inTimeNotify = false;
|
| | | public bool inDateNotify = false;
|
| | |
|
| | | public bool inAdvanceNotify = false;
|
| | |
|
| | | public int inAdvanceSeconds = 0;
|
| | |
|
| | | public int limitLv;
|
| | |
|
| | | public bool InTime(DateTime time)
|
| | | {
|
| | | if (!InDay(time))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (allDay)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | for (int i = 0; i < times.Count; i++)
|
| | | {
|
| | | if (times[i].InTime(time))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool SideOfTime(DateTime time, out int side)
|
| | | {
|
| | | side = 0;
|
| | | if (!InDay(time))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (allDay)
|
| | | {
|
| | | side = 0;
|
| | | return true;
|
| | | }
|
| | | for (int i = 0; i < times.Count; i++)
|
| | | {
|
| | | side = times[i].SideOfTime(time);
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | public bool InDay(DateTime time)
|
| | | {
|
| | | if (time.Year != startDate.year && time.Year != endDate.year)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (startDate.year != endDate.year)
|
| | | {
|
| | | if (time.Year == startDate.year)
|
| | | {
|
| | | if (time.Month < startDate.month)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == startDate.month && time.Day < startDate.day)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | else if (time.Year == endDate.year)
|
| | | {
|
| | | if (time.Month > endDate.month)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == endDate.month && time.Day > endDate.day)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (time.Month < startDate.month || (time.Month == startDate.month && time.Day < startDate.day))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (time.Month > endDate.month || (time.Month == endDate.month && time.Day > endDate.day))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | public int IndexOfOpenDay(DateTime time)
|
| | | {
|
| | | if (!InDay(time))
|
| | | {
|
| | | return -1;
|
| | | }
|
| | | DateTime s = new DateTime(startDate.year, startDate.month, startDate.day);
|
| | | return (time - s).Days;
|
| | | }
|
| | |
|
| | | public int IndexOfOpenTime(DateTime time)
|
| | | {
|
| | | if (!InTime(time))
|
| | | {
|
| | | return -1;
|
| | | }
|
| | | if (allDay)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | for (int i = 0; i < times.Count; i++)
|
| | | {
|
| | | if (times[i].InTime(time))
|
| | | {
|
| | | return i;
|
| | | }
|
| | | }
|
| | | return -1;
|
| | | }
|
| | |
|
| | | public bool InAdvanceTime(DateTime time)
|
| | | {
|
| | | if (InTime(time) || inAdvanceSeconds <= 0)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | var seconds = 0;
|
| | | if (TryGetInAdvanceSurplusSecond(time, out seconds))
|
| | | {
|
| | | return seconds < inAdvanceSeconds;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool TryGetInAdvanceSurplusSecond(DateTime time, out int seconds)
|
| | | {
|
| | | seconds = 0;
|
| | | if (InTime(time))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (allDay)
|
| | | {
|
| | | var startTime = new DateTime(startDate.year, startDate.month, startDate.day);
|
| | | seconds = (int)(startTime - time).TotalSeconds;
|
| | | }
|
| | | else
|
| | | {
|
| | | if (dateEnumerator != null)
|
| | | {
|
| | | foreach (OperationDate date in dateEnumerator)
|
| | | {
|
| | | for (int i = 0; i < times.Count; i++)
|
| | | {
|
| | | var startTime = new DateTime(date.year, date.month, date.day, times[i].startHour, times[i].startMinute, 0);
|
| | | seconds = (int)(startTime - time).TotalSeconds;
|
| | | if (seconds > 0)
|
| | | {
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (seconds > 0)
|
| | | {
|
| | | dateEnumerator.Reset();
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return seconds > 0;
|
| | | }
|
| | |
|
| | | public int GetSurplusTime(DateTime time)
|
| | | {
|
| | | var seconds = 0;
|
| | | if (InTime(time))
|
| | | {
|
| | | if (allDay)
|
| | | {
|
| | | seconds += (int)(endDate.AddSeconds(24 * 60 * 60) - time).TotalSeconds;
|
| | | }
|
| | | else
|
| | | {
|
| | | for (int i = 0; i < times.Count; i++)
|
| | | {
|
| | | if (times[i].InTime(time))
|
| | | {
|
| | | seconds += times[i] - time;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return seconds;
|
| | | }
|
| | | public virtual string ToDisplayTime()
|
| | | {
|
| | | return string.Empty;
|
| | | }
|
| | |
|
| | | public virtual void Reset()
|
| | | {
|
| | | stepTimeNotify = false;
|
| | | stepDateNotify = false;
|
| | | inTimeNotify = false;
|
| | | inDateNotify = false;
|
| | | inAdvanceNotify = false;
|
| | | allDay = false;
|
| | | inAdvanceSeconds = 0;
|
| | | limitLv = 0;
|
| | | times.Clear();
|
| | | }
|
| | |
|
| | | public virtual bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | | }
|
| | |
|
| | | public class OperationMultiExp : OperationBase
|
| | | {
|
| | | public int multiple;
|
| | |
|
| | | public override string ToDisplayTime()
|
| | | {
|
| | | var textBuilder = OperationTimeHepler.textBuilder;
|
| | | textBuilder.Length = 0;
|
| | | if (allDay)
|
| | | {
|
| | | textBuilder.Append(Language.Get("OpenAllDay"));
|
| | | }
|
| | | else
|
| | | {
|
| | | if (startDate != endDate)
|
| | | {
|
| | | textBuilder.Append(Language.Get("EveryDay"));
|
| | | }
|
| | | for (int i = 0, n = times.Count; i < n; i++)
|
| | | {
|
| | | textBuilder.Append(times[i].ToString());
|
| | | if (i < n - 1)
|
| | | {
|
| | | textBuilder.Append("、");
|
| | | }
|
| | | }
|
| | | }
|
| | | return textBuilder.ToString();
|
| | | }
|
| | |
|
| | | public override bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | |
|
| | | public string GetMultipleCHS()
|
| | | {
|
| | | if (multiple / 10000 == 2)
|
| | | {
|
| | | return Language.Get("Num_CHS_Double");
|
| | | }
|
| | | else
|
| | | {
|
| | | return Language.Get(StringUtility.Contact("Num_CHS_", multiple / 10000));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public class OperationFlashSale : OperationBase
|
| | | {
|
| | | public bool dayReset = false;
|
| | |
|
| | | public List<FlashSale> flashShops = new List<FlashSale>();
|
| | |
|
| | | public int IndexOfFlashShop()
|
| | | {
|
| | | if (flashShops.Count == 1)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow);
|
| | | if (_timeIndex == -1)
|
| | | {
|
| | | return -1;
|
| | | }
|
| | | return Mathf.Min(flashShops.Count - 1, allDay ? 0 : _timeIndex);
|
| | | }
|
| | |
|
| | | public FlashSaleGift GetFlashSaleGift(int _index, int _id)
|
| | | {
|
| | | if (_index < flashShops.Count)
|
| | | {
|
| | | for (int i = 0; i < flashShops[_index].gifts.Length; i++)
|
| | | {
|
| | | if (flashShops[_index].gifts[i].id == _id)
|
| | | {
|
| | | return flashShops[_index].gifts[i];
|
| | | }
|
| | | }
|
| | | }
|
| | | return default(FlashSaleGift);
|
| | | }
|
| | |
|
| | | public override bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | |
|
| | | public override void Reset()
|
| | | {
|
| | | base.Reset();
|
| | | flashShops.Clear();
|
| | | }
|
| | |
|
| | | public override string ToDisplayTime()
|
| | | {
|
| | | var textBuilder = OperationTimeHepler.textBuilder;
|
| | | textBuilder.Length = 0;
|
| | | textBuilder.Append(startDate.ToDisplay());
|
| | | if (startDate != endDate)
|
| | | {
|
| | | textBuilder.Append("—");
|
| | | textBuilder.Append(endDate.ToDisplay());
|
| | | }
|
| | | return textBuilder.ToString();
|
| | | }
|
| | |
|
| | | public int GetSurplusTime(int index)
|
| | | {
|
| | | if (!InTime(TimeUtility.ServerNow))
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | var seconds = 0;
|
| | | if (times.Count == 0)
|
| | | {
|
| | | DateTime endOperationTime = new DateTime(TimeUtility.Year, TimeUtility.Month,
|
| | | TimeUtility.Day, 0, 0, 0);
|
| | | endOperationTime = endOperationTime.AddDays(1);
|
| | | seconds = (int)(endOperationTime - TimeUtility.ServerNow).TotalSeconds;
|
| | | }
|
| | | if (index >= 0 && index < times.Count)
|
| | | {
|
| | | var _endTime = times[index];
|
| | | DateTime endOperationTime = new DateTime(TimeUtility.Year, TimeUtility.Month,
|
| | | TimeUtility.Day, _endTime.endHour, _endTime.endMinute, 0);
|
| | | seconds = (int)(endOperationTime - TimeUtility.ServerNow).TotalSeconds;
|
| | | }
|
| | | return seconds;
|
| | | }
|
| | |
|
| | | public struct FlashSale
|
| | | {
|
| | | public FlashSaleGift[] gifts;
|
| | | }
|
| | |
|
| | | public struct FlashSaleGift
|
| | | {
|
| | | public int id;
|
| | | public int limitNum;
|
| | | public int moneyType;
|
| | | public int moneyNumber;
|
| | | public int moneyOriginal;
|
| | | public FlashSaleItem[] items;
|
| | | }
|
| | |
|
| | | public struct FlashSaleItem
|
| | | {
|
| | | public int itemId;
|
| | | public int itemCount;
|
| | | public int isBind;
|
| | | public bool isMainItem;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public class GiftPackageClass : OperationBase
|
| | | {
|
| | | public bool dayReset = false;
|
| | |
|
| | | public List<Gift_Package> giftpackage1 = new List<Gift_Package>();
|
| | |
|
| | | public int IndexOfFlashShop()
|
| | | {
|
| | | if (giftpackage1.Count == 1)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow);
|
| | | if (_timeIndex == -1)
|
| | | {
|
| | | return -1;
|
| | | }
|
| | | return Mathf.Min(giftpackage1.Count - 1, allDay ? 0 : _timeIndex);
|
| | | }
|
| | |
|
| | | public GiftPackageGift GetFlashSaleGift(int _index, int _id)
|
| | | {
|
| | | if (_index < giftpackage1.Count)
|
| | | {
|
| | | for (int i = 0; i < giftpackage1[_index].gifts.Length; i++)
|
| | | {
|
| | | if (giftpackage1[_index].gifts[i].id == _id)
|
| | | {
|
| | | return giftpackage1[_index].gifts[i];
|
| | | }
|
| | | }
|
| | | }
|
| | | return default(GiftPackageGift);
|
| | | }
|
| | |
|
| | | public override bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | |
|
| | | public override void Reset()
|
| | | {
|
| | | base.Reset();
|
| | | giftpackage1.Clear();
|
| | | }
|
| | |
|
| | | public override string ToDisplayTime()
|
| | | {
|
| | | var textBuilder = OperationTimeHepler.textBuilder;
|
| | | textBuilder.Length = 0;
|
| | | textBuilder.Append(startDate.ToDisplay());
|
| | | if (startDate != endDate)
|
| | | {
|
| | | textBuilder.Append("—");
|
| | | textBuilder.Append(endDate.ToDisplay());
|
| | | }
|
| | | return textBuilder.ToString();
|
| | | }
|
| | |
|
| | | public struct Gift_Package
|
| | | {
|
| | | public GiftPackageGift[] gifts;
|
| | | }
|
| | |
|
| | | public struct GiftPackageGift
|
| | | {
|
| | | public int id;
|
| | | public int limitNum;//限购数
|
| | | public int rmb;//人民币
|
| | | public int rmbOriginal;//原价
|
| | | public string OrderInfo;//商品编号
|
| | | public int OrderInfoLength;//长度
|
| | | public GiftPackageItem[] items;
|
| | | }
|
| | |
|
| | | public struct GiftPackageItem
|
| | | {
|
| | | public int itemId;
|
| | | public int itemCount;
|
| | | public int isBind;
|
| | | public bool isMainItem;
|
| | | }
|
| | | }
|
| | |
|
| | | public class OperationConsumeRebate : OperationBase
|
| | | {
|
| | | public bool dayReset = false;
|
| | |
|
| | | public List<Rebate> rebates = new List<Rebate>();
|
| | | public override bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | |
|
| | | public override string ToDisplayTime()
|
| | | {
|
| | | var textBuilder = OperationTimeHepler.textBuilder;
|
| | | textBuilder.Length = 0;
|
| | | textBuilder.Append(startDate.ToDisplay());
|
| | | if (startDate != endDate)
|
| | | {
|
| | | textBuilder.Append("—");
|
| | | textBuilder.Append(endDate.ToDisplay());
|
| | | }
|
| | | return textBuilder.ToString();
|
| | | }
|
| | |
|
| | | public override void Reset()
|
| | | {
|
| | | base.Reset();
|
| | | rebates.Clear();
|
| | | }
|
| | |
|
| | | public Rebate GetRebate(DateTime time)
|
| | | {
|
| | | if (rebates.Count == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | var index = IndexOfOpenDay(time);
|
| | | if (index != -1 && index < rebates.Count)
|
| | | {
|
| | | return rebates[index];
|
| | | }
|
| | | return rebates[rebates.Count - 1];
|
| | | }
|
| | |
|
| | | public class Rebate
|
| | | {
|
| | | public List<RebateGrade> rebateGrades = new List<RebateGrade>();
|
| | | }
|
| | |
|
| | | public class RebateGrade
|
| | | {
|
| | | public int needGold;
|
| | | public int index;//奖励索引
|
| | | public List<Item> items = new List<Item>();
|
| | | }
|
| | |
|
| | | public struct Item
|
| | | {
|
| | | public int itemId;
|
| | | public int count;
|
| | | public int isBind;
|
| | | }
|
| | | }
|
| | |
|
| | | public class OperationBossReborn : OperationBase
|
| | | {
|
| | | public override bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | | }
|
| | |
|
| | | public class OperationMultipleRealmPoint : OperationBase
|
| | | {
|
| | | public int multiplePractice; //倍数
|
| | | public int startHour = 5;
|
| | | public int startMinute = 0;
|
| | | public int startSecond = 0;
|
| | | public override bool SatisfyOpenCondition()
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.LV >= limitLv;
|
| | | }
|
| | |
|
| | | public bool InActiveTime(DateTime time)
|
| | | {
|
| | | if (time.Year != startDate.year && time.Year != endDate.year)
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (startDate.year != endDate.year)
|
| | | {
|
| | | if (time.Year == startDate.year)
|
| | | {
|
| | | if (time.Month < startDate.month)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == startDate.month && time.Day < startDate.day)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if(time.Month == startDate.month
|
| | | && time.Day == startDate.day
|
| | | && time.Hour < startHour)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == startDate.month
|
| | | && time.Day == startDate.day
|
| | | && time.Hour == startHour
|
| | | && time.Minute < startMinute)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == startDate.month
|
| | | && time.Day == startDate.day
|
| | | && time.Hour == startHour
|
| | | && time.Minute == startMinute
|
| | | && time.Second < startSecond)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | else if (time.Year == endDate.year)
|
| | | {
|
| | | if (time.Month > endDate.month)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == endDate.month && time.Day > endDate.day)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if(time.Month == endDate.month |
| | | && time.Day == endDate.day
|
| | | && time.Hour > startHour)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == endDate.month
|
| | | && time.Day == endDate.day
|
| | | && time.Hour == startHour
|
| | | && time.Minute > startMinute)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | else if (time.Month == endDate.month
|
| | | && time.Day == endDate.day
|
| | | && time.Hour == startHour
|
| | | && time.Minute == startMinute
|
| | | && time.Second > startSecond)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (time.Month < startDate.month |
| | | || (time.Month == startDate.month && time.Day < startDate.day)
|
| | | || (time.Month == startDate.month && time.Day == startDate.day && time.Hour < startHour)
|
| | | || (time.Month == startDate.month && time.Day == startDate.day && time.Hour == startHour && time.Minute < startMinute)
|
| | | || (time.Month == startDate.month && time.Day == startDate.day && time.Hour == startHour && time.Minute == startMinute) && time.Second < startSecond)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | if (time.Month > endDate.month |
| | | || (time.Month == endDate.month && time.Day > endDate.day)
|
| | | || (time.Month == endDate.month && time.Day == endDate.day && time.Hour > startHour)
|
| | | || (time.Month == endDate.month && time.Day == endDate.day && time.Hour == startHour && time.Minute > startMinute)
|
| | | || (time.Month == endDate.month && time.Day == endDate.day && time.Hour == startHour && time.Minute == startMinute) && time.Second > startSecond)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | public int GetRemainTime(DateTime time)
|
| | | {
|
| | | var seconds = 0;
|
| | | if (InActiveTime(time))
|
| | | {
|
| | | DateTime endTime = new DateTime(endDate.year, endDate.month, endDate.day, startHour, 0, 0);
|
| | | seconds = (int)(endTime - time).TotalSeconds;
|
| | | }
|
| | | return seconds;
|
| | | }
|
| | | }
|
| | |
|