//--------------------------------------------------------  
 | 
//    [Author]:           第二世界  
 | 
//    [  Date ]:           Wednesday, January 09, 2019  
 | 
//--------------------------------------------------------  
 | 
  
 | 
using System;  
 | 
using System.Collections;  
 | 
using System.Collections.Generic;  
 | 
using UnityEngine;  
 | 
using UnityEngine.UI;  
 | 
  
 | 
namespace vnxbqy.UI  
 | 
{  
 | 
    //成就活动面板  
 | 
    public class AchievementActivityWin : OneLevelWin  
 | 
    {  
 | 
        Dictionary<int, FunctionButton> m_FunctionButtons = new Dictionary<int, FunctionButton>();  
 | 
  
 | 
        #region Built-in  
 | 
        OpenServiceAchievementModel openServiceAchievementModel { get { return ModelCenter.Instance.GetModel<OpenServiceAchievementModel>(); } }  
 | 
        SpringFestivalModel springFestivalModel { get { return ModelCenter.Instance.GetModel<SpringFestivalModel>(); } }  
 | 
  
 | 
        protected override void BindController()  
 | 
        {  
 | 
            m_TitleIcon = this.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");  
 | 
            m_Group = this.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");  
 | 
            m_Left = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");  
 | 
            m_Right = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");  
 | 
            m_Close = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");  
 | 
  
 | 
            m_SubWindowContainer = this.GetComponent<RectTransform>("Pivot/Container_SubWindow");  
 | 
  
 | 
            var name = this.GetType().Name;  
 | 
            var infos = WindowConfig.GetWindowFunctionInfos(name);  
 | 
            foreach (var info in infos)  
 | 
            {  
 | 
                m_FunctionButtons.Add(info.order,  
 | 
                    m_Group.AddFunction("FunctionButton_Pattern_1", info.order, info.functionId, Language.Get(info.titleKey), info.redPointId));  
 | 
            }  
 | 
  
 | 
            m_TitleIcon.SetSprite(WindowConfig.GetTitleIconKey(name));  
 | 
            m_TitleIcon.SetNativeSize();  
 | 
        }  
 | 
  
 | 
        protected override void AddListeners()  
 | 
        {  
 | 
            base.AddListeners();  
 | 
            SetFunctionListener(0, OpenServiceAchievementButton);  
 | 
            SetFunctionListener(1, SpringFestivalButton);  
 | 
        }  
 | 
  
 | 
        protected override void OnPreOpen()  
 | 
        {  
 | 
            base.OnPreOpen();  
 | 
            OperationTimeHepler.Instance.operationStartEvent += operationStartEvent;  
 | 
            VerifyFunctionState();  
 | 
            if (WindowCenter.Instance.IsOpen<MainInterfaceWin>())  
 | 
            {  
 | 
                WindowCenter.Instance.Close<MainInterfaceWin>();  
 | 
            }  
 | 
            if (WindowJumpMgr.Instance.IsJumpState)  
 | 
            {  
 | 
                return;  
 | 
            }  
 | 
            if (openServiceAchievementModel.IsOpenFeatures())  
 | 
            {  
 | 
                functionOrder = 0;  
 | 
            }  
 | 
            else if (springFestivalModel.IsOpenFeatures())  
 | 
            {  
 | 
                functionOrder = 1;  
 | 
            }  
 | 
        }  
 | 
  
 | 
        protected override void OnActived()  
 | 
        {  
 | 
            m_Group.TriggerByOrder(functionOrder);  
 | 
        }  
 | 
  
 | 
        protected override void OnAfterOpen()  
 | 
        {  
 | 
            OperationTimeHepler.Instance.operationStartEvent -= operationStartEvent;  
 | 
        }  
 | 
  
 | 
        private void operationStartEvent(Operation arg1, int arg2)  
 | 
        {  
 | 
            if (arg1 == Operation.SpringFestival || arg1 == Operation.OpenServiceAchievement)  
 | 
            {  
 | 
                VerifyFunctionState();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        protected override void OnPreClose()  
 | 
        {  
 | 
            CloseChild();  
 | 
            if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())  
 | 
            {  
 | 
                WindowCenter.Instance.Open<MainInterfaceWin>();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        protected override void OnAfterClose()  
 | 
        {  
 | 
        }  
 | 
  
 | 
        void CloseChild()  
 | 
        {  
 | 
            if (WindowCenter.Instance.IsOpen<OpenServiceAchievementWin>())  
 | 
            {  
 | 
                WindowCenter.Instance.Close<OpenServiceAchievementWin>();  
 | 
            }  
 | 
            if (WindowCenter.Instance.IsOpen<SpringFestivalWin>())  
 | 
            {  
 | 
                WindowCenter.Instance.Close<SpringFestivalWin>();  
 | 
            }  
 | 
        }  
 | 
  
 | 
        private void OpenServiceAchievementButton()  
 | 
        {  
 | 
            CloseChild();  
 | 
            WindowCenter.Instance.Open<OpenServiceAchievementWin>(true);  
 | 
            functionOrder = 0;  
 | 
        }  
 | 
        private void SpringFestivalButton()  
 | 
        {  
 | 
            CloseChild();  
 | 
            WindowCenter.Instance.Open<SpringFestivalWin>(true);  
 | 
            functionOrder = 1;  
 | 
        }  
 | 
        #endregion  
 | 
  
 | 
        private void VerifyFunctionState()  
 | 
        {  
 | 
            var isWeekPartyOpen = openServiceAchievementModel.IsOpenFeatures();  
 | 
            var isSpringFestival = springFestivalModel.IsOpenFeatures();  
 | 
  
 | 
            m_FunctionButtons[0].SetActive(isWeekPartyOpen);  
 | 
            m_FunctionButtons[0].state = isWeekPartyOpen ? TitleBtnState.Normal : TitleBtnState.Normal;  
 | 
  
 | 
            m_FunctionButtons[1].SetActive(isSpringFestival);  
 | 
            m_FunctionButtons[1].state = isSpringFestival ? TitleBtnState.Normal : TitleBtnState.Normal;  
 | 
  
 | 
            m_Left.SetActive(isWeekPartyOpen && isSpringFestival);  
 | 
            m_Right.SetActive(isWeekPartyOpen && isSpringFestival);  
 | 
  
 | 
            m_TitleIcon.SetSprite(isWeekPartyOpen ? "OneLevelTitle_28" : "OneLevelTitle_27");  
 | 
        }  
 | 
    }  
 | 
  
 | 
}  
 | 
  
 | 
  
 | 
  
 | 
  
 |