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

427 lines
18 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 recruitType={}--前端显示用 抽卡类型
local state --1单抽 2多抽
local index=0 --十连抽索引
local orginLayer
local heroStaticData
local testLiveGO
local maxTimesId--特权id上限今日召唤上限
local _heroTable={} --符合4、5星的英雄容器
this.time = Timer.New()
this.time2 = Timer.New()
this.time3 = Timer.New()
--初始化组件(用于子类重写)
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.jumpPanel = Util.GetGameObject(self.transform, "jumpPanel")
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(this.jumpPanel.transform, "btnContinue/jumpBtn")
this.jumpBtnGo = Util.GetGameObject(this.jumpPanel.transform, "btnContinue")
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,"BodyBg/Viewport/Body"):GetComponent("Text")
this.infoBodyGo=Util.GetGameObject(this.info,"BodyBg")
end
--绑定事件(用于子类重写)
function SingleRecruitPanel:BindEvent()
Util.AddClick(self.sureBtn, function()
isFirst=true
if lotterySetting[type].LotteryType == 11 then
isFirst=false
end
self:ClosePanel()
if PlayerManager.IsGetFiveStarHero then--and OperatingManager.IsShowFiveStarPatch then
Game.GlobalEvent:DispatchEvent(GameEvent.PatFace.PatFaceSend, FacePanelType.GrowGift, 5)
PlayerManager.IsGetFiveStarHero = false
end
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
if d[1] == 16 then
if lotterySetting[type].MoneyTimes and lotterySetting[type].MoneyTimes > 0 and PrivilegeManager.GetPrivilegeRemainValue(lotterySetting[type].MoneyTimes) < 1 then
PopupTipPanel.ShowTip("今日妖晶召唤次数不足!")
return
end
end
local recruitOne = function()
RecruitManager.RecruitRequest(type,function(msg)
if d[1] == 16 and lotterySetting[type].MoneyTimes and lotterySetting[type].MoneyTimes > 0 then
PrivilegeManager.RefreshPrivilegeUsedTimes(lotterySetting[type].MoneyTimes,1)--记录妖晶限购抽卡次数
end
PrivilegeManager.RefreshPrivilegeUsedTimes(maxTimesId,1)--记录抽卡次数
for i=1, #msg.drop.Hero do
heroData = msg.drop.Hero[i]
self:UpdataPanelData(heroData)
end
end,maxTimesId)
end
local state = PlayerPrefs.GetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..recruitType[2])
if state==0 and d[1] == 16 then
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecruitConfirm,type,recruitOne)
else
recruitOne()
end
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(this.jumpBtn, function()
isFirst=true
this.CloseAllTimer()
if state==1 then --单抽
this.UI_Effect_open:SetActive(false)
self:UpdataPanelData(heroData)
this.goBtn:SetActive(false)
this.againBtn:SetActive(true)
this.sureBtn:SetActive(true)
this.info:SetActive(false)
else
if lotterySetting[type].LotteryType == 11 then
isFirst=false
end
self:ClosePanel()
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData,type,recruitType)
end
this.jumpBtnGo:SetActive(false)
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
if lotterySetting[type].LotteryType == 11 then
isFirst=false
end
self:ClosePanel()
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData,type,recruitType)
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
this.jumpPanel:GetComponent("Canvas").sortingOrder = self.sortingOrder + 10
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]
recruitType=data[4]
end
function SingleRecruitPanel:OnShow()
isFirst=true
maxTimesId=lotterySetting[type].MaxTimes --特权上限ID
index=0
this.jumpBtnGo:SetActive(true)
if state==1 then --单抽
if lotterySetting[type].LotteryType == 11 then
isFirst=false
end
self:TenOpenPanel()
elseif state==2 then
isFirst=true
if lotterySetting[type].LotteryType == 11 then
isFirst=false
end
_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
this.CloseAllTimer()
--当单抽 或者是 十连抽第一次的时候
if state==1 or isFirst then
this.rolePanel:SetActive(false)
this.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)
this.time:Start()
this.time3 = Timer.New(function ()
this.UI_Effect_open:SetActive(false)
end, 4)
this.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
this.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,recruitType)
end
end
end, timeNum2)
this.time2:Start()
end
function SingleRecruitPanel:UpdataPanelData(_heroData)
--赋值展示界面数据
-- local time2 = Timer.New(function ()
this.CloseAllTimer()
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.infoBodyGo: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 passiveSkillConfig = passiveSkillConfig[heroStaticData.OpenPassiveSkillRules[i][3]]
if passiveSkillConfig and passiveSkillLogicConfig[passiveSkillConfig.Id].Judge == 1 and string.len(passiveSkillConfig.Desc) > 1 then
local d = {}
d.passiveSkillConfig = passiveSkillConfig
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
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,1,Vector2.New(52,52),-2,Vector2.New(0.5,0.5))
-- 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
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.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
this.jumpBtnGo:SetActive(false)
end
end
function SingleRecruitPanel:OnClose()
_heroTable={}
index=0
this.CloseAllTimer()
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
function this.CloseAllTimer()
if this.time then
this.time:Stop()
this.time = nil
end
if this.time2 then
this.time2:Stop()
this.time2 = nil
end
if this.time3 then
this.time3:Stop()
this.time3 = nil
end
end
return SingleRecruitPanel