Files
JJBB/Assets/Project/Script/GUI/Role/RoleViewAttrPair.cs

119 lines
2.9 KiB
C#
Raw Permalink Normal View History

2024-08-23 15:49:34 +08:00
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
using GCGame;
using GCGame.Table;
public class RoleViewAttrPair : UIItemBase
{
public class AttrPair : ICloneable
{
public PropID.PropertyID _PropID;
public int _SubID;
public int _Value1;
public int _Value2;
public int _Value3;
public int _OrgValue;
private bool _ValueIsLong;
public bool ValueIsLong
{
get { return _ValueIsLong; }
set { _ValueIsLong = value; }
}
public long _ValueLong1;
public string GetValue1Str()
{
if (_ValueIsLong)
return _ValueLong1.ToString();
return _Value1.ToString();
}
public string GetValue1PercentageStr()
{
return (_Value1 / 100.0f).ToString() + "%";
}
public AttrPair()
{
}
public AttrPair(PropID.PropertyID prop, int value1, int value2)
{
_PropID = prop;
_Value1 = value1;
_Value2 = value2;
_ValueIsLong = false;
}
public AttrPair(PropID.PropertyID prop, int value1)
{
_PropID = prop;
_Value1 = value1;
_ValueIsLong = false;
}
public AttrPair(PropID.PropertyID prop, long value1)
{
_PropID = prop;
_ValueLong1 = value1;
_ValueIsLong = true;
}
public AttrPair(PropID.PropertyID prop, Games.GlobeDefine.CharacterDefine.PROFESSION subID, int value1)
{
_PropID = prop;
_SubID = (int)subID;
_Value1 = value1;
_ValueIsLong = false;
}
public object Clone()
{
AttrPair newOne = new AttrPair();
newOne._PropID = this._PropID;
newOne._SubID = this._SubID;
newOne._Value1 = this._Value1;
newOne._Value2 = this._Value2;
newOne._Value3 = this._Value3;
newOne._OrgValue = this._OrgValue;
newOne.ValueIsLong = this.ValueIsLong;
newOne._ValueLong1 = this._ValueLong1;
return newOne;
}
}
public Text _AttrText;
public Text _AttrName;
public override void Show(Hashtable hash)
{
base.Show(hash);
var attrPair = (AttrPair)hash["InitObj"];
_InitInfo = attrPair;
SetAttr(attrPair);
}
public void SetAttr(AttrPair attrPair)
{
_AttrName.text = PropID.GetAttrName(attrPair._PropID, attrPair._SubID, attrPair._Value1);
// 如果是对职业的加成伤害,用百分比显示
if(attrPair._PropID == PropID.PropertyID.VOCDAMAGERATE)
{
_AttrText.text = attrPair.GetValue1PercentageStr();
}
else
{
_AttrText.text = attrPair.GetValue1Str();
}
}
}