123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 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 "";
- }
- }
- }
|