using System; using System.Collections; using System.Collections.Generic; using System.Text; using UnityEngine; namespace Snxxz.UI { public class OperationTimeHepler : Singleton { private Dictionary operationDict = new Dictionary(); public static StringBuilder textBuilder = new StringBuilder(); public event Action operationTimeUpdateEvent; public event Action operationServerCloseEvent;//特殊情况下触发 public event Action operationEndEvent;//活动结束时间触发 第二个参数0--过活动时间触发 1--过活动天触发 public event Action operationStartEvent;//活动开始时间并且满足开启条件触发 第二个参数0--活动时间触发 1--活动天触发 public event Action operationAdvanceEvent;//活动提前开放事件 public OperationTimeHepler() { DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitializeEvent; GlobalTimeEvent.Instance.secondEvent += SecondEvent; } private void BeforePlayerDataInitializeEvent() { operationDict.Clear(); } private void SecondEvent() { if (!(StageManager.Instance.CurrentStage is DungeonStage)) { return; } for (int i = 0; i < (int)Operation.max; i++) { if (operationDict.ContainsKey((Operation)i)) { var operation = operationDict[(Operation)i]; if (operation.InDay(TimeUtility.ServerNow) && operation.SatisfyOpenCondition() && !operation.inDateNotify) { operation.inDateNotify = true; operation.stepDateNotify = false; DebugEx.LogFormat("{0} 活动天开始", (Operation)i); if (operationStartEvent != null) { operationStartEvent((Operation)i, 1); } } else if (!operation.InDay(TimeUtility.ServerNow) && !operation.stepDateNotify) { operation.inDateNotify = false; operation.stepDateNotify = true; DebugEx.LogFormat("{0} 活动天结束", (Operation)i); if (operationEndEvent != null) { operationEndEvent((Operation)i, 1); } } if (operation.InTime(TimeUtility.ServerNow) && operation.SatisfyOpenCondition() && !operation.inTimeNotify) { 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) { operation.inTimeNotify = false; operation.stepTimeNotify = true; DebugEx.LogFormat("{0} 活动时间结束", (Operation)i); if (operationEndEvent != null) { operationEndEvent((Operation)i, 0); } } if (!operation.inAdvanceNotify && operation.InAdvanceTime(TimeUtility.ServerNow)) { operation.inAdvanceNotify = true; if (operationAdvanceEvent != null) { operationAdvanceEvent((Operation)i); } } } } } /// /// 多倍经验 /// /// public void UpdateMultipleExp(HAC06_tagGCMultiExpRateInfo package) { 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 (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); } } else { if (operation == null) { operation = new OperationMultiExp(); operationDict.Add(Operation.MultipleExp, operation); } operation.Reset(); operation.startDate = ParseOperationDate(package.StartDate); operation.endDate = ParseOperationDate(package.EndtDate); operation.limitLv = package.LimitLV; (operation as OperationMultiExp).multiple = (int)package.AddExpRate + 10000; if (package.ActivityTimeCount == 0) { operation.allDay = true; } else { for (int i = 0; i < package.ActivityTimeCount; i++) { operation.times.Add(ParseOperationTime(package.ActivityTime[i].StartTime, package.ActivityTime[i].EndtTime)); } } if (operationTimeUpdateEvent != null) { operationTimeUpdateEvent(Operation.MultipleExp); } } } /// /// 消费返利 /// /// public void UpdateConsumeRebate(HAA09_tagMCCostRebateInfo package) { 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 (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); } } else { if (operationBase == null) { operationBase = new OperationConsumeRebate(); operationDict.Add(Operation.ConsumeRebate, operationBase); } OperationConsumeRebate operation = operationBase as OperationConsumeRebate; operation.Reset(); 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); } if (operationTimeUpdateEvent != null) { operationTimeUpdateEvent(Operation.ConsumeRebate); } } } /// /// 限时特惠 /// /// public void UpdateFlashSale(HAA11_tagMCSpringSaleInfo package) { OperationBase operationBase = null; 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); } } else { if (operationBase == null) { operationBase = new OperationFlashSale(); operationDict.Add(Operation.FlashSale, operationBase); } OperationFlashSale operation = operationBase as OperationFlashSale; operation.Reset(); operation.limitLv = package.LimitLV; operation.startDate = ParseOperationDate(package.StartDate); operation.endDate = ParseOperationDate(package.EndtDate); operation.dayReset = package.IsDayReset == 1; if (package.ActivityTimeCount == 0) { operation.allDay = true; } 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); } if (operationTimeUpdateEvent != null) { operationTimeUpdateEvent(Operation.FlashSale); } } } /// /// 限时礼包 /// /// /// 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); } } else { if (operationBase == null) { operationBase = new GiftPackageClass(); operationDict.Add(Operation.GiftPackage, operationBase); } GiftPackageClass operation = operationBase as GiftPackageClass; operation.Reset(); operation.limitLv = package.LimitLV; operation.startDate = ParseOperationDate(package.StartDate); operation.endDate = ParseOperationDate(package.EndtDate); operation.dayReset = package.IsDayReset == 1; if (package.ActivityTimeCount == 0) { operation.allDay = true; } 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); } if (operationTimeUpdateEvent != null) { operationTimeUpdateEvent(Operation.GiftPackage); } } } public void UpdateBossReborn(HAB04_tagMCBossRebornInfo package) { 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); } } else { OperationBase operationBase = null; operationDict.TryGetValue(Operation.BossReborn, out operationBase); if (operationBase == null) { operationDict[Operation.BossReborn] = operationBase = new OperationBossReborn(); } operationBase.Reset(); operationBase.limitLv = package.LimitLV; operationBase.allDay = true; operationBase.startDate = ParseOperationDate(package.StartDate); operationBase.endDate = ParseOperationDate(package.EndtDate); ModelCenter.Instance.GetModel().UpdateTaskBaseInfos(package.TaskInfo); } } /// /// 仙界盛典 /// /// public void RefreshFairyCeremonyInfo(HAC09_tagGCFairyCeremonyInfo package) { 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 (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); } } else { if (operation == null) { operation = new OperationBase(); operationDict.Add(Operation.FairyCeremony, operation); } operation.Reset(); operation.startDate = ParseOperationDate(package.StartDate); operation.endDate = ParseOperationDate(package.EndtDate); operation.limitLv = package.LimitLV; operation.allDay = true; if (operationTimeUpdateEvent != null) { operationTimeUpdateEvent(Operation.FairyCeremony); } } } /// /// N倍修行点 /// /// public void RefreshNTimesPractice(HAC0A_tagGCMultiRealmPointInfo package) { 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 (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); } } else { if (operation == null) { operation = new OperationMultipleRealmPoint(); operationDict.Add(Operation.MultipRealmPoint, operation); } operation.Reset(); 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); } } } public bool TryGetOperationTime(Operation type, out OperationBase operation) { return operationDict.TryGetValue(type, out operation); } public bool InOperationTime(Operation type) { OperationBase operation; if (TryGetOperationTime(type, out operation)) { return operation.InTime(TimeUtility.ServerNow); } return false; } public bool InOperationDay(Operation type) { OperationBase operation; if (TryGetOperationTime(type, out operation)) { return operation.InDay(TimeUtility.ServerNow); } 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; if (TryGetOperationTime(type, out operation)) { return operation.GetSurplusTime(TimeUtility.ServerNow); } return 0; } public bool SatisfyOpenCondition(Operation type) { OperationBase operation; if (TryGetOperationTime(type, out operation)) { return operation.SatisfyOpenCondition() && InOperationTime(type); } return false; } public void ProcessConditionError(Operation type) { if (SatisfyOpenCondition(type)) { return; } OperationBase operation; if (TryGetOperationTime(type, out operation)) { if (!InOperationTime(type)) { SysNotifyMgr.Instance.ShowTip("InOperationTimeError"); } else if (!operation.SatisfyOpenCondition()) { SysNotifyMgr.Instance.ShowTip(StringUtility.Contact("OperationLevelLimit_", type), operation.limitLv); } } else { SysNotifyMgr.Instance.ShowTip("InOperationTimeError"); } } 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('-'); if (dateArray != null && dateArray.Length == 3) { return new OperationDate() { year = int.Parse(dateArray[0].Trim()), month = int.Parse(dateArray[1].Trim()), day = int.Parse(dateArray[2].Trim()) }; } return default(OperationDate); } OperationTime ParseOperationTime(string startTime, string endTime) { var startTimeArray = startTime.Split(':'); var endTimeArray = endTime.Split(':'); if (startTimeArray != null && startTimeArray.Length == 2 && endTimeArray != null && endTimeArray.Length == 2) { return new OperationTime() { startHour = int.Parse(startTimeArray[0].Trim()), startMinute = int.Parse(startTimeArray[1].Trim()), endHour = int.Parse(endTimeArray[0].Trim()), endMinute = int.Parse(endTimeArray[1].Trim()), }; } return default(OperationTime); } } 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; public int month; public int day; public static bool operator ==(OperationDate x, OperationDate y) { return x.year == y.year && x.month == y.month && x.day == y.day; } public static bool operator !=(OperationDate x, OperationDate y) { return !(x == y); } public DateTime AddSeconds(int _seconds) { DateTime d = new DateTime(year, month, day); return d.AddTicks(_seconds * TimeSpan.TicksPerSecond); } public string ToDisplay(bool showYear = true) { var yearString = StringUtility.Contact(year, Language.Get("Year")); return StringUtility.Contact(showYear ? yearString : string.Empty, month, Language.Get("Month"), day, Language.Get("Day")); } public static int operator -(OperationDate x, OperationDate y) { DateTime _x = new DateTime(x.year, x.month, x.day); DateTime _y = new DateTime(y.year, y.month, y.day); return (int)(_y - _x).TotalDays; } } public struct OperationTime { public int startHour; public int startMinute; public int endHour; public int endMinute; 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; } public int SideOfTime(DateTime time) { if (time.Hour < startHour || (time.Hour == startHour && time.Minute < startMinute)) { return -1; } if (time.Hour > endHour || (time.Hour == endHour && time.Minute >= endMinute)) { return 1; } return 0; } public override string ToString() { return StringUtility.Contact(startHour.ToString("D2"), ":", startMinute.ToString("D2"), "-", endHour.ToString("D2"), ":", endMinute.ToString("D2")); } public static int operator -(OperationTime x, DateTime y) { 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 times = new List(); 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 flashShops = new List(); public int IndexOfFlashShop() { if (flashShops.Count == 1) { return 0; } var _dayIndex = IndexOfOpenDay(TimeUtility.ServerNow); if (_dayIndex == -1) { return -1; } var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow); if (_timeIndex == -1) { return -1; } return Mathf.Min(flashShops.Count - 1, allDay ? _dayIndex : _dayIndex * 2 + _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 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 giftpackage1 = new List(); public int IndexOfFlashShop() { if (giftpackage1.Count == 1) { return 0; } var _dayIndex = IndexOfOpenDay(TimeUtility.ServerNow); if (_dayIndex == -1) { return -1; } var _timeIndex = IndexOfOpenTime(TimeUtility.ServerNow); if (_timeIndex == -1) { return -1; } return Mathf.Min(giftpackage1.Count - 1, allDay ? _dayIndex : _dayIndex * 2 + _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 rebates = new List(); 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 rebateGrades = new List(); } public class RebateGrade { public int needGold; public int index;//奖励索引 public List items = new List(); } 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 override bool SatisfyOpenCondition() { return PlayerDatas.Instance.baseData.LV >= limitLv; } } public enum Operation { MultipleExp, ConsumeRebate, FlashSale, BossReborn, GiftPackage, FairyCeremony, //仙界盛典 MultipRealmPoint, //N倍修行点 max, } }