FaBaoAttributeWidget.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using GameLogic.Hero;
  2. using UnityEngine;
  3. using Utility;
  4. namespace Fort23.Mono
  5. {
  6. [UIBinding(prefab = "FaBaoAttributeWidget")]
  7. public partial class FaBaoAttributeWidget : UIComponent
  8. {
  9. public FaBaoInfo faBaoInfo;
  10. public int key;
  11. private void Init()
  12. {
  13. }
  14. public override void AddEvent()
  15. {
  16. }
  17. public override void DelEvent()
  18. {
  19. }
  20. public override void AddButtonEvent()
  21. {
  22. }
  23. public void CusomtInit(FaBaoInfo faBaoInfo, int key)
  24. {
  25. this.faBaoInfo = faBaoInfo;
  26. this.key = key;
  27. Text_AttributeName.text = GetAttributeName(key);
  28. Text_AttributeValue.text = faBaoInfo.attriButedIC[key].ToStringEx();
  29. Text_NextAttributeValue.gameObject.SetActive(false);
  30. }
  31. public void StartUpGrad(FaBaoInfo nextFabaoInfo)
  32. {
  33. Text_NextAttributeValue.text = $"+{(nextFabaoInfo.attriButedIC[key] - faBaoInfo.attriButedIC[key]).ToStringEx()}";
  34. Text_NextAttributeValue.gameObject.SetActive(true);
  35. Text_NextAttributeValue.color = new Color32(15,241,150,255);
  36. }
  37. public void EndUpGrade()
  38. {
  39. Text_NextAttributeValue.gameObject.SetActive(false);
  40. }
  41. public void StartBj(FaBaoInfo nextFabaoInfo)
  42. {
  43. if (nextFabaoInfo == null || !nextFabaoInfo.attriButedIC.ContainsKey(key) || nextFabaoInfo.attriButedIC[key] < faBaoInfo.attriButedIC[key])
  44. {
  45. long nextValue = nextFabaoInfo.attriButedIC.ContainsKey(key) ? nextFabaoInfo.attriButedIC[key] : 0;
  46. Text_NextAttributeValue.text = $"+{(faBaoInfo.attriButedIC[key] - nextValue).ToStringEx()}";
  47. Text_NextAttributeValue.gameObject.SetActive(true);
  48. Text_NextAttributeValue.color = new Color32(15,241,150,255);
  49. // Icon_Bj.gameObject.SetActive(true);
  50. // Icon_Bj.icon_name = "dec_fbjia";
  51. }
  52. else if (nextFabaoInfo.attriButedIC[key] >faBaoInfo.attriButedIC[key])
  53. {
  54. long nextValue = nextFabaoInfo.attriButedIC.ContainsKey(key) ? nextFabaoInfo.attriButedIC[key] : 0;
  55. if (nextValue == 0)
  56. {
  57. Text_NextAttributeValue.text = $"{(nextValue - faBaoInfo.attriButedIC[key]).ToStringEx()}";
  58. }
  59. else
  60. {
  61. Text_NextAttributeValue.text = $"-{(nextValue - faBaoInfo.attriButedIC[key]).ToStringEx()}";
  62. }
  63. Text_NextAttributeValue.gameObject.SetActive(true);
  64. Text_NextAttributeValue.color = new Color32(235,110,109,255);
  65. // Icon_Bj.gameObject.SetActive(true);
  66. // Icon_Bj.icon_name = "dec_fbjian";
  67. }
  68. else
  69. {
  70. Text_NextAttributeValue.gameObject.SetActive(false);
  71. // Icon_Bj.gameObject.SetActive(false);
  72. }
  73. }
  74. public void EndBj()
  75. {
  76. Icon_Bj.gameObject.SetActive(false);
  77. }
  78. private string GetAttributeName(int type)
  79. {
  80. switch (type)
  81. {
  82. case 1:
  83. return "生命";
  84. case 2:
  85. return "防御";
  86. case 3:
  87. return "攻击";
  88. }
  89. return "";
  90. }
  91. }
  92. }