//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Thursday, December 07, 2017 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using vnxbqy.UI; namespace vnxbqy.UI { public class VipExperienceWin : Window { [SerializeField] Button m_Known; [SerializeField] Text m_KnownTxt; [SerializeField] Text m_Content; [SerializeField] float m_ViewDuration = 15f; [SerializeField] float m_CountDownSeconds = 5f; float viewTime = 0f; float countDownTime = 0f; #region Built-in protected override void BindController() { } protected override void AddListeners() { m_Known.onClick.AddListener(CloseClick); } protected override void OnPreOpen() { m_Content.text = Language.Get("VipExperience3"); m_KnownTxt.text = Language.Get("VipCard4"); viewTime = Time.time + m_ViewDuration; countDownTime = viewTime + m_CountDownSeconds; GlobalTimeEvent.Instance.secondEvent += SecondEvent; } protected override void OnAfterOpen() { } protected override void OnPreClose() { GlobalTimeEvent.Instance.secondEvent -= SecondEvent; } protected override void OnAfterClose() { if (!WindowJumpMgr.Instance.IsJumpState) { WindowCenter.Instance.Open(); } } #endregion protected override void LateUpdate() { base.LateUpdate(); if (Time.time >= countDownTime) { if (WindowCenter.Instance.IsOpen()) { WindowCenter.Instance.Close(); } } } private void SecondEvent() { var seconds = Mathf.CeilToInt(countDownTime - Time.time); if (seconds <= m_CountDownSeconds) { m_KnownTxt.text = StringUtility.Contact(Language.Get("VipCard4"), "\n(", seconds, ")"); } } } }