| | |
| | | |
| | | public class SkinStoreWin : UIBase |
| | | { |
| | | [SerializeField] OwnMoneyCell ownMoneyCellWithShop; |
| | | //有刷新功能的商店 |
| | | [SerializeField] GameObject refreshGo; |
| | | [SerializeField] Image refreshMoneyIcon; |
| | | [SerializeField] Text refreshMoneyText; |
| | | [SerializeField] Button refreshButton; |
| | | |
| | | [SerializeField] GroupButtonEx normalShopBtn; |
| | | [SerializeField] GroupButtonEx guildShopBtn; |
| | | [SerializeField] GroupButtonEx heroShopBtn; |
| | | [SerializeField] Button giftBtn; |
| | | |
| | | [SerializeField] ScrollerController scroller; |
| | | |
| | | |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | refreshButton.AddListener(RefreshStore); |
| | | normalShopBtn.AddListener(() => { OnSelectStoreFuncType(1); }); |
| | | guildShopBtn.AddListener(() => { OnSelectStoreFuncType(2); }); |
| | | heroShopBtn.AddListener(() => { OnSelectStoreFuncType(3); }); |
| | | giftBtn.AddListener(() => |
| | | { |
| | | UIManager.Instance.OpenWindow<HeroSkinGiftWin>(); |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | scroller.OnRefreshCell += OnRefreshCell; |
| | | StoreModel.Instance.RefreshShopEvent += Display; |
| | | StoreModel.Instance.RefreshBuyShopLimitEvent += Display; |
| | | GuildManager.Instance.EnterOrQuitGuildEvent += EnterOrQuitGuildEvent; |
| | | StoreModel.Instance.RefreshShopEvent += Show; |
| | | StoreModel.Instance.RefreshBuyShopLimitEvent += Show; |
| | | |
| | | Display(); |
| | | } |
| | |
| | | protected override void OnPreClose() |
| | | { |
| | | scroller.OnRefreshCell -= OnRefreshCell; |
| | | StoreModel.Instance.RefreshShopEvent -= Display; |
| | | StoreModel.Instance.RefreshBuyShopLimitEvent -= Display; |
| | | GuildManager.Instance.EnterOrQuitGuildEvent -= EnterOrQuitGuildEvent; |
| | | StoreModel.Instance.selectStoreFuncType = StoreFunc.Normal; |
| | | StoreModel.Instance.RefreshShopEvent -= Show; |
| | | StoreModel.Instance.RefreshBuyShopLimitEvent -= Show; |
| | | } |
| | | |
| | | void Display() |
| | | { |
| | | if (StoreModel.Instance.selectStoreFuncType == StoreFunc.Normal) |
| | | { |
| | | normalShopBtn.SelectBtn(); |
| | | } |
| | | else if (StoreModel.Instance.selectStoreFuncType == StoreFunc.Guild) |
| | | { |
| | | guildShopBtn.SelectBtn(); |
| | | } |
| | | else if (StoreModel.Instance.selectStoreFuncType == StoreFunc.Hero) |
| | | { |
| | | heroShopBtn.SelectBtn(); |
| | | } |
| | | |
| | | guildShopBtn.SetColorful(null, PlayerDatas.Instance.fairyData.HasFairy); |
| | | guildShopBtn.isLock = !PlayerDatas.Instance.fairyData.HasFairy; |
| | | |
| | | ShowMoney(); |
| | | CreateScroller(); |
| | | } |
| | | |
| | | void EnterOrQuitGuildEvent(bool isEnter) |
| | | void Show() |
| | | { |
| | | if (!isEnter && StoreModel.Instance.selectStoreFuncType == StoreFunc.Guild) |
| | | { |
| | | StoreModel.Instance.selectStoreFuncType = StoreFunc.Normal; |
| | | } |
| | | Display(); |
| | | scroller.m_Scorller.RefreshActiveCellViews(); |
| | | } |
| | | |
| | | void CreateScroller() |
| | | { |
| | | if (!StoreModel.Instance.storeTypeDict.ContainsKey((int)StoreModel.Instance.selectStoreFuncType)) |
| | | if (!StoreModel.Instance.storeTypeDict.ContainsKey(StoreModel.skinStoreType)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | scroller.Refresh(); |
| | | int jumpIndex = -1; |
| | | var list = StoreModel.Instance.storeTypeDict[(int)StoreModel.Instance.selectStoreFuncType]; |
| | | scroller.Refresh(); |
| | | var list = StoreModel.Instance.storeTypeDict[StoreModel.skinStoreType]; |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | if (i % 3 == 0) |
| | | if (i % 4 == 0) |
| | | { |
| | | scroller.AddCell(ScrollerDataType.Header, i); |
| | | } |
| | | if (jumpIndex == -1 && list[i].shopId == StoreModel.Instance.jumpShopID) |
| | | { |
| | | jumpIndex = i / 3; |
| | | jumpIndex = i / 4; |
| | | } |
| | | } |
| | | scroller.Restart(); |
| | |
| | | |
| | | void OnRefreshCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | var _cell = cell as StoreLineCell; |
| | | var _cell = cell as SkinStoreLineCell; |
| | | _cell.Display(cell.index); |
| | | } |
| | | |
| | | |
| | | void ShowMoney() |
| | | { |
| | | if (!StoreModel.Instance.shopMoneyTypeDict.ContainsKey((int)StoreModel.Instance.selectStoreFuncType)) |
| | | { |
| | | return; |
| | | } |
| | | var moneyType = StoreModel.Instance.shopMoneyTypeDict[(int)StoreModel.Instance.selectStoreFuncType]; |
| | | ownMoneyCellWithShop.moneyType = moneyType; |
| | | ownMoneyCellWithShop.Display(true); |
| | | |
| | | if (StoreModel.Instance.selectStoreFuncType == StoreFunc.Hero) |
| | | { |
| | | refreshGo.SetActive(true); |
| | | refreshMoneyIcon.SetIconWithMoneyType(StoreModel.Instance.heroSoulRefreshMoneyType); |
| | | |
| | | if (StoreModel.Instance.shopRefreshCntDict.ContainsKey((int)StoreModel.Instance.selectStoreFuncType)) |
| | | { |
| | | if (StoreModel.Instance.shopRefreshCntDict[(int)StoreModel.Instance.selectStoreFuncType] >= |
| | | StoreModel.Instance.heroSoulRefreshFreeCount) |
| | | { |
| | | refreshMoneyText.text = StoreModel.Instance.heroSoulRefreshMoney.ToString(); |
| | | } |
| | | else |
| | | { |
| | | refreshMoneyText.text = Language.Get("L1127"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | refreshMoneyText.text = Language.Get("L1127"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | refreshGo.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | void RefreshStore() |
| | | { |
| | | if (StoreModel.Instance.selectStoreFuncType != StoreFunc.Hero) |
| | | { |
| | | return; |
| | | } |
| | | var useCnt = 0; |
| | | if (StoreModel.Instance.shopRefreshCntDict.ContainsKey((int)StoreModel.Instance.selectStoreFuncType)) |
| | | { |
| | | if (StoreModel.Instance.shopRefreshCntDict[(int)StoreModel.Instance.selectStoreFuncType] >= |
| | | StoreModel.Instance.heroSoulRefreshFreeCount) |
| | | { |
| | | useCnt = StoreModel.Instance.heroSoulRefreshMoney; |
| | | } |
| | | } |
| | | |
| | | if (UIHelper.CheckMoneyCount(StoreModel.Instance.heroSoulRefreshMoneyType, useCnt, 2)) |
| | | { |
| | | StoreModel.Instance.RefreshStore((int)StoreFunc.Hero); |
| | | } |
| | | } |
| | | |
| | | void OnSelectStoreFuncType(int index) |
| | | { |
| | | if (index == 2) |
| | | { |
| | | if (!PlayerDatas.Instance.fairyData.HasFairy) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("NoGuild"); |
| | | return; |
| | | } |
| | | } |
| | | StoreModel.Instance.selectStoreFuncType = (StoreFunc)index; |
| | | Display(); |
| | | } |
| | | } |