using Snxxz.UI;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using System;
|
|
|
namespace EnhancedUI.EnhancedScroller
|
{
|
public class RuneBreakCell : ScrollerUI
|
{
|
[SerializeField] List<RectTransform> m_Runes;
|
[SerializeField] List<Button> m_RuneBtns;
|
[SerializeField] List<Image> m_RuneIcons;
|
[SerializeField] List<Text> m_RuneNameTxts;
|
[SerializeField] List<Text> m_RuneAttrTxts;
|
[SerializeField] List<Image> m_RuneSelects;
|
|
RuneModel m_Model;
|
RuneModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RuneModel>());
|
}
|
}
|
public override void Refresh(CellView cell)
|
{
|
for (int i = 0; i < 4; i++)
|
{
|
int index = cell.index * 4 + i;
|
int _row = i;
|
if (index >= model.runeBreakList.Count)
|
{
|
m_Runes[i].gameObject.SetActive(false);
|
continue;
|
}
|
else
|
{
|
m_Runes[i].gameObject.SetActive(true);
|
}
|
RuneData data = model.runeBreakList[index];
|
m_RuneBtns[i].onClick.RemoveAllListeners();
|
m_RuneBtns[i].onClick.AddListener(() =>
|
{
|
OnClickRuneBreakItem(index, _row);
|
});
|
ItemConfig _itemCfg = ItemConfig.Get(data.id);
|
if (_itemCfg == null)
|
{
|
DebugEx.LogError("不存在的物品id" + data.id);
|
return;
|
}
|
if (_itemCfg.Type == RuneModel.RUNE_TYPE)
|
{
|
m_RuneNameTxts[i].text =StringUtility.Contact(_itemCfg.ItemName," lv.",data.lv);
|
m_RuneNameTxts[i].color = UIHelper.GetUIColor(_itemCfg.ItemColor, true);
|
m_RuneAttrTxts[i].text = model.GetRuneAttrStr(data.id, data.lv);
|
}
|
else if (_itemCfg.Type == RuneModel.RUNE_CREAMTYPE)
|
{
|
m_RuneNameTxts[i].text = _itemCfg.ItemName;
|
m_RuneNameTxts[i].color = UIHelper.GetUIColor(_itemCfg.ItemColor, true);
|
m_RuneAttrTxts[i].text = Language.Get("L1079", _itemCfg.EffectValueA1);
|
}
|
m_RuneIcons[i].SetSprite(_itemCfg.IconKey);
|
if (model.runeBreakEnableDict.ContainsKey(index) && model.runeBreakEnableDict[index])
|
{
|
if (!model.runeBreakRects.Contains(m_Runes[i]))
|
{
|
model.runeBreakRects.Add(m_Runes[i]);
|
}
|
m_RuneSelects[i].gameObject.SetActive(true);
|
}
|
else
|
{
|
if (model.runeBreakRects.Contains(m_Runes[i]))
|
{
|
model.runeBreakRects.Remove(m_Runes[i]);
|
}
|
m_RuneSelects[i].gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void OnClickRuneBreakItem(int _index,int _row)
|
{
|
model.runeBreakEnableDict[_index] = !model.runeBreakEnableDict[_index];
|
RuneData data = model.runeBreakList[_index];
|
ItemConfig item = ItemConfig.Get(data.id);
|
if (model.runeBreakEnableDict[_index])
|
{
|
if (!model.runeBreakRects.Contains(m_Runes[_row]))
|
{
|
model.runeBreakRects.Add(m_Runes[_row]);
|
}
|
m_RuneSelects[_row].gameObject.SetActive(true);
|
}
|
else
|
{
|
if (model.runeBreakRects.Contains(m_Runes[_row]))
|
{
|
model.runeBreakRects.Remove(m_Runes[_row]);
|
}
|
m_RuneSelects[_row].gameObject.SetActive(false);
|
}
|
model.UpdateBreakRune();
|
}
|
}
|
}
|
|