using Snxxz.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class GemEquipPlate : MonoBehaviour
|
{
|
[SerializeField] ItemCell m_ItemCell;
|
[SerializeField] Image m_SelectImg;
|
[SerializeField] Image m_EquipBg;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
[SerializeField] List<GameObject> m_GemHoles;
|
[SerializeField] List<Image> m_Gems;
|
[SerializeField] Text m_EquipNameTxt;
|
[SerializeField] Text m_ContentTxt;
|
[SerializeField] Text m_TipTxt;
|
[SerializeField] Button m_EquipBtn;
|
|
public int EquipPos { get; private set; }
|
|
GemModel m_Model;
|
GemModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<GemModel>());
|
}
|
}
|
|
VipModel m_VipModel;
|
VipModel vipModel
|
{
|
get
|
{
|
return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>());
|
}
|
}
|
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
private void Awake()
|
{
|
m_EquipBtn.onClick.AddListener(OnEquipPlateClick);
|
}
|
|
public void Refresh(int _pos)
|
{
|
EquipPos = _pos;
|
ItemModel _itemModel = playerPack.GetItemModelByIndex(PackType.Equip,_pos);
|
if (_itemModel != null)
|
{
|
ItemConfig cfg = ItemConfig.Get(_itemModel.itemId);
|
m_EquipNameTxt.gameObject.SetActive(true);
|
m_EquipNameTxt.text = UIHelper.AppendStringColor(cfg.ItemColor, cfg.ItemName, true);
|
m_ItemCell.gameObject.SetActive(true);
|
m_ItemCell.Init(_itemModel);
|
m_ContentTxt.gameObject.SetActive(false);
|
m_TipTxt.gameObject.SetActive(false);
|
}
|
else
|
{
|
m_ItemCell.gameObject.SetActive(false);
|
for (int i = 0; i < m_GemHoles.Count; i++)
|
{
|
m_GemHoles[i].gameObject.SetActive(false);
|
}
|
m_ContentTxt.gameObject.SetActive(true);
|
var equipPartName = string.Empty;
|
if (_pos - 1 < model.equipPartNames.Length)
|
{
|
equipPartName = model.equipPartNames[_pos - 1];
|
}
|
m_ContentTxt.text = Language.Get("L1076", equipPartName);
|
m_TipTxt.gameObject.SetActive(true);
|
m_TipTxt.text = Language.Get("L1067");
|
m_EquipNameTxt.gameObject.SetActive(false);
|
}
|
RefreshGem();
|
m_Redpoint.redpointId = GemModel.GEM_REDPOINT * GemModel.REDPOINT_INTERVAL + _pos;
|
}
|
|
private static Queue<uint> m_GemIdQueue = new Queue<uint>();
|
public void RefreshGem()
|
{
|
ItemModel _itemModel = playerPack.GetItemModelByIndex(PackType.Equip,EquipPos);
|
if (_itemModel == null)
|
{
|
return;
|
}
|
ItemConfig cfg = ItemConfig.Get(_itemModel.itemId);
|
int holeCnt = 0;
|
m_GemIdQueue.Clear();
|
uint[] stones = PlayerStoneData.Instance.GetStoneInfo(EquipPos);
|
if (stones != null && stones.Length > 0)
|
{
|
for (int i = 0; i < 4; i++)
|
{
|
if (stones[i] != 0)
|
{
|
m_GemIdQueue.Enqueue(stones[i]);
|
}
|
}
|
}
|
for (int i = 0; i < 4; i++)
|
{
|
bool openHole = false;
|
if (i < 3)
|
{
|
if (cfg.LV >= model.gemOpenArray[i])
|
{
|
openHole = true;
|
}
|
}
|
else if (i == 3)
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv >= model.gemVipHoleLv && cfg.LV >= model.gemOpenArray[0])
|
{
|
openHole = true;
|
}
|
}
|
m_Gems[i].gameObject.SetActive(m_GemIdQueue.Count > 0);
|
if (m_GemIdQueue.Count > 0)
|
{
|
uint id = m_GemIdQueue.Dequeue();
|
ItemConfig itemCfg = ItemConfig.Get((int)id);
|
if (itemCfg.EffectValueA1 == 1)
|
{
|
m_Gems[i].SetSprite("Member_Online");
|
}
|
else if (itemCfg.EffectValueA1 == 2)
|
{
|
m_Gems[i].SetSprite("Member_Offline");
|
}
|
}
|
if (openHole)
|
{
|
m_GemHoles[holeCnt].gameObject.SetActive(true);
|
holeCnt++;
|
}
|
}
|
for (int i = holeCnt; i < 4; i++)
|
{
|
m_GemHoles[i].SetActive(false);
|
m_Gems[i].gameObject.SetActive(false);
|
}
|
}
|
|
public void SetSelect(bool _select)
|
{
|
m_SelectImg.gameObject.SetActive(_select);
|
}
|
|
private void OnEquipPlateClick()
|
{
|
model.UpdateEquipPlate(EquipPos);
|
}
|
}
|
}
|