using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class EquipGemSelectBehaviour : CellView
|
{
|
[SerializeField] Transform m_ContainerEquip;
|
[SerializeField] Transform m_ContainerUnEquip;
|
[SerializeField] Text m_EquipPlaceName;
|
[SerializeField] Transform m_ContainerSelect;
|
[SerializeField] ItemCell m_Item;
|
[SerializeField] Text m_EquipStar;
|
[SerializeField] Text m_ItemName;
|
[SerializeField] TinyGem[] m_TinyGems;
|
[SerializeField] Button m_Select;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
|
EquipGemModel model { get { return ModelCenter.Instance.GetModel<EquipGemModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
int equipLevel = 0;
|
int equipPlace = 0;
|
string equipGuid = string.Empty;
|
|
public void Display(int level, int place)
|
{
|
this.equipLevel = level;
|
this.equipPlace = place;
|
|
var equipSet = equipModel.GetEquipSet(equipLevel);
|
equipGuid = equipSet.GetEquip(equipPlace);
|
|
var equiped = !string.IsNullOrEmpty(equipGuid);
|
m_ContainerEquip.SetActive(equiped);
|
m_ContainerUnEquip.SetActive(!equiped);
|
|
m_Select.SetListener(() => { model.selectEquipPlace = equipPlace; });
|
|
if (equiped)
|
{
|
DisplayBase();
|
DisplayGems();
|
|
EquipGemRedpoint equipGemRedpoint;
|
if (model.TryGetRedpoint(level, place, out equipGemRedpoint))
|
{
|
m_Redpoint.redpointId = equipGemRedpoint.repoint.id;
|
}
|
}
|
else
|
{
|
m_Redpoint.redpointId = 0;
|
DisplayUnEquip();
|
}
|
|
m_ContainerSelect.SetActive(model.selectEquipPlace == equipPlace);
|
}
|
|
void DisplayBase()
|
{
|
var item = packModel.GetItemByGuid(equipGuid);
|
if (item != null)
|
{
|
m_Item.Init(item);
|
m_Item.button.enabled = false;
|
m_ItemName.text = item.config.ItemName;
|
m_ItemName.color = UIHelper.GetUIColor(item.config.ItemColor, true);
|
|
var maxStar = EquipStarModel.GetMaxStarLevel(item.config.ItemColor, item.config.LV);
|
var starLevel = Mathf.Min(maxStar, equipStarModel.GetStarLevel(new Int2(equipLevel, equipPlace)));
|
m_EquipStar.text = starLevel == 0 ? string.Empty : Language.Get("EquipStarLevel", starLevel);
|
}
|
}
|
|
void DisplayGems()
|
{
|
int[] equipGems = null;
|
model.TryGetEquipGems(equipLevel, equipPlace, out equipGems);
|
for (int i = 0; i < m_TinyGems.Length; i++)
|
{
|
bool isOpen = model.IsEquipGemHoleOpen(equipLevel, equipPlace, i);
|
m_TinyGems[i].SetActive(isOpen);
|
if (isOpen)
|
{
|
var id = (equipGems != null && i < equipGems.Length) ? equipGems[i] : 0;
|
m_TinyGems[i].Set(id);
|
}
|
}
|
}
|
|
void DisplayUnEquip()
|
{
|
if (GeneralDefine.equipPlaceNameDict.ContainsKey(equipPlace))
|
{
|
m_EquipPlaceName.text = Language.Get("L1076", GeneralDefine.equipPlaceNameDict[equipPlace]);
|
}
|
}
|
}
|
}
|
|