ShopBtnWidget.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System.Linq;
  2. using Core.Language;
  3. using Excel2Json;
  4. using Fort23.UTool;
  5. namespace Fort23.Mono
  6. {
  7. [UIBinding(prefab = "ShopBtnWidget")]
  8. public partial class ShopBtnWidget : ItemWidgetBasic
  9. {
  10. public ShopGroupConfig ShopGroupConfig;
  11. public SmallPlacesConfig SmallPlacesConfig;
  12. public bool iaUlock = false;
  13. private void Init()
  14. {
  15. }
  16. public override void AddEvent()
  17. {
  18. }
  19. public override void DelEvent()
  20. {
  21. }
  22. public override void AddButtonEvent()
  23. {
  24. base.AddButtonEvent();
  25. }
  26. public void CustomInit(ShopGroupConfig shopGroupConfig)
  27. {
  28. this.ShopGroupConfig = shopGroupConfig;
  29. Text_Name.text = LanguageManager.Instance.Text(ShopGroupConfig.shopName);
  30. }
  31. public void CustomInit(int smallPlacesId)
  32. {
  33. this.SmallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(smallPlacesId);
  34. Text_Name.text = LanguageManager.Instance.Text(SmallPlacesConfig.placeName);
  35. PlayerManager.Instance.GetSmallPlacesData(SmallPlacesConfig.ID - 1);
  36. AccountFileInfo.SmallPlacesData lastSmallPlacesData =
  37. PlayerManager.Instance.GetSmallPlacesData(SmallPlacesConfig.ID - 1);
  38. SmallPlacesConfig lastSmallPlacesConfig =
  39. ConfigComponent.Instance.Get<SmallPlacesConfig>(SmallPlacesConfig.ID - 1);
  40. if (SmallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||
  41. lastSmallPlacesData.completionEventCount <
  42. lastSmallPlacesConfig.CompletionEventCount))
  43. {
  44. iaUlock = false;
  45. uiToggle.Hind();
  46. // TipMessagePanel.OpenTipMessagePanel(
  47. // $"[{LanguageManager.Instance.Text(shopBtnWidget.SmallPlacesConfig.placeName)}]未解锁, 完成{lastSmallPlacesConfig.CompletionEventCount}个任务后, 可解锁. ");
  48. return;
  49. }
  50. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  51. {
  52. AccountFileInfo.EventList eventList =
  53. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  54. ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  55. if (eventList == null || !eventList.isCompleted)
  56. {
  57. iaUlock = false;
  58. uiToggle.Hind();
  59. return;
  60. }
  61. }
  62. AccountFileInfo.SmallPlacesData currentSmallPlacesData =
  63. PlayerManager.Instance.GetSmallPlacesData(SmallPlacesConfig.ID);
  64. if (currentSmallPlacesData == null)
  65. {
  66. iaUlock = false;
  67. uiToggle.Hind();
  68. return;
  69. }
  70. iaUlock = true;
  71. uiToggle.Show();
  72. }
  73. }
  74. }