ShopBtnWidget.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. private void Init()
  13. {
  14. }
  15. public override void AddEvent()
  16. {
  17. }
  18. public override void DelEvent()
  19. {
  20. }
  21. public override void AddButtonEvent()
  22. {
  23. base.AddButtonEvent();
  24. }
  25. public void CustomInit(ShopGroupConfig shopGroupConfig)
  26. {
  27. this.ShopGroupConfig = shopGroupConfig;
  28. Text_Name.text = LanguageManager.Instance.Text(ShopGroupConfig.shopName);
  29. }
  30. public void CustomInit(int smallPlacesId)
  31. {
  32. this.SmallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(smallPlacesId);
  33. Text_Name.text = LanguageManager.Instance.Text(SmallPlacesConfig.placeName);
  34. PlayerManager.Instance.GetSmallPlacesData(SmallPlacesConfig.ID - 1);
  35. AccountFileInfo.SmallPlacesData lastSmallPlacesData =
  36. PlayerManager.Instance.GetSmallPlacesData(SmallPlacesConfig.ID - 1);
  37. SmallPlacesConfig lastSmallPlacesConfig =
  38. ConfigComponent.Instance.Get<SmallPlacesConfig>(SmallPlacesConfig.ID - 1);
  39. if (SmallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||
  40. lastSmallPlacesData.completionEventCount <
  41. lastSmallPlacesConfig.CompletionEventCount))
  42. {
  43. uiToggle.Hind();
  44. // TipMessagePanel.OpenTipMessagePanel(
  45. // $"[{LanguageManager.Instance.Text(shopBtnWidget.SmallPlacesConfig.placeName)}]未解锁, 完成{lastSmallPlacesConfig.CompletionEventCount}个任务后, 可解锁. ");
  46. return;
  47. }
  48. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  49. {
  50. AccountFileInfo.EventList eventList =
  51. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  52. ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  53. if (eventList == null || !eventList.isCompleted)
  54. {
  55. uiToggle.Hind();
  56. return;
  57. }
  58. }
  59. AccountFileInfo.SmallPlacesData currentSmallPlacesData =
  60. PlayerManager.Instance.GetSmallPlacesData(SmallPlacesConfig.ID);
  61. if (currentSmallPlacesData == null)
  62. {
  63. uiToggle.Hind();
  64. return;
  65. }
  66. uiToggle.Show();
  67. }
  68. }
  69. }