DivineSenceInfoBtnWidget.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. // Icon_ItemIcon.icon_name = ItemInfo.config.icon;
  30. Text_ItemCount.text =
  31. $"<color=#EF9F32>{100 * 1}</color>/{AccountFileInfo.Instance.playerData.divineSensePoint}";
  32. }
  33. else
  34. {
  35. if (id == -1)
  36. {
  37. ItemInfo = null;
  38. Icon_ItemIcon.gameObject.SetActive(false);
  39. Icon_ShenIcon.gameObject.SetActive(false);
  40. Text_ItemCount.text = "";
  41. icon_Jia.gameObject.SetActive(true);
  42. }
  43. else
  44. {
  45. icon_Jia.gameObject.SetActive(false);
  46. ItemInfo = PlayerManager.Instance.BagController.GetItemInfo(id);
  47. Icon_ItemIcon.gameObject.SetActive(transform);
  48. Icon_ShenIcon.gameObject.SetActive(false);
  49. Text_ItemCount.text = $"{1}/{ItemInfo.count.Value.ToString()}";
  50. if (ItemInfo.config.associateID == 7)
  51. {
  52. Icon_ItemIcon.icon_name = "icon_shenshitishengfu";
  53. Icon_ItemIcon2.icon_name = ItemInfo.config.icon;
  54. Icon_ItemIcon2.gameObject.SetActive(true);
  55. }
  56. else
  57. {
  58. Icon_ItemIcon.icon_name = ItemInfo.config.icon;
  59. Icon_ItemIcon2.gameObject.SetActive(false);
  60. }
  61. }
  62. }
  63. }
  64. public void UpdateItermCount(int selectCount)
  65. {
  66. if (type == 1)
  67. {
  68. Text_ItemCount.text =
  69. $"<color=#EF9F32>{100 * selectCount}</color>/{AccountFileInfo.Instance.playerData.divineSensePoint}";
  70. }
  71. else
  72. {
  73. if (ItemInfo != null)
  74. {
  75. selectCount = selectCount > ItemInfo.count.Value ? (int)ItemInfo.count.Value : selectCount;
  76. Text_ItemCount.text = $"<color=#EF9F32>{selectCount}</color>/{ItemInfo.count.Value.ToString()}";
  77. }
  78. }
  79. }
  80. }
  81. }