FaBaoAttributeWidget.cs 3.5 KB

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