using vnxbqy.UI;
|
using System;
|
using System.Globalization;
|
using UnityEngine;
|
|
public class ChallengeDemonKingInfoCell : CellView
|
{
|
[SerializeField] TextEx txtInfo1;
|
[SerializeField] TextEx txtInfo2;
|
[SerializeField] TextEx txtInfo3;
|
ChallengeDemonKingModel challengeDemonKingModel { get { return ModelCenter.Instance.GetModel<ChallengeDemonKingModel>(); } }
|
|
public void Display(int index, CellView cell)
|
{
|
bool isAloneLine = index <= PlayerPropertyConfig.GetShowDict()[1].Count; //只有类型1是一整列的,反之分两列
|
txtInfo1.SetActive(isAloneLine);
|
txtInfo2.SetActive(!isAloneLine);
|
txtInfo3.SetActive(!isAloneLine);
|
//txtInfo1.text = challengeDemonKingModel.GetShowAttribute(challengeDemonKingModel.showNpcID, cell.info.Value.infoInt1);
|
//txtInfo2.text = challengeDemonKingModel.GetShowAttribute(challengeDemonKingModel.showNpcID, cell.info.Value.infoInt1);
|
//txtInfo3.text = challengeDemonKingModel.GetShowAttribute(challengeDemonKingModel.showNpcID, cell.info.Value.infoInt2);
|
txtInfo1.text = GetShowAttribute(cell.info.Value.infoInt1, GetEnemyAttributeValue(challengeDemonKingModel.showNpcID, cell.info.Value.infoInt1));
|
txtInfo2.text = GetShowAttribute(cell.info.Value.infoInt1, GetEnemyAttributeValue(challengeDemonKingModel.showNpcID, cell.info.Value.infoInt1));
|
txtInfo3.text = GetShowAttribute(cell.info.Value.infoInt2, GetEnemyAttributeValue(challengeDemonKingModel.showNpcID, cell.info.Value.infoInt2));
|
}
|
|
//传入属性id 自动根据属性类型决定后面加不加%
|
string GetShowAttribute(int id, long value)
|
{
|
if (id == 0 || !PlayerPropertyConfig.GetKeys().Contains(id.ToString()))
|
return "";
|
return StringUtility.Contact(PlayerPropertyConfig.Get(id).Name, " ", PlayerPropertyConfig.GetValueDescription(id, value));
|
}
|
|
//获取抢夺者当前属性的值
|
long GetEnemyAttributeValue(int npcid,int id)
|
{
|
//传入表格中不存在的id
|
if (id == 0 || !PlayerPropertyConfig.GetKeys().Contains(id.ToString()))
|
return 0;
|
if (!Enum.IsDefined(typeof(PropertyType), id))
|
return 0;
|
PropertyType enumValue = (PropertyType)id;
|
Debug.Log($"GetPropertyNpcValue npcid {npcid} id {id} Value {(long)UIHelper.GetPropertyNpcValue(npcid, enumValue)}");
|
return (long)UIHelper.GetPropertyNpcValue(npcid, enumValue);
|
}
|
}
|