using GameLogic.Hero; using UnityEngine; namespace Fort23.Mono { [UIBinding(prefab = "FaBaoAttributeWidget")] public partial class FaBaoAttributeWidget : UIComponent { public FaBaoInfo faBaoInfo; public int key; private void Init() { } public override void AddEvent() { } public override void DelEvent() { } public override void AddButtonEvent() { } public void CusomtInit(FaBaoInfo faBaoInfo, int key) { this.faBaoInfo = faBaoInfo; this.key = key; Text_AttributeName.text = GetAttributeName(key); Text_AttributeValue.text = faBaoInfo.attriButedIC[key].ToString(); Text_NextAttributeValue.gameObject.SetActive(false); } public void StartUpGrad(FaBaoInfo nextFabaoInfo) { Text_NextAttributeValue.text = $"+{nextFabaoInfo.attriButedIC[key] - faBaoInfo.attriButedIC[key]}"; Text_NextAttributeValue.gameObject.SetActive(true); Text_NextAttributeValue.color = new Color32(15,241,150,255); } public void EndUpGrade() { Text_NextAttributeValue.gameObject.SetActive(false); } public void StartBj(FaBaoInfo nextFabaoInfo) { if (nextFabaoInfo == null || !nextFabaoInfo.attriButedIC.ContainsKey(key) || nextFabaoInfo.attriButedIC[key] < faBaoInfo.attriButedIC[key]) { long nextValue = nextFabaoInfo.attriButedIC.ContainsKey(key) ? nextFabaoInfo.attriButedIC[key] : 0; Text_NextAttributeValue.text = $"+{ faBaoInfo.attriButedIC[key] - nextValue}"; Text_NextAttributeValue.gameObject.SetActive(true); Text_NextAttributeValue.color = new Color32(15,241,150,255); // Icon_Bj.gameObject.SetActive(true); // Icon_Bj.icon_name = "dec_fbjia"; } else if (nextFabaoInfo.attriButedIC[key] >faBaoInfo.attriButedIC[key]) { long nextValue = nextFabaoInfo.attriButedIC.ContainsKey(key) ? nextFabaoInfo.attriButedIC[key] : 0; if (nextValue == 0) { Text_NextAttributeValue.text = $"{nextValue - faBaoInfo.attriButedIC[key]}"; } else { Text_NextAttributeValue.text = $"-{nextValue - faBaoInfo.attriButedIC[key]}"; } Text_NextAttributeValue.gameObject.SetActive(true); Text_NextAttributeValue.color = new Color32(235,110,109,255); // Icon_Bj.gameObject.SetActive(true); // Icon_Bj.icon_name = "dec_fbjian"; } else { Text_NextAttributeValue.gameObject.SetActive(false); // Icon_Bj.gameObject.SetActive(false); } } public void EndBj() { Icon_Bj.gameObject.SetActive(false); } private string GetAttributeName(int type) { switch (type) { case 1: return "生命"; case 2: return "防御"; case 3: return "攻击"; } return ""; } } }