| | |
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | 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;
|
| | |
| | | return Mathf.Max(0, (int)(d - y).TotalSeconds);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | public enum Operation
|
| | | {
|