----- 献祭弹窗 ----- local this = {} --传入父脚本模块 local parent --传入特效层级 local sortingOrder=0 local fun local itemList = {} --传入选择英雄 local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig) this.timer = Timer.New() function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() this.close = Util.GetGameObject (gameObject, "mask") this.btn_Left = Util.GetGameObject (gameObject, "buttom/op/btnLeft") this.txt_BtnLeft = Util.GetGameObject (this.btn_Left, "Text"):GetComponent("Text") this.btn_Right = Util.GetGameObject (gameObject, "buttom/op/btnRight") this.txt_BtnRight = Util.GetGameObject (this.btn_Right, "Text"):GetComponent("Text") this.title = Util.GetGameObject (gameObject, "buttom/title"):GetComponent("Text") this.subTitle = Util.GetGameObject (gameObject, "buttom/subTitle"):GetComponent("Text") this.tipLabel = Util.GetGameObject (gameObject, "buttom/content"):GetComponent("Text") this.cost = Util.GetGameObject (gameObject, "buttom/cost") this.costIcon = Util.GetGameObject (gameObject, "buttom/cost/icon"):GetComponent("Image") this.costNum = Util.GetGameObject (gameObject, "buttom/cost/num"):GetComponent("Text") end function this:BindEvent() Util.AddClick(this.close, function () if parent then parent:ClosePanel() end end) Util.AddClick(this.btn_Left, this.OnLeftBtnClick) Util.AddClick(this.btn_Right, this.OnRightBtnClick) end --左边按钮点击事件 function this.OnLeftBtnClick() if this.leftAction then this.leftAction() end if parent then parent:ClosePanel() end end --右边按钮点击事件 function this.OnRightBtnClick() FightLevelManager.RequestGetDailyReward(this.rightAction) end function this:AddListener() Game.GlobalEvent:AddEvent(GameEvent.FightLevel.DailyRewardStateChange,this.Refresh) end function this:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.FightLevel.DailyRewardStateChange,this.Refresh) end function this:OnShow(_parent,...) parent=_parent local _args = {...} -- 计算可获得的数量 local starNum = FightLevelManager.GetAllChapterStars() local getNum = starNum * 5 + 50 local itemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig, 1226) this.title.text = "提示" this.tipLabel.text = string.format("当前可领取%s%s(星数×5+50),\n确认领取?", itemConfig.Name, UIColorStr.GREEN, getNum) this.rightAction = _args[1] this.Refresh() end function this.Refresh() local freePriId = 5 local buyPriId = 3 local storeId = 10006 local storeData = ConfigManager.GetConfigData(ConfigName.StoreConfig,storeId) local freeTimes = PrivilegeManager.GetPrivilegeRemainValue(freePriId) local buyTimes = PrivilegeManager.GetPrivilegeRemainValue(buyPriId) this.subTitle.text = "本日可领取次数:"..(freeTimes + buyTimes) if PrivilegeManager.GetPrivilegeRemainValue(freePriId) > 0 then this.costIcon.gameObject:SetActive(false) this.costNum.text = string.format("免费领取") else this.costIcon.gameObject:SetActive(true) this.costIcon.sprite = this.spLoader:LoadSprite(GetResourcePath(itemConfig[storeData.Cost[1][1]].ResourceID)) local needNum = CalculateCostCount(PrivilegeManager.GetPrivilegeUsedTimes(buyPriId),storeData.Cost[2]) --storeData.Cost[2][PrivilegeManager.GetPrivilegeUsedTimes(buyPriId) + 1] or storeData.Cost[2][#storeData.Cost[2]] if BagManager.GetItemCountById(storeData.Cost[1][1]) >= needNum then this.costNum.text = string.format("×%s",needNum) else this.costNum.text = string.format("×%s",needNum) end end ForceRebuildLayout(this.cost.transform) end function this:OnClose() if parent then parent:ClosePanel() end end function this:OnDestroy() this.spLoader:Destroy() end return this