miduo_client/Assets/ManagedResources/~Lua/Modules/Recruit/SingleRecruitPanel.lua

357 lines
15 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
SingleRecruitPanel = Inherit(BasePanel)
local this=SingleRecruitPanel
local heroConfigData = ConfigManager.GetConfig(ConfigName.HeroConfig)
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local artResourcesConfig =ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local privilegeConfig=ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
local passiveSkillConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local passiveSkillLogicConfig=ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
local heroRankupConfig=ConfigManager.GetConfig(ConfigName.HeroRankupConfig)
local isFirst=true--是否为第一次进入界面
local timeNum--第一个特效等待播放的时间
local timeNum2--第二个特效等待播放的时间
local timeNum3--第三个特效等待播放的时间
local heroData--展示界面需要的单个英雄数据
local type--抽卡类型
local state --1单抽 2多抽
local index=0 --十连抽索引
local orginLayer
local heroStaticData
local testLiveGO
local maxTimesId--特权id上限今日召唤上限
local _heroTable={} --符合4、5星的英雄容器
--初始化组件(用于子类重写)
function SingleRecruitPanel:InitComponent()
orginLayer = 0
self.live2dRoot = Util.GetGameObject(self.gameObject, "rolePanel/live2dRoot")
self.bg = Util.GetGameObject(self.gameObject, "bg")
screenAdapte(self.bg)
self.heroName = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/Panel/name/heroName"):GetComponent("Text")
self.proImage = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/Panel/name/proImage/proImage/proImage"):GetComponent("Image")
self.starGrid = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/Panel/star")
self.goBtn=Util.GetGameObject(self.transform,"rolePanel/rolePanel2/goBtn")
self.sureBtn = Util.GetGameObject(self.transform, "rolePanel/rolePanel2/sureBtn")
self.againBtn = Util.GetGameObject(self.transform, "rolePanel/rolePanel2/againBtn")
self.againIcon=Util.GetGameObject(self.againBtn,"Tip/juan"):GetComponent("Image")
self.againNum=Util.GetGameObject(self.againBtn,"Tip/Text"):GetComponent("Text")
self.dragView = SubUIManager.Open(SubUIConfig.DragView, self.gameObject.transform)
self.dragView.transform:SetSiblingIndex(1)
this.rolePanel = Util.GetGameObject(self.transform, "rolePanel")
this.UI_Effect_open = Util.GetGameObject(self.transform, "bg/UI_Effect_open") --开门特效
this.UI_Effect_appear = Util.GetGameObject(self.transform, "bg/UI_Effect_appear")
this.UI_Effect_choukaSSR = Util.GetGameObject(self.transform, "bg/UI_Effect_chouka_SSR")
this.UI_Effect_choukaSR = Util.GetGameObject(self.transform, "bg/UI_Effect_chouka_SR")
this.UI_Effect_choukaR = Util.GetGameObject(self.transform, "bg/UI_Effect_chouka_R")
this.jumpBtn = Util.GetGameObject(self.transform, "rolePanel/jumpBtn")
self.posImage=Util.GetGameObject(self.transform,"Pos/PosImage"):GetComponent("Image")
self.posText=Util.GetGameObject(self.transform,"Pos/PosText"):GetComponent("Text")
this.info=Util.GetGameObject(self.gameObject,"rolePanel/rolePanel1/Panel/Info")
this.infoTitleBg=Util.GetGameObject(this.info,"TitleBg")
this.infoTitle=Util.GetGameObject(this.infoTitleBg,"Title"):GetComponent("Text")
this.infoBody=Util.GetGameObject(this.info,"Body"):GetComponent("Text")
end
--绑定事件(用于子类重写)
function SingleRecruitPanel:BindEvent()
Util.AddClick(self.sureBtn, function()
isFirst=true
self:ClosePanel()
end)
Util.AddClick(self.againBtn, function()
local d=RecruitManager.GetExpendData(type)
if BagManager.GetItemCountById(d[1])<d[2] then
PopupTipPanel.ShowTip(itemConfig[d[1]].Name..Language[10492])
return
end
if PrivilegeManager.GetPrivilegeUsedTimes(maxTimesId)+1>privilegeConfig[maxTimesId].Condition[1][2] then
PopupTipPanel.ShowTip(Language[11760])
return
end
RecruitManager.RecruitRequest(type,function(msg)
PrivilegeManager.RefreshPrivilegeUsedTimes(maxTimesId,1)--记录抽卡次数
for i=1, #msg.drop.Hero do
heroData = msg.drop.Hero[i]
self:UpdataPanelData(heroData)
end
end,maxTimesId)
end)
Util.AddClick(this.dragView.gameObject, function ()
if testLiveGO then
local SkeletonGraphic = testLiveGO:GetComponent("SkeletonGraphic")
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
end
end)
--十连跳过按钮 直接打开十连抽展示界面
Util.AddClick(self.jumpBtn, function()
isFirst=true
self:ClosePanel()
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData,type)
end)
--确定按钮
Util.AddClick(self.goBtn,function()
if state==1 then
this.goBtn:SetActive(false)
this.againBtn:SetActive(true)
this.sureBtn:SetActive(true)
this.info:SetActive(false)
elseif state==2 then
if index>=LengthOfTable(_heroTable) then
isFirst=true
self:ClosePanel()
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData,type)
else
self:TenOpenPanel(heroData)
end
end
end)
end
--添加事件监听(用于子类重写)
function SingleRecruitPanel:AddListener()
end
--移除事件监听(用于子类重写)
function SingleRecruitPanel:RemoveListener()
end
function SingleRecruitPanel:OnSortingOrderChange()
Util.AddParticleSortLayer(self.bg, self.sortingOrder - orginLayer)
this.rolePanel:GetComponent("Canvas").sortingOrder = self.sortingOrder + 5
orginLayer = self.sortingOrder
end
--界面打开时调用(用于子类重写)
function SingleRecruitPanel:OnOpen(...)
this.UI_Effect_open:SetActive(true)
SoundManager.PlaySound(SoundConfig.Sound_Recruit1)
this.UI_Effect_choukaSSR:SetActive(false)
this.UI_Effect_choukaSR:SetActive(false)
this.UI_Effect_choukaR:SetActive(false)
this.UI_Effect_appear:SetActive(false)
this.rolePanel:SetActive(false)
local data={...}
heroData=data[1]
type=data[2]
state=data[3]
end
function SingleRecruitPanel:OnShow()
maxTimesId=lotterySetting[type].MaxTimes --特权上限ID
index=0
if state==1 then --单抽
self:TenOpenPanel()
elseif state==2 then
isFirst=true
_heroTable={}
--将符合条件的英雄插入容器中
for k, v in ipairs(heroData) do
if heroConfigData[v.heroId].Star==4 or heroConfigData[v.heroId].Star==5 then
-- LogBlue(heroConfigData[v.heroId].ReadingName)
table.insert(_heroTable,v)
end
end
-- LogGreen("符合条件的英雄数量"..LengthOfTable(_heroTable))
self:TenOpenPanel()
end
end
local time--十连抽每次展示特效time
function SingleRecruitPanel:TenOpenPanel()
if isFirst then --第一次进来
this.UI_Effect_open:SetActive(true)
index=1
timeNum3=0
timeNum=1.3
timeNum2=4.3
else--以后每次进来
this.UI_Effect_open:SetActive(false)
index=index+1
timeNum3=2
timeNum=0
timeNum2=0
end
--当单抽 或者是 十连抽第一次的时候
if state==1 or isFirst then
this.rolePanel:SetActive(false)
local time = Timer.New(function ()
this.UI_Effect_choukaSSR:SetActive(false)
this.UI_Effect_choukaSR:SetActive(false)
this.UI_Effect_choukaR:SetActive(false)
this.UI_Effect_appear:SetActive(true)
SoundManager.PlaySound(SoundConfig.Sound_Recruit2)
end, timeNum)
time:Start()
local time3 = Timer.New(function ()
this.UI_Effect_open:SetActive(false)
end, 4)
time3:Start()
elseif state==2 then-- 十连抽
-- timeNum2=0
--this.UI_Effect_choukaSSR:SetActive(false)
--this.UI_Effect_choukaSR:SetActive(false)
--this.UI_Effect_choukaR:SetActive(false)
end
local time2 = Timer.New(function ()
if state==1 then
self:UpdataPanelData(heroData)
else
if LengthOfTable(_heroTable)>0 then
self:UpdataPanelData(_heroTable[index])
else
self:ClosePanel()
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData,type)
end
end
end, timeNum2)
time2:Start()
end
function SingleRecruitPanel:UpdataPanelData(_heroData)
--赋值展示界面数据
-- local time2 = Timer.New(function ()
this.UI_Effect_appear:SetActive(false)
SoundManager.PlaySound(SoundConfig.Sound_Recruit3)
if heroStaticData and testLiveGO then
poolManager:UnLoadLive(GetResourcePath(heroStaticData.Live), testLiveGO)
heroStaticData, testLiveGO = nil, nil
end
heroStaticData = heroConfigData[_heroData.heroId]
-- Log("heroStaticData.Live:"..heroStaticData.Live)
--不同星级开启不同特效
this.UI_Effect_choukaSSR:SetActive(heroStaticData.Star == 5)
this.UI_Effect_choukaSR:SetActive(heroStaticData.Star == 4)
this.UI_Effect_choukaR:SetActive(heroStaticData.Star == 3 or heroStaticData.Star == 2 or heroStaticData.Star == 1)
--指定星级开启info
this.info:SetActive(heroStaticData.Star == 5 or heroStaticData.Star == 4)
this.infoBody.gameObject:SetActive(heroStaticData.Star == 5)
this.infoTitle.text=heroStaticData.HeroLocationDesc1
if heroStaticData.Star == 5 then
local t={}
local upStarSkillDataList={} --数据容器
--获取几星激活数据
for i = 1, #heroStaticData.OpenPassiveSkillRules do
if heroStaticData.OpenPassiveSkillRules[i][1] == 2 then
local d = {}
d.passiveSkillConfig = passiveSkillConfig[heroStaticData.OpenPassiveSkillRules[i][3]]
d.OpenPassiveSkillRules = heroStaticData.OpenPassiveSkillRules[i]
d.titleStr = "<size=34><color=#5AC383>"..NumToSimplenessFont[heroRankupConfig[heroStaticData.OpenPassiveSkillRules[i][2]].Phase[2]] .. Language[11767]
table.insert(upStarSkillDataList,d)
end
end
--数据插入t
for j = 1, #upStarSkillDataList do
if passiveSkillLogicConfig[upStarSkillDataList[j].passiveSkillConfig.Id].Judge == 1 then
table.insert(t,upStarSkillDataList[j].titleStr..upStarSkillDataList[j].passiveSkillConfig.Desc.."\n")
end
end
--获取法宝数据
local dTalis = ConfigManager.GetConfigData(ConfigName.HeroConfig,heroStaticData.Id).EquipTalismana--当前法宝数据 data[1]星级 data[2]法宝ID
local dowerAllData= ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipTalismana,"TalismanaId",dTalis[2])--当前法宝全部天赋数据(天赋可能为空)
local dowerData={}--当前法宝全部技能数据(天赋不为空)
for k=1,#dowerAllData do
if dowerAllData[k].OpenSkillRules then
table.insert(dowerData, dowerAllData[k])
end
end
--数据插入t,保证在星数据后
for n=1,#dowerData do
if dowerData[n].Level==25 then
table.insert(t,Language[11768]..passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc.."\n")
end
end
local s=table.concat(t)--将表里字符串拼接
--看这下面 是全角空格哦~
this.infoBody.text=string.sub(string.gsub(s," "," "),1,-2)--去除最后\n
end
--TODO:动态加载立绘
testLiveGO = poolManager:LoadLive(GetResourcePath(heroStaticData.Live), self.live2dRoot.transform,
Vector3.one * heroStaticData.Scale, Vector3.New(heroStaticData.Position[1],heroStaticData.Position[2],0))
local SkeletonGraphic = testLiveGO:GetComponent("SkeletonGraphic")
local idle = function() SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) end
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle
poolManager:SetLiveClearCall(GetResourcePath(heroStaticData.Live), testLiveGO, function ()
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle
end)
self.dragView:SetDragGO(testLiveGO)
SetHeroStars(self.starGrid, _heroData.star)
-- self.profession.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(heroStaticData.Profession))
self.proImage.sprite =Util.LoadSprite(GetProStrImageByProNum(heroStaticData.PropertyName))
self.heroName.text =heroStaticData.ReadingName --string.format("lv.%s", heroData.lv)
Util.GetGameObject(self.transform,"Pos"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroPosBgStr(heroStaticData.Profession))
self.posImage.sprite=Util.LoadSprite(GetHeroPosStr(heroStaticData.Profession))
self.posText.text=heroStaticData.HeroLocation
local d=RecruitManager.GetExpendData(type)
self.againIcon.sprite=Util.LoadSprite(artResourcesConfig[itemConfig[d[1]].ResourceID].Name)
self.againNum.text="×"..d[2]
this.rolePanel:SetActive(true)
PlayUIAnim(self.transform)
isFirst=false
--10连
if state == 2 then
-- self:TenOpenPanel(heroData)
this.jumpBtn:SetActive(false)
Util.GetGameObject(self.transform, "rolePanel/rolePanel2"):SetActive(true)
this.sureBtn:SetActive(false)
this.againBtn:SetActive(false)
this.goBtn:SetActive(true)
else
this.goBtn:SetActive(heroStaticData.Star == 5 or heroStaticData.Star == 4)
this.jumpBtn:SetActive(false)
this.sureBtn:SetActive(heroStaticData.Star ~= 5 and heroStaticData.Star ~= 4)
this.againBtn:SetActive(heroStaticData.Star ~= 5 and heroStaticData.Star ~= 4)
Util.GetGameObject(self.transform, "rolePanel/rolePanel2"):SetActive(true)
if heroStaticData.Quality == 5 and heroStaticData.Natural >= 13 then
HeroManager.DetectionOpenFiveStarActivity(heroStaticData.Star)
end
end
-- end, timeNum2)
-- time2:Start()
end
function SingleRecruitPanel:OnClose()
_heroTable={}
index=0
if time ~= nil then
time:Stop()
end
if heroStaticData then
poolManager:UnLoadLive(GetResourcePath(heroStaticData.Live), testLiveGO)
end
heroStaticData, testLiveGO = nil, nil
end
function SingleRecruitPanel:GetProStr(index)
local proStr=""
if index==1 then
proStr=Language[11769]
elseif index==2 then
proStr=Language[11770]
elseif index==3 then
proStr=Language[11771]
elseif index==4 then
proStr=Language[11772]
elseif index==5 then
proStr=Language[11773]
elseif index==6 then
proStr=Language[11774]
end
return proStr
end
function SingleRecruitPanel:OnDestroy()
end
return SingleRecruitPanel