using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Text;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class EquipGemHoleBehaviour : MonoBehaviour
|
{
|
[SerializeField] Transform m_ContainerUnOpen;
|
[SerializeField] Transform m_ContainerOpened;
|
[SerializeField] Transform m_ContainerInlay;
|
[SerializeField] Transform m_ContainerUnInlay;
|
[SerializeField] Image m_ItemBackground;
|
[SerializeField] Image m_ItemIcon;
|
[SerializeField] Text m_ItemName;
|
[SerializeField] Image m_Bind;
|
[SerializeField] Text m_OpenCondition;
|
[SerializeField] PropertyBehaviour[] m_Propertys;
|
[SerializeField] Text m_GemType;
|
[SerializeField] UIEffect m_Mosaic;
|
[SerializeField] Button m_Inlaid;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
[SerializeField] Image m_SelectImg;
|
|
EquipGemModel model { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
public void DisplayEquipGem(int level, int place, int hole)
|
{
|
var isOpen = model.IsEquipGemHoleOpen(level, place, hole);
|
|
var equipGuid = equipModel.GetEquip( new Int2(level, place));
|
isOpen = string.IsNullOrEmpty(equipGuid) ? false : isOpen;
|
|
m_ContainerOpened.SetActive(isOpen);
|
m_ContainerUnOpen.SetActive(!isOpen);
|
|
m_Inlaid.RemoveAllListeners();
|
|
if (!isOpen)
|
{
|
DisplayOpenCondition(hole);
|
m_Redpoint.redpointId = 0;
|
}
|
m_SelectImg.SetActive(hole == model.SelectHoleIndex);
|
|
if (isOpen)
|
{
|
m_Inlaid.AddListener(() =>
|
{
|
Inlay(level, place, hole);
|
});
|
|
bool inlay = false;
|
int[] equipGems = null;
|
if (model.TryGetEquipGems(level, place, out equipGems))
|
{
|
inlay = hole < equipGems.Length && equipGems[hole] != 0;
|
}
|
|
if (inlay)
|
{
|
DisplayGemBase(equipGems[hole]);
|
DisplayGemProperty(equipGems[hole]);
|
}
|
else
|
{
|
DisplayGemType(place);
|
}
|
|
m_ContainerInlay.SetActive(inlay);
|
m_ContainerUnInlay.SetActive(!inlay);
|
|
EquipGemRedpoint equipGemRedpoint;
|
if (model.TryGetRedpoint(level, place, out equipGemRedpoint))
|
{
|
var holeRedpoint = equipGemRedpoint.GetHoleRedpoint(hole);
|
m_Redpoint.redpointId = holeRedpoint.id;
|
}
|
}
|
}
|
|
void DisplayGemBase(int equipGem)
|
{
|
var config = ItemConfig.Get(equipGem);
|
m_ItemBackground.SetItemBackGround(config.ItemColor, config.QualityEchoType);
|
m_ItemIcon.SetSprite(config.IconKey);
|
m_ItemName.text = config.ItemName;
|
m_Bind.SetActive(false);
|
}
|
|
void DisplayOpenCondition(int hole)
|
{
|
GemHoleCondition condition;
|
if (model.TryGetGemHoleCondition(hole, out condition))
|
{
|
if (condition.vipLevel != 0)
|
{
|
m_OpenCondition.text = Language.Get("GemHole04Unlock", condition.vipLevel);
|
}
|
else
|
{
|
m_OpenCondition.text = Language.Get("L1075", condition.equipStar);
|
}
|
}
|
}
|
|
public void DisplayGemProperty(int equipGem)
|
{
|
foreach (var gem in m_Propertys)
|
{
|
gem.SetActive(false);
|
}
|
//EquipGemWin.DisplayProperty(equipGem, m_Propertys);
|
}
|
|
public void DisplayGemType(int place)
|
{
|
List<int> gemTypes = null;
|
var sb = new StringBuilder();
|
if (model.TryGetGemTypes(place, out gemTypes))
|
{
|
foreach (var type in gemTypes)
|
{
|
GemType gemType;
|
if (model.TryGetGemType(type, out gemType))
|
{
|
sb.Append(gemType.description);
|
sb.Append("\n");
|
}
|
}
|
}
|
m_GemType.text = sb.ToString();
|
}
|
|
public void DisplayLevelUp(bool show)
|
{
|
if (show)
|
{
|
m_Mosaic.Play();
|
}
|
else
|
{
|
m_Mosaic.StopImediatly();
|
}
|
}
|
|
private void Inlay(int level, int place, int hole)
|
{
|
bool inlay = false;
|
int[] equipGems = null;
|
if (model.TryGetEquipGems(level, place, out equipGems))
|
{
|
inlay = hole < equipGems.Length && equipGems[hole] != 0;
|
}
|
if (!inlay)
|
{
|
EquipGemSelectWin.equipHole = hole;
|
EquipGemSelectWin.equipLevel = level;
|
EquipGemSelectWin.equipPlace = place;
|
WindowCenter.Instance.Open<EquipGemSelectWin>();
|
}
|
model.SelectHoleIndex = hole;
|
}
|
}
|
}
|
|