//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, October 12, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
using System;
|
|
namespace vnxbqy.UI
|
{
|
|
public class TreasureExhibitionBehaviour : MonoBehaviour
|
{
|
[SerializeField] UIEffect m_EntranceEffect;
|
[SerializeField] UIEffect m_NewTreasureEffect;
|
|
Window m_Parent;
|
Window parent { get { return m_Parent ?? (m_Parent = this.GetComponentInParent<Window>()); } }
|
|
TreasureModel model { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
|
|
private void Awake()
|
{
|
ShowCollectingTreasure();
|
WindowCenter.Instance.windowBeforeOpenEvent += OnWindowPreOpen;
|
WindowCenter.Instance.windowAfterOpenEvent += OnWindowAfterOpen;
|
model.collectingTreasureChangeEvent += OnCollectingTreasureChange;
|
EffectToFaBaoWin.EffectToFaBaoEvent += EffectToFaBaoEvent;
|
model.treasureStateChangeEvent += TreasureStateChangeEvent;
|
WindowCenter.Instance.windowAfterCloseEvent += WindowAfterCloseEvent;
|
}
|
|
private void OnDestroy()
|
{
|
WindowCenter.Instance.windowBeforeOpenEvent -= OnWindowPreOpen;
|
WindowCenter.Instance.windowAfterOpenEvent -= OnWindowAfterOpen;
|
model.collectingTreasureChangeEvent -= OnCollectingTreasureChange;
|
EffectToFaBaoWin.EffectToFaBaoEvent -= EffectToFaBaoEvent;
|
model.treasureStateChangeEvent -= TreasureStateChangeEvent;
|
WindowCenter.Instance.windowAfterCloseEvent -= WindowAfterCloseEvent;
|
}
|
|
private void OnWindowPreOpen(Window _window)
|
{
|
if (_window != parent)
|
{
|
return;
|
}
|
|
ShowCollectingTreasure();
|
}
|
|
private void WindowAfterCloseEvent(Window _window)
|
{
|
if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
|
{
|
return;
|
}
|
if (_window is TreasureSelectWin || _window is TreasureBaseWin)
|
{
|
if (!m_NewTreasureEffect.IsPlaying)
|
{
|
m_EntranceEffect.Play();
|
}
|
}
|
}
|
|
private void OnWindowAfterOpen(Window _window)
|
{
|
if (_window != parent)
|
{
|
return;
|
}
|
|
if (!m_NewTreasureEffect.IsPlaying)
|
{
|
m_EntranceEffect.Play();
|
}
|
}
|
|
private void OnCollectingTreasureChange(TreasureCategory _category)
|
{
|
ShowCollectingTreasure();
|
}
|
|
private void ShowCollectingTreasure()
|
{
|
m_NewTreasureEffect.StopImediatly();
|
var treasureId = 0;
|
if (model.treasureCollectingShowId != 0)
|
{
|
treasureId = model.collectingHuman;
|
m_NewTreasureEffect.Play();
|
if (m_EntranceEffect.IsPlaying)
|
{
|
m_EntranceEffect.StopImediatly();
|
}
|
}
|
}
|
|
private void EffectToFaBaoEvent()
|
{
|
var treasureId = 0;
|
if ((treasureId = model.IsRequireUnlockAnim(TreasureCategory.Human)) != 0)
|
{
|
model.treasureCollectingShowId = treasureId;
|
ShowCollectingTreasure();
|
}
|
}
|
|
private void TreasureStateChangeEvent(int _id)
|
{
|
if (model.treasureCollectingShowId == _id)
|
{
|
model.treasureCollectingShowId = 0;
|
ShowCollectingTreasure();
|
}
|
}
|
}
|
|
}
|
|
|
|