using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
[XLua.Hotfix]
|
public class GatherSoulHoleBehaviour : MonoBehaviour
|
{
|
[SerializeField] int hole;
|
[SerializeField] RectTransform m_ContainreItem;
|
[SerializeField] RectTransform m_ContainerEquipSign;
|
[SerializeField] RectTransform m_ContainerLock;
|
[SerializeField] RectTransform m_ContaienrRedpoint;
|
[SerializeField] Image m_Icon;
|
[SerializeField] Text m_ItemName;
|
[SerializeField] Text m_Level;
|
[SerializeField] Text m_Condition;
|
[SerializeField] Button m_Func;
|
|
GatheringSoulModel model
|
{
|
get { return ModelCenter.Instance.GetModel<GatheringSoulModel>(); }
|
}
|
|
GatherSoulComposeModel composeModel
|
{
|
get { return ModelCenter.Instance.GetModel<GatherSoulComposeModel>(); }
|
}
|
|
bool existItem = false;
|
|
private void Awake()
|
{
|
m_Func.onClick.AddListener(OnFunc);
|
}
|
|
public void Display()
|
{
|
model.gatherSoulHoleRefresh -= GatherSoulHoleRefresh;
|
model.gatherSoulHoleRefresh += GatherSoulHoleRefresh;
|
|
RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
|
RedpointCenter.Instance.redpointValueChangeEvent += RedpointValueChangeEvent;
|
|
DisplayBase();
|
DisplayRedpoint();
|
}
|
|
void DisplayBase()
|
{
|
bool unlockHole = model.IsHoleUnlock(hole);
|
GatherSoulItem item;
|
bool equiped = model.TryGetItem(hole, out item);
|
m_ContainreItem.gameObject.SetActive(equiped);
|
m_ContainerLock.gameObject.SetActive(!unlockHole);
|
m_ContainerEquipSign.gameObject.SetActive(!equiped && unlockHole);
|
existItem = equiped;
|
if (equiped)
|
{
|
var config = ItemConfig.Get(item.id);
|
m_Icon.SetSprite(config.IconKey);
|
m_ItemName.text = config.ItemName;
|
m_Level.text = item.level.ToString();
|
m_ItemName.color = UIHelper.GetUIColor(config.ItemColor);
|
}
|
if (!unlockHole)
|
{
|
DisplayCondition();
|
}
|
}
|
|
void DisplayCondition()
|
{
|
GatherSoulHoleCondition condition;
|
if (model.TryGetHoleCondition(hole, out condition))
|
{
|
m_Condition.text = Language.Get("GatherSoulHoleOpenCondition", condition.level);
|
}
|
}
|
|
private void OnFunc()
|
{
|
if (!model.IsHoleUnlock(hole))
|
{
|
GatherSoulHoleCondition condition;
|
if (model.TryGetHoleCondition(hole, out condition))
|
{
|
SysNotifyMgr.Instance.ShowTip("GatherSoulHoleOpenCondition", condition.level);
|
}
|
}
|
else
|
{
|
GatherSoulItem item;
|
if (model.TryGetItem(hole, out item))
|
{
|
ItemTipUtility.ShowGatherSoul(PackType.InterimPack, hole);
|
}
|
else
|
{
|
if (!model.ContainsEquipSoul(hole))
|
{
|
SysNotifyMgr.Instance.ShowTip("NoneSoulSatisfyEquip");
|
}
|
else
|
{
|
GatherSoulEquipListWin.selectHole = hole;
|
WindowCenter.Instance.Open<GatherSoulEquipListWin>();
|
}
|
}
|
}
|
}
|
|
private void RedpointValueChangeEvent(int id)
|
{
|
if (id == model.equipRedpoint.id || id == model.levelUpRedpoint.id
|
|| id == model.replaceRedpoint.id)
|
{
|
DisplayRedpoint();
|
}
|
}
|
|
void DisplayRedpoint()
|
{
|
bool requireRedpoint = (model.equipRedpoint.state == RedPointState.Simple && model.equipRedpointHole == hole)
|
|| (model.levelUpRedpoint.state == RedPointState.Simple && model.levelUpRedpointHole == hole);
|
m_ContaienrRedpoint.gameObject.SetActive(requireRedpoint);
|
}
|
|
private void GatherSoulHoleRefresh(int hole)
|
{
|
if (this.hole == hole)
|
{
|
bool exist = existItem;
|
DisplayBase();
|
if (!exist && existItem && model.serverInited)
|
{
|
EffectMgr.Instance.PlayUIEffect(3079, 2100, transform, false);
|
}
|
}
|
}
|
|
public void Dispose()
|
{
|
model.gatherSoulHoleRefresh -= GatherSoulHoleRefresh;
|
RedpointCenter.Instance.redpointValueChangeEvent -= RedpointValueChangeEvent;
|
}
|
}
|
}
|