少年修仙传客户端代码仓库
client_linchunjie
2018-09-13 07d1576a5e725429bd82edf13f79ca22a2dcdd64
3442运营活动修改
2个文件已修改
98 ■■■■■ 已修改文件
System/Welfare/OperationBase.cs 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Welfare/OperationTimeHepler.cs 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Welfare/OperationBase.cs
@@ -40,6 +40,9 @@
        public bool inTimeNotify = false;
        public bool inDateNotify = false;
        public int inAdvanceMinute = 0;
        public bool inAdvanceNotify = false;
        public int limitLv;
        public bool allDay
@@ -155,6 +158,54 @@
            return 0;
        }
        public bool InAdvanceTime(DateTime time)
        {
            if (inAdvanceMinute <= 0)
            {
                return false;
            }
            var advanceSeconds = inAdvanceMinute * 60;
            return GetSecondsBeforeStart(time) <= advanceSeconds;
        }
        public int GetSecondsBeforeStart(DateTime time)
        {
            var seconds = 0;
            if (InTime(time))
            {
                return 0;
            }
            if (allDay)
            {
                var startHour = 0;
                if (resetType == 0)
                {
                    startHour = 0;
                }
                else if (resetType == 1)
                {
                    startHour = DayResetHour;
                }
                var startTime = new DateTime(startDate.year, startDate.month, startDate.day, startHour, 0, 0);
                seconds = (int)(startTime - time).TotalSeconds;
            }
            else
            {
                var index = IndexOfDays(time);
                var date = startDate.AddDays(index);
                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;
                    }
                }
            }
            return seconds;
        }
        public virtual string ToDisplayTime()
        {
            return string.Empty;
@@ -169,6 +220,8 @@
            dayReset = false;
            resetType = 0;
            limitLv = 0;
            inAdvanceNotify = false;
            inAdvanceMinute = 0;
            times.Clear();
        }
System/Welfare/OperationTimeHepler.cs
@@ -16,6 +16,7 @@
        public event Action<Operation, int> operationEndEvent;//活动结束时间触发  第二个参数0--过活动时间触发  1--过活动天触发
        public event Action<Operation, int> operationStartEvent;//活动开始时间并且满足开启条件触发 第二个参数0--活动时间触发  1--活动天触发
        public event Action<int> dayResetEvent;//活动重置事件0-0点 1-5点
        public event Action<Operation> operationAdvanceEvent;//活动在提前开启的时间内
        public OperationTimeHepler()
        {
            DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerDataInitializeEvent;
@@ -39,8 +40,8 @@
                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;
@@ -50,7 +51,7 @@
                            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;
@@ -60,8 +61,8 @@
                            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;
@@ -71,14 +72,25 @@
                            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)
                        {
                            operationEndEvent((Operation)i, 0);
                        }
                    }
                    if (!operation.inAdvanceNotify && operation.InAdvanceTime(TimeUtility.ServerNow))
                    {
                        operation.inAdvanceNotify = true;
                        DebugEx.LogFormat("{0}  活动提前开启", (Operation)i);
                        if (operationAdvanceEvent != null)
                        {
                            operationAdvanceEvent((Operation)i);
                        }
                    }
                }
@@ -381,6 +393,26 @@
            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;
@@ -639,7 +671,6 @@
            return Mathf.Max(0, (int)(d - y).TotalSeconds);
        }
    }
    public enum Operation
    {