少年修仙传客户端代码仓库
client_linchunjie
2019-03-04 2a86bfa84ad4ed870703022ea765e29f16d25a08
System/MainInterfacePanel/TopAnimationPlay.cs
@@ -1,224 +1,236 @@
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, April 11, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using TableConfig;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using System;
using Snxxz.UI;
//顶层控制动画播放
namespace Snxxz.UI
{
    public class TopAnimationPlay : MonoBehaviour
    {
        [SerializeField] Animator m_Animator;
        [SerializeField] bool m_IsplayAnimator = false;
        [SerializeField] CanvasGroup m_CanvasGroup;
        [SerializeField] List<string> AnimatorPlayName = new List<string>();
        private bool IsBool = true;
        IsPlayerUIeffect isPlayerUIeffect;
        HighBtnRecord highBtnRecord;
        TreasureFindHostModel hostModel { get { return ModelCenter.Instance.GetModel<TreasureFindHostModel>(); } }
        OSGiftModel osGiftModel { get { return ModelCenter.Instance.GetModel<OSGiftModel>(); } }
        private void OnEnable()
        {
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
            hostModel.TreasureFindHostCompleteAct += TreasureFindHostCompleteAct;
            osGiftModel.OnOSGiftStateChange += OnOSGiftStateChange;
            RedpointCenter.Instance.redpointValueChangeEvent += UpdateRedpoint;
            TimeUtility.OnServerOpenDayRefresh += OnStepServerDay;
            OpenServerActivityCenter.Instance.openServerActivityStateChange += OpenServerActivityStateChange;
            WindowCenter.Instance.windowAfterOpenEvent += windowAfterOpenEvent;
            OperationTimeHepler.Instance.operationStartEvent += operationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent += operationEndEvent;
        }
        private void operationStartEvent(Operation arg1, int arg2)
        {
            if (arg1 == Operation.GiftPackage || arg1 == Operation.FairyCeremony)
            {
                Await1();
            }
        }
        private void operationEndEvent(Operation arg1, int arg2)
        {
            if (arg1 == Operation.GiftPackage || arg1 == Operation.FairyCeremony)
            {
                Await1();
            }
        }
        private void windowAfterOpenEvent(Window obj)
        {
            if (obj as MainInterfaceWin)
            {
                Await1();
            }
        }
        private void OpenServerActivityStateChange()
        {
            Await1();
        }
        private void UpdateRedpoint(int redPointID)
        {
            if (redPointID == 201 || redPointID == 210)
            {
                Await1();
            }
        }
        private void OnOSGiftStateChange()
        {
            Await1();
        }
        private void TreasureFindHostCompleteAct()
        {
            Await1();
        }
        private void OnFuncStateChange(int obj)
        {
            Await1();
        }
        private void OnStepServerDay()
        {
            Await1();
        }
        IEnumerator Await()
        {
            yield return new WaitForSeconds(0.2f);
            highBtnRecord = null;
            IsBool = true;
        }
        private void Await1()
        {
            highBtnRecord = null;
            IsBool = true;
        }
        private void LateUpdate()
        {
            if (WindowCenter.Instance.CheckOpen<MainInterfaceWin>())
            {
                if (IsBool)
                {
                    if (this.transform.childCount > 0)
                    {
                        highBtnRecord = this.transform.GetChild(0).GetComponent<HighBtnRecord>();
                        isPlayerUIeffect = this.transform.GetChild(0).GetComponent<IsPlayerUIeffect>();
                    }
                    IsBool = false;
                }
                if (highBtnRecord != null)
                {
                    if (!highBtnRecord.IsNagaaki != m_IsplayAnimator)
                    {
                        m_IsplayAnimator = !highBtnRecord.IsNagaaki;
                    }
                }
            }
        }
        private void OnDisable()
        {
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
            hostModel.TreasureFindHostCompleteAct -= TreasureFindHostCompleteAct;
            osGiftModel.OnOSGiftStateChange -= OnOSGiftStateChange;
            RedpointCenter.Instance.redpointValueChangeEvent -= UpdateRedpoint;
            TimeUtility.OnServerOpenDayRefresh -= OnStepServerDay;
            OpenServerActivityCenter.Instance.openServerActivityStateChange -= OpenServerActivityStateChange;
            WindowCenter.Instance.windowAfterOpenEvent -= windowAfterOpenEvent;
            OperationTimeHepler.Instance.operationStartEvent -= operationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent -= operationEndEvent;
            highBtnRecord = null;
            IsBool = true;
        }
        public bool IsplayAnimator
        {
            get { return m_IsplayAnimator; }
            set { m_IsplayAnimator = value; }
        }
        public CanvasGroup CanvasGroup
        {
            get { return m_CanvasGroup; }
            set { m_CanvasGroup = value; }
        }
        public void FadeOut()//出现
        {
            if (m_IsplayAnimator && AnimatorPlayName.Count > 0)
            {
                m_Animator.Play(AnimatorPlayName[0]);
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.IsStarPlayUieffect();
                    }
                }
            }
        }
        public void FadeIn()//消失
        {
            if (m_IsplayAnimator && AnimatorPlayName.Count > 0)
            {
                m_Animator.Play(AnimatorPlayName[1]);
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.GetIsPlayUieffect();
                    }
                }
            }
        }
        public void PositionNow()//立刻出现
        {
            if (AnimatorPlayName.Count > 0)
            {
                if (this.gameObject.activeInHierarchy)
                {
                    m_Animator.Play(AnimatorPlayName[0], 0, 1);
                }
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.IsStarPlayUieffect();
                    }
                }
            }
        }
        public void ImmediatelyDisappear()//立刻消失
        {
            if (m_IsplayAnimator && AnimatorPlayName.Count > 0)
            {
                m_Animator.Play(AnimatorPlayName[1], 0, 1);
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.GetIsPlayUieffect();
                    }
                }
            }
        }
    }
}
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, April 11, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using System;
using Snxxz.UI;
//顶层控制动画播放
namespace Snxxz.UI
{
    public class TopAnimationPlay : MonoBehaviour
    {
        [SerializeField] Animator m_Animator;
        [SerializeField] bool m_IsplayAnimator = false;
        [SerializeField] CanvasGroup m_CanvasGroup;
        [SerializeField] List<string> AnimatorPlayName = new List<string>();
        private bool IsBool = true;
        IsPlayerUIeffect isPlayerUIeffect;
        HighBtnRecord highBtnRecord;
        TreasureFindHostModel hostModel { get { return ModelCenter.Instance.GetModel<TreasureFindHostModel>(); } }
        OSGiftModel osGiftModel { get { return ModelCenter.Instance.GetModel<OSGiftModel>(); } }
        LimitedTimePackageItemClassModel limitedTimePackageItemModel { get { return ModelCenter.Instance.GetModel<LimitedTimePackageItemClassModel>(); } }
        ImpactRankModel impactRankModel { get { return ModelCenter.Instance.GetModel<ImpactRankModel>(); } }
        private void OnEnable()
        {
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
            hostModel.TreasureFindHostCompleteAct += TreasureFindHostCompleteAct;
            RedpointCenter.Instance.redpointValueChangeEvent += UpdateRedpoint;
            TimeUtility.OnServerOpenDayRefresh += OnStepServerDay;
            OpenServerActivityCenter.Instance.openServerActivityStateChange += OpenServerActivityStateChange;
            WindowCenter.Instance.windowAfterOpenEvent += windowAfterOpenEvent;
            OperationTimeHepler.Instance.operationStartEvent += operationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent += operationEndEvent;
            limitedTimePackageItemModel.UpdateLimitedTimePackageItem += UpdateLimitedTimePackageItem;
            impactRankModel.inImpactRankUpdate += InImpactRankUpdate;
        }
        private void InImpactRankUpdate()
        {
            Await1();
        }
        private void operationStartEvent(Operation arg1, int arg2)
        {
            if (arg1 == Operation.FairyCeremony)
            {
                Await1();
            }
        }
        private void operationEndEvent(Operation arg1, int arg2)
        {
            if ( arg1 == Operation.FairyCeremony)
            {
                Await1();
            }
        }
        private void windowAfterOpenEvent(Window obj)
        {
            if (obj as MainInterfaceWin)
            {
                Await1();
            }
        }
        private void OpenServerActivityStateChange()
        {
            Await1();
        }
        private void UpdateRedpoint(int redPointID)
        {
            if (redPointID == 201 || redPointID == 210)
            {
                Await1();
            }
        }
        private void OnOSGiftStateChange()
        {
            Await1();
        }
        private void TreasureFindHostCompleteAct()
        {
            Await1();
        }
        private void OnFuncStateChange(int obj)
        {
            Await1();
        }
        private void OnStepServerDay()
        {
            Await1();
        }
        private void UpdateLimitedTimePackageItem()
        {
            Await1();
        }
        IEnumerator Await()
        {
            yield return new WaitForSeconds(0.2f);
            highBtnRecord = null;
            IsBool = true;
        }
        private void Await1()
        {
            highBtnRecord = null;
            IsBool = true;
        }
        private void LateUpdate()
        {
            if (WindowCenter.Instance.IsOpen<MainInterfaceWin>())
            {
                if (IsBool)
                {
                    if (this.transform.childCount > 0)
                    {
                        highBtnRecord = this.transform.GetChild(0).GetComponent<HighBtnRecord>();
                        isPlayerUIeffect = this.transform.GetChild(0).GetComponent<IsPlayerUIeffect>();
                    }
                    IsBool = false;
                }
                if (highBtnRecord != null)
                {
                    if (!highBtnRecord.IsNagaaki != m_IsplayAnimator)
                    {
                        m_IsplayAnimator = !highBtnRecord.IsNagaaki;
                    }
                }
            }
        }
        private void OnDisable()
        {
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
            hostModel.TreasureFindHostCompleteAct -= TreasureFindHostCompleteAct;
            RedpointCenter.Instance.redpointValueChangeEvent -= UpdateRedpoint;
            TimeUtility.OnServerOpenDayRefresh -= OnStepServerDay;
            OpenServerActivityCenter.Instance.openServerActivityStateChange -= OpenServerActivityStateChange;
            WindowCenter.Instance.windowAfterOpenEvent -= windowAfterOpenEvent;
            OperationTimeHepler.Instance.operationStartEvent -= operationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent -= operationEndEvent;
            limitedTimePackageItemModel.UpdateLimitedTimePackageItem -= UpdateLimitedTimePackageItem;
            impactRankModel.inImpactRankUpdate -= InImpactRankUpdate;
            highBtnRecord = null;
            IsBool = true;
        }
        public bool IsplayAnimator
        {
            get { return m_IsplayAnimator; }
            set { m_IsplayAnimator = value; }
        }
        public CanvasGroup CanvasGroup
        {
            get { return m_CanvasGroup; }
            set { m_CanvasGroup = value; }
        }
        public void FadeOut()//出现
        {
            if (m_IsplayAnimator && AnimatorPlayName.Count > 0)
            {
                m_Animator.Play(AnimatorPlayName[0]);
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.StartPlayUIEffect();
                    }
                }
            }
        }
        public void FadeIn()//消失
        {
            if (m_IsplayAnimator && AnimatorPlayName.Count > 0)
            {
                m_Animator.Play(AnimatorPlayName[1]);
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.ObtainPlayUIEffect();
                    }
                }
            }
        }
        public void PositionNow()//立刻出现
        {
            if (AnimatorPlayName.Count > 0)
            {
                if (this.gameObject.activeInHierarchy)
                {
                    m_Animator.Play(AnimatorPlayName[0], 0, 1);
                }
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.StartPlayUIEffect();
                    }
                }
            }
        }
        public void ImmediatelyDisappear()//立刻消失
        {
            if (m_IsplayAnimator && AnimatorPlayName.Count > 0)
            {
                m_Animator.Play(AnimatorPlayName[1], 0, 1);
                if (this.transform.childCount > 0)
                {
                    if (isPlayerUIeffect != null)
                    {
                        isPlayerUIeffect.ObtainPlayUIEffect();
                    }
                }
            }
        }
    }
}