少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
    }
}