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

356 lines
15 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
SingleRecruitPanel = Inherit(BasePanel)
local this=SingleRecruitPanel
local heroConfigData = ConfigManager.GetConfig(ConfigName.HeroConfig)
2020-05-25 19:16:23 +08:00
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)
2020-05-09 13:31:21 +08:00
local isFirst=true--是否为第一次进入界面
local timeNum--第一个特效等待播放的时间
local timeNum2--第二个特效等待播放的时间
local timeNum3--第三个特效等待播放的时间
local heroData--展示界面需要的单个英雄数据
2020-05-25 19:16:23 +08:00
local type--抽卡类型
local state --1单抽 2多抽
2020-05-09 13:31:21 +08:00
local index=0 --十连抽索引
local orginLayer
local heroStaticData
local testLiveGO
2020-05-25 19:16:23 +08:00
local maxTimesId--特权id上限今日召唤上限
local _heroTable={} --符合4、5星的英雄容器
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function SingleRecruitPanel:InitComponent()
orginLayer = 0
self.live2dRoot = Util.GetGameObject(self.gameObject, "rolePanel/live2dRoot")
self.bg = Util.GetGameObject(self.gameObject, "bg")
screenAdapte(self.bg)
2020-05-25 19:16:23 +08:00
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")
2020-05-09 13:31:21 +08:00
self.sureBtn = Util.GetGameObject(self.transform, "rolePanel/rolePanel2/sureBtn")
self.againBtn = Util.GetGameObject(self.transform, "rolePanel/rolePanel2/againBtn")
2020-05-25 19:16:23 +08:00
self.againIcon=Util.GetGameObject(self.againBtn,"Tip/juan"):GetComponent("Image")
self.againNum=Util.GetGameObject(self.againBtn,"Tip/Text"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
self.dragView = SubUIManager.Open(SubUIConfig.DragView, self.gameObject.transform)
self.dragView.transform:SetSiblingIndex(1)
this.rolePanel = Util.GetGameObject(self.transform, "rolePanel")
2020-05-25 19:16:23 +08:00
this.UI_Effect_open = Util.GetGameObject(self.transform, "bg/UI_Effect_open") --开门特效
2020-05-09 13:31:21 +08:00
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")
2020-05-25 19:16:23 +08:00
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")
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function SingleRecruitPanel:BindEvent()
Util.AddClick(self.sureBtn, function()
isFirst=true
self:ClosePanel()
end)
Util.AddClick(self.againBtn, function()
2020-05-25 19:16:23 +08:00
local d=RecruitManager.GetExpendData(type)
if BagManager.GetItemCountById(d[1])<d[2] then
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(itemConfig[d[1]].Name..Language[10492])
2020-05-09 13:31:21 +08:00
return
end
2020-05-25 19:16:23 +08:00
if PrivilegeManager.GetPrivilegeUsedTimes(maxTimesId)+1>privilegeConfig[maxTimesId].Condition[1][2] then
2020-06-23 18:36:24 +08:00
PopupTipPanel.ShowTip(Language[11760])
2020-05-25 19:16:23 +08:00
return
end
RecruitManager.RecruitRequest(type,function(msg)
2020-06-03 19:09:01 +08:00
PrivilegeManager.RefreshPrivilegeUsedTimes(maxTimesId,1)--记录抽卡次数
2020-05-09 13:31:21 +08:00
for i=1, #msg.drop.Hero do
heroData = msg.drop.Hero[i]
self:UpdataPanelData(heroData)
2020-06-28 17:48:49 +08:00
end
end,maxTimesId)
2020-05-09 13:31:21 +08:00
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()
2020-05-25 19:16:23 +08:00
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
2020-05-09 13:31:21 +08:00
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]
2020-05-25 19:16:23 +08:00
state=data[3]
2020-05-09 13:31:21 +08:00
end
function SingleRecruitPanel:OnShow()
2020-06-28 17:48:49 +08:00
maxTimesId=lotterySetting[type].MaxTimes --特权上限ID
2020-05-09 13:31:21 +08:00
index=0
2020-05-25 19:16:23 +08:00
if state==1 then --单抽
self:TenOpenPanel()
elseif state==2 then
2020-05-09 13:31:21 +08:00
isFirst=true
2020-05-25 19:16:23 +08:00
_heroTable={}
--将符合条件的英雄插入容器中
for k, v in ipairs(heroData) do
if heroConfigData[v.heroId].Star==4 or heroConfigData[v.heroId].Star==5 then
2020-06-03 19:09:01 +08:00
-- LogBlue(heroConfigData[v.heroId].ReadingName)
2020-05-25 19:16:23 +08:00
table.insert(_heroTable,v)
end
end
2020-06-03 19:09:01 +08:00
-- LogGreen("符合条件的英雄数量"..LengthOfTable(_heroTable))
2020-05-25 19:16:23 +08:00
self:TenOpenPanel()
2020-05-09 13:31:21 +08:00
end
end
2020-05-25 19:16:23 +08:00
local time--十连抽每次展示特效time
function SingleRecruitPanel:TenOpenPanel()
2020-05-09 13:31:21 +08:00
if isFirst then --第一次进来
this.UI_Effect_open:SetActive(true)
2020-05-25 19:16:23 +08:00
index=1
timeNum3=0
2020-05-09 13:31:21 +08:00
timeNum=1.3
timeNum2=4.3
else--以后每次进来
this.UI_Effect_open:SetActive(false)
2020-05-25 19:16:23 +08:00
index=index+1
timeNum3=2
2020-05-09 13:31:21 +08:00
timeNum=0
2020-05-25 19:16:23 +08:00
timeNum2=0
2020-05-09 13:31:21 +08:00
end
--当单抽 或者是 十连抽第一次的时候
2020-05-25 19:16:23 +08:00
if state==1 or isFirst then
2020-05-09 13:31:21 +08:00
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)
2020-05-25 19:16:23 +08:00
end, 4)
2020-05-09 13:31:21 +08:00
time3:Start()
2020-05-25 19:16:23 +08:00
elseif state==2 then-- 十连抽
-- timeNum2=0
2020-05-09 13:31:21 +08:00
--this.UI_Effect_choukaSSR:SetActive(false)
--this.UI_Effect_choukaSR:SetActive(false)
--this.UI_Effect_choukaR:SetActive(false)
end
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
local time2 = Timer.New(function ()
2020-05-25 19:16:23 +08:00
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 ()
2020-05-09 13:31:21 +08:00
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]
2020-05-25 19:16:23 +08:00
-- Log("heroStaticData.Live:"..heroStaticData.Live)
--不同星级开启不同特效
2020-05-09 13:31:21 +08:00
this.UI_Effect_choukaSSR:SetActive(heroStaticData.Star == 5)
this.UI_Effect_choukaSR:SetActive(heroStaticData.Star == 4)
2020-05-25 19:16:23 +08:00
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]
2020-06-23 18:36:24 +08:00
d.titleStr = "<size=34><color=#5AC383>"..NumToSimplenessFont[heroRankupConfig[heroStaticData.OpenPassiveSkillRules[i][2]].Phase[2]] .. Language[11767]
2020-05-25 19:16:23 +08:00
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
2020-06-23 18:36:24 +08:00
table.insert(t,Language[11768]..passiveSkillConfig[dowerData[n].OpenSkillRules[1]].Desc.."\n")
2020-05-25 19:16:23 +08:00
end
end
local s=table.concat(t)--将表里字符串拼接
--看这下面 是全角空格哦~
this.infoBody.text=string.sub(string.gsub(s," "," "),1,-2)--去除最后\n
end
2020-05-09 13:31:21 +08:00
--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)
2020-07-27 18:00:45 +08:00
SetHeroStars(self.starGrid, _heroData.star,1,Vector2.New(52,52),-2,Vector2.New(0.5,0.5))
2020-05-25 19:16:23 +08:00
-- self.profession.sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(heroStaticData.Profession))
2020-05-09 13:31:21 +08:00
self.proImage.sprite =Util.LoadSprite(GetProStrImageByProNum(heroStaticData.PropertyName))
self.heroName.text =heroStaticData.ReadingName --string.format("lv.%s", heroData.lv)
2020-06-19 20:19:35 +08:00
Util.GetGameObject(self.transform,"Pos"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroPosBgStr(heroStaticData.Profession))
2020-05-09 13:31:21 +08:00
self.posImage.sprite=Util.LoadSprite(GetHeroPosStr(heroStaticData.Profession))
self.posText.text=heroStaticData.HeroLocation
2020-05-25 19:16:23 +08:00
local d=RecruitManager.GetExpendData(type)
self.againIcon.sprite=Util.LoadSprite(artResourcesConfig[itemConfig[d[1]].ResourceID].Name)
self.againNum.text="×"..d[2]
2020-05-09 13:31:21 +08:00
this.rolePanel:SetActive(true)
PlayUIAnim(self.transform)
isFirst=false
2020-05-25 19:16:23 +08:00
--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)
2020-05-09 13:31:21 +08:00
else
2020-05-25 19:16:23 +08:00
this.goBtn:SetActive(heroStaticData.Star == 5 or heroStaticData.Star == 4)
2020-05-09 13:31:21 +08:00
this.jumpBtn:SetActive(false)
2020-05-25 19:16:23 +08:00
this.sureBtn:SetActive(heroStaticData.Star ~= 5 and heroStaticData.Star ~= 4)
this.againBtn:SetActive(heroStaticData.Star ~= 5 and heroStaticData.Star ~= 4)
2020-05-09 13:31:21 +08:00
Util.GetGameObject(self.transform, "rolePanel/rolePanel2"):SetActive(true)
if heroStaticData.Quality == 5 and heroStaticData.Natural >= 13 then
HeroManager.DetectionOpenFiveStarActivity(heroStaticData.Star)
end
end
2020-05-25 19:16:23 +08:00
-- end, timeNum2)
-- time2:Start()
2020-05-09 13:31:21 +08:00
end
function SingleRecruitPanel:OnClose()
2020-05-25 19:16:23 +08:00
_heroTable={}
index=0
2020-05-09 13:31:21 +08:00
if time ~= nil then
time:Stop()
end
if heroStaticData then
poolManager:UnLoadLive(GetResourcePath(heroStaticData.Live), testLiveGO)
end
heroStaticData, testLiveGO = nil, nil
end
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
function SingleRecruitPanel:GetProStr(index)
local proStr=""
if index==1 then
2020-06-23 18:36:24 +08:00
proStr=Language[11769]
2020-05-09 13:31:21 +08:00
elseif index==2 then
2020-06-23 18:36:24 +08:00
proStr=Language[11770]
2020-05-09 13:31:21 +08:00
elseif index==3 then
2020-06-23 18:36:24 +08:00
proStr=Language[11771]
2020-05-09 13:31:21 +08:00
elseif index==4 then
2020-06-23 18:36:24 +08:00
proStr=Language[11772]
2020-05-09 13:31:21 +08:00
elseif index==5 then
2020-06-23 18:36:24 +08:00
proStr=Language[11773]
2020-05-09 13:31:21 +08:00
elseif index==6 then
2020-06-23 18:36:24 +08:00
proStr=Language[11774]
2020-05-09 13:31:21 +08:00
end
return proStr
end
2020-05-25 19:16:23 +08:00
2020-05-09 13:31:21 +08:00
function SingleRecruitPanel:OnDestroy()
end
2020-06-23 18:36:24 +08:00
return SingleRecruitPanel