57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PvpTeamRoleInfoItem : UIItemBase {
|
|
|
|
public Material _GrayMaterial;
|
|
public Image _BG;
|
|
public Sprite _RedBGIcon;
|
|
public Sprite _BlueBGIcon;
|
|
public Image _HeadIcon;
|
|
public Slider _HpSlider;
|
|
public GameObject _DeadIcon;
|
|
//public Text _RoleName;
|
|
//public Text _HpText;
|
|
//public Text _RoleLevel;
|
|
|
|
public long _Guid;
|
|
HonorBattlefieldMatchMemberInfo info = null;
|
|
public override void Show(Hashtable hash)
|
|
{
|
|
base.Show(hash);
|
|
info = (HonorBattlefieldMatchMemberInfo)hash["InitObj"];
|
|
_BG.overrideSprite = info.Camp == 6 ? _BlueBGIcon : _RedBGIcon;
|
|
InitItemInfo();
|
|
}
|
|
|
|
public void InitItemInfo()
|
|
{
|
|
_Guid = info.Guid;
|
|
LoadAssetBundle.Instance.SetImageSprite(_HeadIcon, GCGame.Utils.GetProfessionSpriteName(info.Job));
|
|
_HeadIcon.material = _HeadIcon.defaultMaterial;
|
|
_BG.material = _BG.defaultMaterial;
|
|
_HpSlider.value = (float)info.Hp / (float)info.MaxHp;
|
|
_DeadIcon.SetActive(info.Hp <= 0);
|
|
}
|
|
|
|
public void RefreshItemInfo(HonorBattlefieldMatchMemberInfo _Info)
|
|
{
|
|
info = _Info;
|
|
// _HpText.text = info.Hp + "/" + info.MaxHp;
|
|
if (_DeadIcon.gameObject.activeInHierarchy)
|
|
_DeadIcon.SetActive(false);
|
|
_HpSlider.value = (float)info.Hp / (float)info.MaxHp;
|
|
if (info.Hp <= 0)
|
|
{
|
|
if(!_DeadIcon.gameObject.activeInHierarchy)
|
|
_DeadIcon.SetActive(true);
|
|
_HeadIcon.material = _GrayMaterial;
|
|
_HeadIcon.SetMaterialDirty();
|
|
_BG.material = _GrayMaterial;
|
|
_BG.SetMaterialDirty();
|
|
}
|
|
}
|
|
}
|