miduo_client/Assets/ManagedResources/~Lua/Modules/EightDay/ZeroPointOnePanel.lua

194 lines
7.5 KiB
Lua

require("Base/BasePanel")
local ZeroPointOnePanel = Inherit(BasePanel)
local this = ZeroPointOnePanel
local orginLayer = 0
local ActRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig) --总表数据
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local ArtConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local rechargeCommodityConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
local everyDayGiftConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.EveryDayGift, "GlobalActivity", 12601) --表内八日奖励数据
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local ItemList = {} --奖励List
local ItemViewList = {}
local rewardData --后端数据
local curDay --当前天数
local Live
local bgName
--初始化组件(用于子类重写)
function ZeroPointOnePanel:InitComponent()
this.spLoader = SpriteLoader.New()
this.btnClose = Util.GetGameObject(this.gameObject, "panel/bg/btnBack")
this.btn_mission = Util.GetGameObject(this.gameObject, "panel/bg/btn_mission")
this.btn_help = Util.GetGameObject(this.gameObject, "panel/bg/btn_help")
this.btnPreview = Util.GetGameObject(this.gameObject, "panel/bg/btnPreview")
this.show = Util.GetGameObject(this.gameObject, "panel/show") --根节点
this.itemPre = Util.GetGameObject(this.gameObject, "itemPre") --预设
this.effect = Util.GetGameObject(this.gameObject, "panel/effect")
this.badeffect = Util.GetGameObject(this.effect, "Partical/uv_zi")
this.badeffect:SetActive(false)
this.btn_refresh = Util.GetGameObject(this.gameObject, "panel/btn_refresh")
this.refreshTxt = Util.GetGameObject(this.gameObject, "panel/refreshTxt"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function ZeroPointOnePanel:BindEvent()
Util.AddClick(this.btn_mission, function()
UIManager.OpenPanel(UIName.ZeroPointOneMissionPanel)
end)
Util.AddClick(this.btnClose, function()
this:ClosePanel()
end)
Util.AddClick(this.btn_help, function()
UIManager.OpenPanel(UIName.HelpPopup, 149, 0, 0)
end)
Util.AddOnceClick(this.btn_refresh, function()
NetManager.GetActivityRewardRequest(-1, 12601, function(_drop)
this:Refresh()
end)
end)
end
--添加事件监听(用于子类重写)
function ZeroPointOnePanel:AddListener()
end
--移除事件监听(用于子类重写)
function ZeroPointOnePanel:RemoveListener()
end
local refreshNum = 0
function ZeroPointOnePanel:Refresh()
rewardData = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.zeroPointOneGift)
for i = 1, #rewardData.mission do
if rewardData.mission[i].missionId == -1 then
refreshNum = rewardData.mission[i].progress
end
end
Util.SetGray(this.btn_refresh, refreshNum <= 0) --已经领取置灰
this.btn_refresh:GetComponent("Button").interactable = refreshNum > 0 --不可点击
this.refreshTxt.text = string.format(Language[10638], refreshNum)
this.SetAllReward()
end
function ZeroPointOnePanel:SetAllReward()
for i = 1, #everyDayGiftConfig do
local item = ItemList[i]
if not item then
item = newObject(this.itemPre)
item.name = "itemPre_" .. i
item.transform:SetParent(this.show.transform)
item.transform.localScale = Vector3.one
item.transform.localPosition = Vector3.zero
ItemList[i] = item
end
if rewardData.mission[i] then
item.gameObject:SetActive(true)
this:SetSingleReward(item, i, rewardData.mission[i], everyDayGiftConfig[i])
else
item.gameObject:SetActive(false)
end
end
end
function ZeroPointOnePanel:SetSingleReward(item, i, data, config)
local kuang = Util.GetGameObject(item, "kuang"):GetComponent("Image")
local reward = Util.GetGameObject(item, "kuang/reward")
local event = Util.GetGameObject(item, "kuang/reward/event")
event:SetActive(false)
local day = Util.GetGameObject(item, "kuang/reward/days"):GetComponent("Text")
local icon = Util.GetGameObject(item, "kuang/reward/icon")
local name = Util.GetGameObject(item, "kuang/Button/name"):GetComponent("Text")
local btnGet = Util.GetGameObject(item, "kuang/Button")
local redPoint = Util.GetGameObject(item, "kuang/Button/redPoint")
local mask = Util.GetGameObject(item, "kuang/reward/mask")
local itemMask = Util.GetGameObject(item, "mask")
local tipTxt = Util.GetGameObject(item, "mask/tip"):GetComponent("Text")
local buyTimes = Util.GetGameObject(item, "kuang/reward/buyNumTxt"):GetComponent("Text")
local isCanGet = rewardData.mission[i].state --是否可领取
local price2 = Util.GetGameObject(item, "kuang/reward/price"):GetComponent("Text")
local zheTxt = Util.GetGameObject(item, "zheImg/Text"):GetComponent("Text")
--tipTxt.text=
name.text = ""
itemMask:SetActive(data.state == 0)
buyTimes.text = Language[10639] .. data.progress
LogError("data.missionId======================" .. data.missionId)
mask:SetActive(false)
--local config=everyDayGiftConfig[data.missionId]
tipTxt.text = this.GetOpenTip(config)
--奖励的Icon
if not ItemViewList[i] then
local view = SubUIManager.Open(SubUIConfig.ItemView, icon.transform)
ItemViewList[i] = view
end
local recharge = rechargeCommodityConfig[everyDayGiftConfig[i].RechargeID]
LogError("IsDiscount================" .. recharge.IsDiscount)
zheTxt.text = recharge.IsDiscount / 100 .. Language[10640]
ItemViewList[i]:OnOpen(false, recharge.RewardShow[1], 0.85, false)
day.text = GetLanguageStrById(recharge.Name)
price2.text = MoneyUtil.GetMoney(recharge.BaseReward[1][2]) .. Language[10497]
name.text = MoneyUtil.GetMoney(recharge.Price) .. Language[10497]
--设置已达成的按钮状态
Util.SetGray(btnGet, data.progress <= 0) --已经领取置灰
btnGet:GetComponent("Button").interactable = data.progress > 0 --不可点击
redPoint:SetActive(false)
Util.AddOnceClick(btnGet, function()
--NetManager.GetActivityRewardRequest(data.missionId,12601,function (drop)
PayManager.Pay(recharge.Id, function(id)
--FirstRechargeManager.RefreshAccumRechargeValue(recharge.Id)
this.Refresh()
end)
--end)
end)
end
--获取开启条件
function this.GetOpenTip(_config)
if _config and _config.Condition then
local isOk, tip = GetCommonFunctionOpenTip(_config.Condition)
return tip
end
return ""
end
function ZeroPointOnePanel:OnSortingOrderChange()
Util.AddParticleSortLayer(this.effect, self.sortingOrder - orginLayer)
orginLayer = self.sortingOrder
end
--界面打开时调用(用于子类重写)
function ZeroPointOnePanel:OnOpen(...)
end
-- 打开,重新打开时回调
function ZeroPointOnePanel:OnShow()
this.Refresh()
end
--界面关闭时调用(用于子类重写)
function ZeroPointOnePanel:OnClose()
if Live then
poolManager:UnLoadLive(bgName, Live)
Live = nil
end
end
--界面销毁时调用(用于子类重写)
function ZeroPointOnePanel:OnDestroy()
this.spLoader:Destroy()
orginLayer = 0
ItemList = {}
ItemViewList = {}
end
return ZeroPointOnePanel