| | |
| | | public class FlashSaleCoolDown : MonoBehaviour
|
| | | {
|
| | | [SerializeField] TimerBehaviour m_Time;
|
| | | [SerializeField] RectTransform m_ContainerAdvance;
|
| | | [SerializeField] Text m_AdvanceTime;
|
| | |
|
| | | private void OnEnable()
|
| | | {
|
| | |
| | | if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.FlashSale, out operationBase))
|
| | | {
|
| | | var operation = (operationBase as OperationFlashSale);
|
| | | var seconds = operation.GetResetSurplusTime();
|
| | | if (seconds * TimeSpan.TicksPerSecond >= TimeSpan.TicksPerDay || seconds <= 0)
|
| | | bool inAdvance = false;
|
| | | var seconds = 0;
|
| | | if (operation.InAdvanceTime(TimeUtility.ServerNow))
|
| | | {
|
| | | inAdvance = true;
|
| | | seconds = operation.GetSecondsBeforeStart(TimeUtility.ServerNow);
|
| | | }
|
| | | else
|
| | | {
|
| | | seconds = operation.GetResetSurplusTime();
|
| | | }
|
| | |
|
| | | m_ContainerAdvance.gameObject.SetActive(inAdvance);
|
| | | if (inAdvance)
|
| | | {
|
| | | if (m_Time.gameObject.activeSelf)
|
| | | {
|
| | | DisplayTime(0);
|
| | | }
|
| | | DisplayAdvance(seconds);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Time.timeShow.color = seconds > 3600 ? UIHelper.GetUIColor(TextColType.Green) : UIHelper.GetUIColor(TextColType.Red);
|
| | | if (!m_Time.gameObject.activeSelf)
|
| | | if (seconds * TimeSpan.TicksPerSecond >= TimeSpan.TicksPerDay || seconds <= 0)
|
| | | {
|
| | | DisplayTime(seconds);
|
| | | if (m_Time.gameObject.activeSelf)
|
| | | {
|
| | | DisplayTime(0);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Time.timeShow.color = seconds > 3600 ? UIHelper.GetUIColor(TextColType.Green) : UIHelper.GetUIColor(TextColType.Red);
|
| | | if (!m_Time.gameObject.activeSelf)
|
| | | {
|
| | | DisplayTime(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));
|
| | | }
|
| | | }
|
| | | } |
| | | |