DivineSenceInfoBtnWidget.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using GameLogic.Bag;
  2. namespace Fort23.Mono
  3. {
  4. [UIBinding(prefab = "DivineSenceInfoBtnWidget")]
  5. public partial class DivineSenceInfoBtnWidget : ItemWidgetBasic
  6. {
  7. public ItemInfo ItemInfo;
  8. public int type;
  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. base.AddButtonEvent();
  21. }
  22. public void CustomInit(int id, int type)
  23. {
  24. this.type = type;
  25. if (type == 1)
  26. {
  27. Icon_ItemIcon.gameObject.SetActive(false);
  28. Icon_ShenIcon.gameObject.SetActive(true);
  29. Text_ItemCount.text =
  30. $"{(int)AccountFileInfo.Instance.playerData.divineSensePoint}/<color=#EF9F32>{100 * 1}</color>";
  31. }
  32. else
  33. {
  34. if (id == -1)
  35. {
  36. ItemInfo = null;
  37. Icon_ItemIcon.gameObject.SetActive(false);
  38. Icon_ShenIcon.gameObject.SetActive(false);
  39. Text_ItemCount.text = "";
  40. icon_Jia.gameObject.SetActive(true);
  41. }
  42. else
  43. {
  44. icon_Jia.gameObject.SetActive(false);
  45. ItemInfo = PlayerManager.Instance.BagController.GetItemInfo(id);
  46. Icon_ItemIcon.gameObject.SetActive(transform);
  47. Icon_ShenIcon.gameObject.SetActive(false);
  48. Text_ItemCount.text = $"{1}/{ItemInfo.count.Value.ToString()}";
  49. if (ItemInfo.config.associateID == 7)
  50. {
  51. Icon_ItemIcon.icon_name = "icon_shenshitishengfu";
  52. Icon_ItemIcon2.icon_name = ItemInfo.config.icon;
  53. Icon_ItemIcon2.gameObject.SetActive(true);
  54. }
  55. else
  56. {
  57. Icon_ItemIcon.icon_name = ItemInfo.config.icon;
  58. Icon_ItemIcon2.gameObject.SetActive(false);
  59. }
  60. }
  61. }
  62. }
  63. public void UpdateItermCount(int selectCount)
  64. {
  65. if (type == 1)
  66. {
  67. Text_ItemCount.text =
  68. $"{(int)AccountFileInfo.Instance.playerData.divineSensePoint}/<color=#EF9F32>{100 * selectCount}</color>";
  69. }
  70. else
  71. {
  72. if (ItemInfo != null)
  73. {
  74. selectCount = selectCount > ItemInfo.count.Value ? (int)ItemInfo.count.Value : selectCount;
  75. Text_ItemCount.text = $"{ItemInfo.count.Value.ToString()}/<color=#EF9F32>{selectCount}</color>";
  76. }
  77. }
  78. }
  79. }
  80. }