FaBaoAttributeWidget.cs 3.4 KB

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