FaBaoAttributeWidget.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. public void StartBj(FaBaoInfo nextFabaoInfo)
  39. {
  40. if (nextFabaoInfo == null || !nextFabaoInfo.attriButedIC.ContainsKey(key) || nextFabaoInfo.attriButedIC[key] < faBaoInfo.attriButedIC[key])
  41. {
  42. Icon_Bj.gameObject.SetActive(true);
  43. Icon_Bj.icon_name = "icon_tisheng";
  44. }
  45. else if (nextFabaoInfo.attriButedIC[key] >faBaoInfo.attriButedIC[key])
  46. {
  47. Icon_Bj.gameObject.SetActive(true);
  48. Icon_Bj.icon_name = "icon_xiajiang";
  49. }
  50. else
  51. {
  52. Icon_Bj.gameObject.SetActive(false);
  53. }
  54. }
  55. public void EndBj()
  56. {
  57. Icon_Bj.gameObject.SetActive(false);
  58. }
  59. private string GetAttributeName(int type)
  60. {
  61. switch (type)
  62. {
  63. case 1:
  64. return "生命";
  65. case 2:
  66. return "防御";
  67. case 3:
  68. return "攻击";
  69. }
  70. return "";
  71. }
  72. }
  73. }