protected override void OnOpen(object param = null) { FirstChargeRewardTableItemBase item = DataManager.FirstChargeTable[0] as FirstChargeRewardTableItemBase; if (item == null) { Close(); } else { FirstChargeRewardTableItem Item = (FirstChargeRewardTableItem)item; mItemList.Clear(); ObjectCommon.DestoryChildren(Grid.gameObject); for (int i = 0; i < 7; i++) { if (Item.FirstChargeItems[i] != null && Item.FirstChargeItems[i].itemid > 0 && Item.FirstChargeItems[i].itemnum > 0) { ItemTableItem mItemRes = ItemManager.GetItemRes(Item.FirstChargeItems[i].itemid); ChargeItemInfo info = new ChargeItemInfo(Item.FirstChargeItems[i].itemid, Item.FirstChargeItems[i].itemnum); ChargeItemUI itemIcon = new ChargeItemUI(info); itemIcon.gameObject.transform.parent = Grid.gameObject.transform; itemIcon.gameObject.transform.localScale = Vector3.one; mItemList.Add(itemIcon); } } Grid.Reposition(); Grid.repositionNow = true; } EventDelegate.Add(mReturnBtn.onClick, OnReturnBtnClick); PlayerDataModule mPlayerDataModule = ModuleManager.Instance.FindModule <PlayerDataModule>(); if (!mPlayerDataModule.GetCharged()) { NGUITools.SetActive(mGetRewardBtn.gameObject, false); NGUITools.SetActive(mChargeBtn.gameObject, true); EventDelegate.Add(mChargeBtn.onClick, OnChargeBtnClick); } else if (!mPlayerDataModule.GetFirstChargePicked()) { NGUITools.SetActive(mGetRewardBtn.gameObject, true); NGUITools.SetActive(mChargeBtn.gameObject, false); EventDelegate.Add(mGetRewardBtn.onClick, OnRewardBtnClick); picked = false; } else { NGUITools.SetActive(mChargeBtn.gameObject, false); UIAtlasHelper.SetButtonImage(mGetRewardBtn, "common:anniuhui", true); } mScrollBar.value = 0.0f; }
protected override void OnClose() { EventDelegate.Remove(mReturnBtn.onClick, OnReturnBtnClick); PlayerDataModule mPlayerDataModule = ModuleManager.Instance.FindModule <PlayerDataModule>(); if (!mPlayerDataModule.GetCharged()) { EventDelegate.Remove(mChargeBtn.onClick, OnChargeBtnClick); } else if (!mPlayerDataModule.GetFirstChargePicked()) { EventDelegate.Remove(mGetRewardBtn.onClick, OnRewardBtnClick); } }