| //--------------------------------------------------------  | 
| //    [Author]:           第二世界  | 
| //    [  Date ]:           Wednesday, September 19, 2018  | 
| //--------------------------------------------------------  | 
|   | 
| using System;  | 
| using System.Collections;  | 
| using System.Collections.Generic;  | 
|   | 
| using UnityEngine;  | 
| using UnityEngine.UI;  | 
|   | 
| namespace vnxbqy.UI {  | 
|   | 
|     public class FairyChatWin : Window  | 
|     {  | 
|         [SerializeField] ChatSendComponent m_ChatSend;  | 
|         [SerializeField] ChatContentBehaviour m_ChatContent;  | 
|         [SerializeField] RectTransform m_ContainerNoFairy;  | 
|         [SerializeField] Button m_JoinFairy;  | 
|   | 
|         ChatCenter chatCenter { get { return ModelCenter.Instance.GetModel<ChatCenter>(); } }  | 
|   | 
|         #region Built-in  | 
|         protected override void BindController()  | 
|         {  | 
|         }  | 
|   | 
|         protected override void AddListeners()  | 
|         {  | 
|             m_JoinFairy.AddListener(JoinFairy);  | 
|         }  | 
|   | 
|         protected override void OnPreOpen()  | 
|         {  | 
|             WindowCenter.Instance.windowBeforeOpenEvent += WindowBeforeOpenEvent;  | 
|             PlayerDatas.Instance.fairyData.OnRefreshFairyInfo += MyFairyRefresh;  | 
|             PlayerDatas.Instance.fairyData.OnRefreshFairyMine += MyFairyRefresh;  | 
|             ChatCtrl.Inst.presentChatType = ChatInfoType.Fairy;  | 
|             m_ChatContent.chatType = ChatInfoType.Fairy;  | 
|             MyFairyRefresh();  | 
|             ChatCtrl.Inst.ViewChat(ChatInfoType.Fairy);  | 
|             ChatCtrl.Inst.lockUpdate = false;  | 
|             chatCenter.UpdateChatContentPos();  | 
|         }  | 
|   | 
|         protected override void OnActived()  | 
|         {  | 
|             base.OnActived();  | 
|             var parent = WindowCenter.Instance.Get<SocialWin>();  | 
|             if (parent != null)  | 
|             {  | 
|                 m_ChatSend.parent = parent;  | 
|             }  | 
|         }  | 
|   | 
|         protected override void OnAfterOpen()  | 
|         {  | 
|         }  | 
|   | 
|         protected override void OnPreClose()  | 
|         {  | 
|             WindowCenter.Instance.windowBeforeOpenEvent -= WindowBeforeOpenEvent;  | 
|             PlayerDatas.Instance.fairyData.OnRefreshFairyInfo -= MyFairyRefresh;  | 
|             PlayerDatas.Instance.fairyData.OnRefreshFairyMine -= MyFairyRefresh;  | 
|         }  | 
|   | 
|         protected override void OnAfterClose()  | 
|         {  | 
|         }  | 
|         #endregion  | 
|         private void JoinFairy()  | 
|         {  | 
|             int limit = FuncOpenLVConfig.Get((int)FuncOpenEnum.Fairy).LimitLV;  | 
|             if (PlayerDatas.Instance.baseData.LV < limit)  | 
|             {  | 
|                 ServerTipDetails.DisplayNormalTip(Language.Get("L1136", limit));  | 
|                 return;  | 
|             }  | 
|             WindowCenter.Instance.Close<SocialWin>();  | 
|             WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.UnionFunc3);  | 
|         }  | 
|   | 
|         void MyFairyRefresh()  | 
|         {  | 
|             m_ContainerNoFairy.SetActive(!PlayerDatas.Instance.fairyData.HasFairy);  | 
|             m_ChatSend.SetActive(PlayerDatas.Instance.fairyData.HasFairy);  | 
|         }  | 
|   | 
|         private void WindowBeforeOpenEvent(Window win)  | 
|         {  | 
|             if (win is SocialWin)  | 
|             {  | 
|                 m_ChatSend.parent = win;  | 
|             }  | 
|         }  | 
|     }  | 
|   | 
| }  | 
|   | 
|   | 
|   | 
|   |