| | |
| | |
|
| | | public class LimitedTimePackageTime:MonoBehaviour {
|
| | |
|
| | | [SerializeField] Text m_LimitedTimePackageTime_text;
|
| | | [SerializeField] TimerBehaviour m_Time;
|
| | | [SerializeField] RectTransform m_ContainerAdvance;
|
| | | [SerializeField] Text m_AdvanceTime;
|
| | |
|
| | | private void OnEnable()
|
| | | {
|
| | | GlobalTimeEvent.Instance.secondEvent += secondEvent;
|
| | | OperationTimeHepler.Instance.dayResetEvent += DayResetEvent;
|
| | | }
|
| | | private void OnDisable()
|
| | | {
|
| | | GlobalTimeEvent.Instance.secondEvent -= secondEvent;
|
| | | OperationTimeHepler.Instance.dayResetEvent -= DayResetEvent;
|
| | | }
|
| | |
|
| | | private void DayResetEvent(int resetType)
|
| | | {
|
| | | secondEvent();
|
| | | }
|
| | |
|
| | | private void secondEvent()
|
| | | {
|
| | | int time = OperationTimeHepler.Instance.GetOperationSurplusTime(Operation.GiftPackage);
|
| | | if (time <= 0)
|
| | | OperationBase operationBase;
|
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.GiftPackage, out operationBase))
|
| | | {
|
| | | if (m_LimitedTimePackageTime_text.gameObject.activeSelf)
|
| | | var operation = (operationBase as GiftPackageClass);
|
| | | bool inAdvance = false;
|
| | | var seconds = 0;
|
| | | if (operation.InAdvanceTime(TimeUtility.ServerNow))
|
| | | {
|
| | | m_LimitedTimePackageTime_text.gameObject.SetActive(false);
|
| | | inAdvance = true;
|
| | | seconds = operation.GetSecondsBeforeStart(TimeUtility.ServerNow);
|
| | | }
|
| | | return;
|
| | | else
|
| | | {
|
| | | seconds = operation.GetResetSurplusTime();
|
| | | }
|
| | | if (time>86400)
|
| | |
|
| | | m_ContainerAdvance.gameObject.SetActive(inAdvance);
|
| | | if (inAdvance)
|
| | | {
|
| | | if (m_LimitedTimePackageTime_text.gameObject.activeSelf)
|
| | | if (m_Time.gameObject.activeSelf)
|
| | | {
|
| | | m_LimitedTimePackageTime_text.gameObject.SetActive(false);
|
| | | DisplayTime(0);
|
| | | }
|
| | | DisplayAdvance(seconds);
|
| | | }
|
| | | else
|
| | | {
|
| | | if (seconds * TimeSpan.TicksPerSecond >= TimeSpan.TicksPerDay || seconds <= 0)
|
| | | {
|
| | | if (m_Time.gameObject.activeSelf)
|
| | | {
|
| | | DisplayTime(0);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (!m_LimitedTimePackageTime_text.gameObject.activeSelf)
|
| | | m_Time.timeShow.color = seconds > 3600 ? UIHelper.GetUIColor(TextColType.Green) : UIHelper.GetUIColor(TextColType.Red);
|
| | | if (!m_Time.gameObject.activeSelf)
|
| | | {
|
| | | m_LimitedTimePackageTime_text.gameObject.SetActive(true);
|
| | | DisplayTime(seconds);
|
| | | }
|
| | | if (time<3600)
|
| | | {
|
| | | m_LimitedTimePackageTime_text.text = TimeUtility.SecondsToHMS(time);
|
| | | m_LimitedTimePackageTime_text.color = UIHelper.GetUIColor(TextColType.Red);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | m_LimitedTimePackageTime_text.text = TimeUtility.SecondsToHMS(time);
|
| | | m_LimitedTimePackageTime_text.color = UIHelper.GetUIColor(TextColType.Green);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | void DisplayTime(int seconds)
|
| | | {
|
| | | m_Time.timeShow.color = seconds > 3600 ? UIHelper.GetUIColor(TextColType.Green) : UIHelper.GetUIColor(TextColType.Red);
|
| | | m_Time.Begin(DateTime.Now.AddTicks(seconds * TimeSpan.TicksPerSecond));
|
| | | }
|
| | | void DisplayAdvance(int seconds)
|
| | | {
|
| | | m_AdvanceTime.text = Language.Get("OperationAdvanceOpen", TimeUtility.SecondsToHMS(seconds));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|