少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, December 21, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
 
namespace vnxbqy.UI
{
 
    public class RoleInformation : MonoBehaviour
    {
        [SerializeField] AvatarCell avatarCell;
        [SerializeField] Text m_LVText;//角色等级
        [SerializeField] Image m_Shield;//护盾条
        [SerializeField] TextEx m_ShieldValue;//护盾值
        [SerializeField] Text m_NameInformationText;//角色信息
        [SerializeField] Image m_HPSlider;//血条 
        [SerializeField] Text m_HpNumber;//血量
        [SerializeField] Button m_BuffButton;//Buff
        [SerializeField] Text m_BuffNumber;//buff数量
        [SerializeField] Image m_realmImg;//等级
        public Button BuffButton
        {
            get { return m_BuffButton; }
            set { m_BuffButton = value; }
        }
        public Text BuffNumber
        {
            get { return m_BuffNumber; }
            set { m_BuffNumber = value; }
        }
 
        public void SetHeroHead(int playerId,int face,int facePic,int job)//关于人物头像的赋值
        {
            avatarCell.InitUI(AvatarHelper.GetAvatarModel(playerId, face, facePic, job));
        }
 
        public void SetHeroLvAndName(int Lv, string Name)//设置等级和角色名称
        {
            m_LVText.text = Lv.ToString();
            m_NameInformationText.text = Name;
        }
        
 
        public void SetHeroLvAndNameLV(int Lv, string Name,int realmLv)//设置等级和角色名称
        {
            m_LVText.text = Lv.ToString();
            m_NameInformationText.text = Name;           
            RealmConfig presentCfg = RealmConfig.Get(realmLv);
            if (realmLv > 0 && presentCfg != null)
            {
                m_realmImg.SetActive(true);
                m_realmImg.SetSprite(presentCfg.Img);
                m_realmImg.SetNativeSize();
            }
            else
            {
                m_realmImg.SetActive(false);
            }
        }
        public void SetShieldNumber(int Max, int Now)//设置角色护盾属性值
        {
            if (Max != 0)
            {
                float fillAmount = (float)Math.Round((double)Now / Max, 2, MidpointRounding.AwayFromZero);
                m_Shield.fillAmount = fillAmount;
                m_ShieldValue.text = StringUtility.Contact(Now, "/", Max);
            }
            else
            {
                m_Shield.fillAmount = 1;
                m_ShieldValue.text = StringUtility.Contact(0, "/", 0);
            }
        }
 
        public void SetHeroHP(ulong MaxHp, ulong NowHp)//设置角色Hp值
        {
            m_HpNumber.text = NowHp.ToString() + "/" + MaxHp.ToString();
            if (MaxHp > 0)
            {
                m_HPSlider.fillAmount = (float)Math.Round((float)NowHp / MaxHp, 2, MidpointRounding.AwayFromZero);//血条的初始化
            }
            else
            {
                m_HPSlider.fillAmount = 1f;
            }
        }
    }
 
}