FaBaoAttributeWidget.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using GameLogic.Hero;
  2. namespace Fort23.Mono
  3. {
  4. [UIBinding(prefab = "FaBaoAttributeWidget")]
  5. public partial class FaBaoAttributeWidget : UIComponent
  6. {
  7. public FaBaoInfo faBaoInfo;
  8. public int key;
  9. private void Init()
  10. {
  11. }
  12. public override void AddEvent()
  13. {
  14. }
  15. public override void DelEvent()
  16. {
  17. }
  18. public override void AddButtonEvent()
  19. {
  20. }
  21. public void CusomtInit(FaBaoInfo faBaoInfo, int key)
  22. {
  23. this.faBaoInfo = faBaoInfo;
  24. this.key = key;
  25. Text_AttributeName.text = GetAttributeName(key);
  26. Text_AttributeValue.text = faBaoInfo.attriButedIC[key].ToString();
  27. Text_NextAttributeValue.gameObject.SetActive(false);
  28. }
  29. public void StartUpGrad(FaBaoInfo nextFabaoInfo )
  30. {
  31. Text_NextAttributeValue.text = $"+{nextFabaoInfo.attriButedIC[key] - faBaoInfo.attriButedIC[key]}";
  32. Text_NextAttributeValue.gameObject.SetActive(true);
  33. }
  34. public void EndUpGrade()
  35. {
  36. Text_NextAttributeValue.gameObject.SetActive(false);
  37. }
  38. private string GetAttributeName(int type)
  39. {
  40. switch (type)
  41. {
  42. case 1:
  43. return "生命";
  44. case 2:
  45. return "防御";
  46. case 3:
  47. return "攻击";
  48. }
  49. return "";
  50. }
  51. }
  52. }