sk-client/Assets/ManagedResources/~Lua/Modules/AgainRecharge/AgainRechargePanel.lua

266 lines
8.6 KiB
Lua

--[[
* @ClassName FirstRechargePanel
* @Description 首充
* @Date 2019/6/3 11:45
* @Author MagicianJoker, fengliudianshao@outlook.com
* @Copyright Copyright (c) 2019, MagicianJoker
--]]
local DayRewardItem = require("Modules/AgainRecharge/AgainDayRewardItem")
---@class AgainRechargePanel
local AgainRechargePanel = Inherit(BasePanel)
local this = AgainRechargePanel
local kMaxTab, kMaxDay = 2, 3
local TextColorDef = {
[1] = Color.New(255 / 255, 255 / 255, 255 / 255, 76/255),
[2] = Color.New(255 / 255, 255 / 255, 255 / 255, 204/255)
}
local orginLayer
local activityRewardConfig = ConfigManager.GetConfig(ConfigName.ActivityRewardConfig)
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local specialConfig = ConfigManager.GetConfig(ConfigName.SpecialConfig)
local thread = nil --协程
-- --显示英雄ID
-- local showHeroIDs = {
-- 10003,
-- 10019,
-- 10042,
-- }
-- local showHeroId = 10042
--当前显示英雄的下标
local showHeroIndex = 0
function AgainRechargePanel:InitComponent()
orginLayer = 0
self.hero = Util.GetGameObject(self.transform, "hero")
this.lihui = Util.GetGameObject(self.hero.transform, "lihuis")
-- this.oneLihui = Util.GetGameObject(self.hero.transform, "lihui")
this.lihuiInfo = Util.GetGameObject(self.hero.transform, "lihuiInfo")
this.name = Util.GetGameObject(this.lihuiInfo, "name"):GetComponent("Text")
this.pro = Util.GetGameObject(this.lihuiInfo, "pro"):GetComponent("Image")
self.closeBtn = Util.GetGameObject(self.transform, "closeBtn")
this.Btnback = Util.GetGameObject(this.transform, "Btnback")
self.selectTabIndex = -1
self.dayRewardList = {}
for i = 1, kMaxDay do
self.dayRewardList[i] = DayRewardItem.new(self,self.transform:Find("frame/rewardBg/rewardDay" .. i))
end
--bottomPart
self.reChargeBtn = Util.GetGameObject(self.transform, "frame/rechargeBtn")
self.reChargeTips = Util.GetGameObject(self.transform, "frame/tips"):GetComponent("Text")
self.LeftTip = Util.GetGameObject(self.transform, "frame/Image/LeftText"):GetComponent("Text")
self.effect = Util.GetGameObject(self.transform, "frame/effect")
--local LeftTip = Util.GetGameObject(self.transform, "frame/Image/LeftText"):GetComponent("Text")
--if GetChannelConfig().RechargeNum_Mode == 1 then
-- LeftTip.Text = GetLanguageStrById(50417)
--else
-- LeftTip.Text = GetLanguageStrById(50419)
--end
-- effectAdapte(Util.GetGameObject(self.effect, "Partical/ziti mask (1)"))
-- self.oneLihuiInfo = Util.GetGameObject(self.transform,"hero/oneLihuiInfo")
end
function AgainRechargePanel:BindEvent()
Util.AddClick(self.closeBtn, function()
self:ClosePanel()
end)
Util.AddClick(this.Btnback, function()
self:ClosePanel()
end)
Util.AddClick(self.reChargeBtn, function()
self:OnRechargeBtnClicked()
end)
end
function AgainRechargePanel:OnSortingOrderChange()
-- Util.AddParticleSortLayer(self.effect, self.sortingOrder - orginLayer)
-- orginLayer = self.sortingOrder
-- --特效穿透特殊处理
-- for i = 1, #self.dayRewardList do
-- self.dayRewardList[i]:OnSortingOrderChange(self.sortingOrder)
-- end
end
local fun = nil
function AgainRechargePanel:OnOpen(context,_fun)
context = context and context or {}
self.selectTabIndex = context.tabIndex and context.tabIndex or 1
fun = _fun
end
function AgainRechargePanel:OnShow()
self:OnTabChanged(self.selectTabIndex)
local activityInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.AgainRecharge)
local AccumRecharge = 0
for _, missInfo in pairs(activityInfo.mission) do
if missInfo and missInfo.progress then
AccumRecharge = missInfo.progress
end
end
--根据渠道配置界面显示充值金额或充值积分
if GetChannelConfig().RechargeNum_Mode == 1 then
self.reChargeTips.text = string.format(GetLanguageStrById(50420), AccumRecharge/1000)
self.LeftTip.text = GetLanguageStrById(50512)
else
self.reChargeTips.text = string.format(GetLanguageStrById(10663), AccumRecharge/100)
self.LeftTip.text = GetLanguageStrById(50513)
end
-- this.oneHeroData = ConfigManager.GetConfigData(ConfigName.HeroConfig,showHeroId)
-- this.Onelive = LoadHerolive(this.oneHeroData,this.oneLihui.transform)
-- Util.GetGameObject(self.oneLihuiInfo,"name"):GetComponent("Text").text = GetLanguageStrById(this.oneHeroData.ReadingName)
-- Util.GetGameObject(self.oneLihuiInfo,"pro"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(this.oneHeroData.PropertyName))
thread = coroutine.start(function ()
for i = 1, 10, 0 do
AgainSetHeroData(AgainGetHeroId())
end
end)
end
function AgainSetHeroData(heroId)
if this.liveNode then
UnLoadHerolive(this.heroData, this.liveNode)
Util.ClearChild(this.lihui.transform)
this.liveNode = nil
end
this.heroData = ConfigManager.GetConfigData(ConfigName.HeroConfig, tonumber(heroId))
this.name.text = GetLanguageStrById(this.heroData.ReadingName)
this.pro.sprite = Util.LoadSprite(GetProStrImageByProNum(this.heroData.PropertyName))
this.liveNode = LoadHerolive(this.heroData, this.lihui.transform,true)
local stopV3 = Vector3.New(this.heroData.Static[2], this.heroData.Static[3],0)
local startV3 = Vector3.New(this.heroData.Static[2], this.heroData.Static[3],0)
local endV3 = Vector3.New(this.heroData.Static[2], this.heroData.Static[3],0)
startV3.x = 1000
endV3.x = -1000
DoTween.To(
DG.Tweening.Core.DOGetter_UnityEngine_Vector3(
function()
return this.liveNode.transform.localPosition
end
),
DG.Tweening.Core.DOSetter_UnityEngine_Vector3(
function(progress)
this.liveNode.transform.localPosition = progress
end
),
stopV3,
0.3
):SetEase(Ease.InQuad)
coroutine.wait(3)
DoTween.To(
DG.Tweening.Core.DOGetter_UnityEngine_Vector3(
function()
return this.liveNode.transform.localPosition
end
),
DG.Tweening.Core.DOSetter_UnityEngine_Vector3(
function(progress)
this.liveNode.transform.localPosition = progress
end
),
endV3,
0.3
):SetEase(Ease.InQuad)
coroutine.wait(0.3)
end
local lastIndex = 0
local curIndex = 0
function AgainGetHeroId()
local showHeroIDs
if curIndex ~= lastIndex then
showHeroIndex = 0
lastIndex = curIndex
end
local heros = specialConfig[2019].Value
showHeroIDs = string.split(heros, "#")
showHeroIndex = showHeroIndex + 1
if showHeroIndex > #showHeroIDs then
showHeroIndex = 1
end
return showHeroIDs[showHeroIndex]
end
function AgainRechargePanel:OnTabClicked(index)
if self.selectTabIndex == index then
return
end
self:OnTabChanged(index)
end
function AgainRechargePanel:OnTabChanged(index)
self:ShowContent(index)
self.selectTabIndex = index
curIndex = index
-- this.oneLihui:SetActive(index == 0)
-- this.lihui:SetActive(index == 2)
-- this.oneLihuiInfo:SetActive(index == 0)
-- this.lihuiInfo:SetActive(index == 2)
end
function AgainRechargePanel:ShowContent(index)
local tempData = {}
for _, rewardInfo in ConfigPairs(activityRewardConfig) do
if rewardInfo.ActivityId == ActivityTypeDef.AgainRecharge then
table.insert(tempData, rewardInfo)
end
end
local day = GetTimePass(FirstRechargeManager.GetRechargeTime(tempData[1].Values[1][1]))--
if day >=1 and FirstRechargeManager.GetAccumRechargeValue() > 0 then --可领取的话 充值按钮
self.reChargeBtn:SetActive(false)
else
self.reChargeBtn:SetActive(true)
end
for i, dayRewardItem in ipairs(self.dayRewardList) do
dayRewardItem:SetValue(tempData[i], self.sortingOrder)
end
end
function AgainRechargePanel:OnRechargeBtnClicked()
self:ClosePanel()
if not ShopManager.SetMainRechargeJump() then
JumpManager.GoJump(36008)
else
-- UIManager.OpenPanel(UIName.MainRechargePanel, 1)
JumpManager.GoJump(36016)
end
end
--界面关闭时调用(用于子类重写)
function AgainRechargePanel:OnClose()
if thread then
coroutine.stop(thread)
thread = nil
end
if fun then
fun()
fun = nil
end
if this.liveNode then
UnLoadHerolive(this.heroData, this.liveNode)
Util.ClearChild(this.lihui.transform)
this.liveNode = nil
end
end
return AgainRechargePanel