using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
namespace vnxbqy.UI
|
{
|
|
public class FairyTreasureCollect : MonoBehaviour
|
{
|
protected int treasureId = 0;
|
|
[SerializeField] protected Text m_TreasureStory;
|
[SerializeField] protected Button m_GotoGet;
|
[SerializeField] protected Text m_GotoBtnText;
|
[SerializeField] protected RectTransform m_ContainerFight;
|
[SerializeField] protected Text m_FightPower;
|
[SerializeField] protected RectTransform m_ContainerLocked;
|
[SerializeField] protected Text m_LockedDescription;
|
[SerializeField] protected PositionTween m_StoryTween;
|
|
protected TreasureEffectModel treasureEffect
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<TreasureEffectModel>();
|
}
|
}
|
|
protected TreasureModel model
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<TreasureModel>();
|
}
|
}
|
|
protected Treasure treasure;
|
|
protected virtual void Awake()
|
{
|
}
|
|
protected virtual void GotoGet()
|
{
|
|
}
|
|
public virtual void Display(int _treasureId, bool _tween = false)
|
{
|
treasureId = _treasureId;
|
|
m_GotoGet.onClick.RemoveAllListeners();
|
m_GotoGet.onClick.AddListener(GotoGet);
|
|
if (!model.TryGetTreasure(_treasureId, out treasure))
|
{
|
return;
|
}
|
|
if (_tween && m_StoryTween.gameObject.activeInHierarchy)
|
{
|
m_StoryTween.Play();
|
}
|
else
|
{
|
m_StoryTween.SetEndState();
|
}
|
|
m_GotoGet.SetActive(treasure.state == TreasureState.Locked);
|
m_ContainerFight.SetActive(treasure.state == TreasureState.Collected);
|
m_ContainerLocked.SetActive(treasure.state == TreasureState.Locked);
|
|
var config = TreasureConfig.Get(_treasureId);
|
m_TreasureStory.text = config.Story;
|
|
model.treasureStateChangeEvent += OnTreasureStateChange;
|
}
|
|
protected virtual void OnTreasureStateChange(int _id)
|
{
|
if (_id != treasureId)
|
{
|
return;
|
}
|
m_GotoGet.SetActive(treasure.state == TreasureState.Locked);
|
m_ContainerFight.SetActive(treasure.state == TreasureState.Collected);
|
m_ContainerLocked.SetActive(treasure.state == TreasureState.Locked);
|
}
|
|
public virtual void Dispose()
|
{
|
m_GotoGet.onClick.RemoveAllListeners();
|
model.treasureStateChangeEvent -= OnTreasureStateChange;
|
}
|
}
|
}
|
|