| | |
| | | using UnityEngine;
|
| | | using UnityEngine.UI;
|
| | |
|
| | | namespace Snxxz.UI {
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
|
| | | public class TreasureChapterWin : Window
|
| | | {
|
| | | [SerializeField] UIAlphaTween m_AlphaTween;
|
| | | [SerializeField] Text m_ChapterName;
|
| | | [SerializeField] Image m_ChapterIcon;
|
| | | [SerializeField] Image m_TreasureIcon;
|
| | | [SerializeField] Text m_Description;
|
| | | [SerializeField] Text m_CloseRemind;
|
| | | [SerializeField] Transform m_ContainerFly;
|
| | | [SerializeField] Button m_Close;
|
| | |
|
| | | float timer = 0f;
|
| | |
|
| | | bool flying = false;
|
| | |
|
| | | FunctionUnlockFlyObject flyObject = null;
|
| | |
|
| | | TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
| | |
|
| | | #region Built-in
|
| | | protected override void BindController()
|
| | |
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | m_Close.AddListener(OnClickClose);
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | if (flyObject != null)
|
| | | {
|
| | | Destroy(flyObject);
|
| | | flyObject = null;
|
| | | }
|
| | |
|
| | | timer = 0f;
|
| | |
|
| | | flying = false;
|
| | |
|
| | | m_CloseRemind.gameObject.SetActive(false);
|
| | |
|
| | | m_AlphaTween.from = 0f;
|
| | | m_AlphaTween.to = 1f;
|
| | |
|
| | | Display();
|
| | | m_AlphaTween.SetStartState();
|
| | | }
|
| | |
|
| | | protected override void OnActived()
|
| | | {
|
| | | base.OnActived();
|
| | | m_AlphaTween.Play();
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | |
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void LateUpdate()
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | if (timer >= 2f)
|
| | | {
|
| | | if (!m_CloseRemind.gameObject.activeSelf)
|
| | | {
|
| | | m_CloseRemind.gameObject.SetActive(true);
|
| | | }
|
| | | }
|
| | | }
|
| | | #endregion
|
| | | |
| | |
|
| | | void Display()
|
| | | {
|
| | | var instance = UIUtility.CreateWidget("TreasureChapterFlyObject", "TreasureChapterFlyObject");
|
| | | instance.transform.SetParentEx(m_ContainerFly, Vector3.zero, Quaternion.identity, Vector3.one);
|
| | | flyObject = instance.GetComponent<FunctionUnlockFlyObject>();
|
| | | flyObject.SetContent(FunctionUnlockType.TreasureChapter, model.treasureChapterId);
|
| | | flyObject.gameObject.SetActive(true);
|
| | |
|
| | | var config = TreasureConfig.Get(model.treasureChapterId);
|
| | | if (config != null)
|
| | | {
|
| | | m_TreasureIcon.SetSprite(config.Icon);
|
| | | }
|
| | |
|
| | | var chapterConfig = TreasureChapterConfig.Get(model.treasureChapterId);
|
| | |
|
| | | if (chapterConfig != null)
|
| | | {
|
| | | m_ChapterIcon.SetSprite(chapterConfig.taskTitle);
|
| | | m_ChapterName.text = string.Format("第{0}章", Language.Get("Num_CHS_" + chapterConfig.chapterIndex));
|
| | | m_Description.text = chapterConfig.description;
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnClickClose()
|
| | | {
|
| | | if (timer < 2f || flying)
|
| | | {
|
| | | return;
|
| | | }
|
| | | flying = true;
|
| | | m_AlphaTween.from = 1f;
|
| | | m_AlphaTween.to = 0f;
|
| | | m_AlphaTween.Play(OnTweenComplete);
|
| | | }
|
| | |
|
| | | private void OnTweenComplete()
|
| | | {
|
| | | if (flyObject != null)
|
| | | {
|
| | | flyObject.Begin(OnReach);
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnReach()
|
| | | {
|
| | | CloseClick();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|