DivineSenceInfoBtnWidget.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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(transform);
  28. // Icon_ItemIcon.icon_name = ItemInfo.config.icon;
  29. Text_ItemCount.text = $"{100 * 1}/{AccountFileInfo.Instance.playerData.divineSensePoint}";
  30. }
  31. else
  32. {
  33. if (id == -1)
  34. {
  35. ItemInfo = null;
  36. Icon_ItemIcon.gameObject.SetActive(false);
  37. Text_ItemCount.text = "";
  38. }
  39. else
  40. {
  41. ItemInfo = PlayerManager.Instance.BagController.GetItemInfo(id);
  42. Icon_ItemIcon.gameObject.SetActive(transform);
  43. Icon_ItemIcon.icon_name = ItemInfo.config.icon;
  44. Text_ItemCount.text = $"{1}/{ItemInfo.count.Value.ToString()}";
  45. }
  46. }
  47. }
  48. public void UpdateItermCount(int selectCount)
  49. {
  50. if (type == 1)
  51. {
  52. Text_ItemCount.text = $"{100 * selectCount}/{AccountFileInfo.Instance.playerData.divineSensePoint}";
  53. }
  54. else
  55. {
  56. if (ItemInfo != null)
  57. {
  58. Text_ItemCount.text = $"{selectCount}/{ItemInfo.count.Value.ToString()}";
  59. }
  60. }
  61. }
  62. }
  63. }