268 lines
11 KiB
Lua
268 lines
11 KiB
Lua
|
require("Base/BasePanel")
|
|||
|
SingleRecruitPanel = Inherit(BasePanel)
|
|||
|
local this=SingleRecruitPanel
|
|||
|
local heroConfigData = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|||
|
local isFirst=true--是否为第一次进入界面
|
|||
|
local timeNum--第一个特效等待播放的时间
|
|||
|
local timeNum2--第二个特效等待播放的时间
|
|||
|
local timeNum3--第三个特效等待播放的时间
|
|||
|
local heroData--展示界面需要的单个英雄数据
|
|||
|
local type--类型 11 十连抽 12 单抽
|
|||
|
local index=0 --十连抽索引
|
|||
|
local orginLayer
|
|||
|
local heroStaticData
|
|||
|
local testLiveGO
|
|||
|
--初始化组件(用于子类重写)
|
|||
|
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/heroName"):GetComponent("Text")
|
|||
|
self.profession = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/profession/profession"):GetComponent("Image")
|
|||
|
self.proImage = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/proImage/proImage/proImage"):GetComponent("Image")
|
|||
|
--self.proText = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/proText"):GetComponent("Text")
|
|||
|
--self.posText = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/posText"):GetComponent("Text")
|
|||
|
self.starGrid = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/star")
|
|||
|
self.starPre = Util.GetGameObject(self.transform, "rolePanel/rolePanel1/starPre")
|
|||
|
self.sureBtn = Util.GetGameObject(self.transform, "rolePanel/rolePanel2/sureBtn")
|
|||
|
self.againBtn = Util.GetGameObject(self.transform, "rolePanel/rolePanel2/againBtn")
|
|||
|
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")
|
|||
|
Util.GetGameObject(self.transform,"quality"):SetActive(false)
|
|||
|
self.qualityImage=Util.GetGameObject(self.transform,"quality"):GetComponent("Image")
|
|||
|
self.quality=Util.GetGameObject(self.transform,"quality/qualityText")
|
|||
|
self.doubleQuality=Util.GetGameObject(self.transform,"quality/qualityDoubleText")
|
|||
|
self.posImage=Util.GetGameObject(self.transform,"Pos/PosImage"):GetComponent("Image")
|
|||
|
self.posText=Util.GetGameObject(self.transform,"Pos/PosText"):GetComponent("Text")
|
|||
|
end
|
|||
|
|
|||
|
--绑定事件(用于子类重写)
|
|||
|
function SingleRecruitPanel:BindEvent()
|
|||
|
|
|||
|
Util.AddClick(self.sureBtn, function()
|
|||
|
isFirst=true
|
|||
|
self:ClosePanel()
|
|||
|
--UIManager.OpenPanel(UIName.RecruitPanel)
|
|||
|
end)
|
|||
|
Util.AddClick(self.againBtn, function()
|
|||
|
if PopQuickPurchasePanel(UpViewRechargeType.SpiritTicket,1) then
|
|||
|
return
|
|||
|
end
|
|||
|
RecruitManager.RecruitRequest(RecruitType.Single,function (msg)
|
|||
|
RecruitManager.randCount=RecruitManager.randCount+1
|
|||
|
if(#msg.extraBox.Hero~=0) then
|
|||
|
RecruitManager.randCount=0
|
|||
|
RecruitManager.isCanOpenBox=true
|
|||
|
table.insert( RecruitManager.boxReward,msg.extraBox)
|
|||
|
end
|
|||
|
for i=1, #msg.drop.Hero do
|
|||
|
heroData = msg.drop.Hero[i]
|
|||
|
self:UpdataPanelData(heroData)
|
|||
|
end
|
|||
|
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(self.jumpBtn, function()
|
|||
|
isFirst=true
|
|||
|
self:ClosePanel()
|
|||
|
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData)
|
|||
|
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]
|
|||
|
end
|
|||
|
function SingleRecruitPanel:OnShow()
|
|||
|
index=0
|
|||
|
if type==RecruitType.Single then --单抽
|
|||
|
self:UpdataPanelData(heroData)
|
|||
|
elseif type==RecruitType.Ten then
|
|||
|
isFirst=true
|
|||
|
self:TenOpenPanel(heroData)
|
|||
|
end
|
|||
|
end
|
|||
|
function SingleRecruitPanel:UpdataPanelData(_heroData)
|
|||
|
if isFirst then --第一次进来
|
|||
|
this.UI_Effect_open:SetActive(true)
|
|||
|
timeNum=1.3
|
|||
|
timeNum2=4.3
|
|||
|
else--以后每次进来
|
|||
|
this.UI_Effect_open:SetActive(false)
|
|||
|
timeNum=0
|
|||
|
timeNum2=3
|
|||
|
end
|
|||
|
--当单抽 或者是 十连抽第一次的时候
|
|||
|
if type==RecruitType.Single 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, 5)
|
|||
|
time3:Start()
|
|||
|
elseif type==RecruitType.Ten 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 ()
|
|||
|
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)
|
|||
|
--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)
|
|||
|
--this.quality.sprite=Util.LoadSprite(GetQualityIconByQualityNumer(heroStaticData.Natural))
|
|||
|
self.qualityImage.sprite=GetQuantityImage(heroStaticData.Natural)
|
|||
|
self.quality:SetActive(heroStaticData.Natural < 10)
|
|||
|
self.doubleQuality:SetActive(heroStaticData.Natural >= 10)
|
|||
|
self.quality:GetComponent("Text").text = heroStaticData.Natural
|
|||
|
self.doubleQuality:GetComponent("Text").text = heroStaticData.Natural
|
|||
|
self.posImage.sprite=Util.LoadSprite(GetHeroPosStr(heroStaticData.Profession))
|
|||
|
self.posText.text=heroStaticData.HeroLocation
|
|||
|
this.rolePanel:SetActive(true)
|
|||
|
PlayUIAnim(self.transform)
|
|||
|
isFirst=false
|
|||
|
|
|||
|
if type == RecruitType.Ten then
|
|||
|
self:TenOpenPanel(heroData)
|
|||
|
this.jumpBtn:SetActive(true)
|
|||
|
Util.GetGameObject(self.transform, "rolePanel/rolePanel2"):SetActive(false)
|
|||
|
else
|
|||
|
this.jumpBtn:SetActive(false)
|
|||
|
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
|
|||
|
|
|||
|
local time--十连抽每次展示特效time
|
|||
|
function SingleRecruitPanel:TenOpenPanel(_heroListData)
|
|||
|
if isFirst then
|
|||
|
timeNum3=0
|
|||
|
index=1
|
|||
|
else
|
|||
|
index=index+1
|
|||
|
timeNum3=2
|
|||
|
end
|
|||
|
time = Timer.New(function ()
|
|||
|
if index>10 then
|
|||
|
isFirst=true
|
|||
|
self:ClosePanel()
|
|||
|
UIManager.OpenPanel(UIName.TenRecruitPanel,heroData)
|
|||
|
else
|
|||
|
self:UpdataPanelData(_heroListData[index])
|
|||
|
end
|
|||
|
end, timeNum3)
|
|||
|
time:Start()
|
|||
|
end
|
|||
|
|
|||
|
--界面关闭时调用(用于子类重写)
|
|||
|
function SingleRecruitPanel:OnClose()
|
|||
|
|
|||
|
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="火"
|
|||
|
elseif index==2 then
|
|||
|
proStr="水"
|
|||
|
elseif index==3 then
|
|||
|
proStr="风"
|
|||
|
elseif index==4 then
|
|||
|
proStr="地"
|
|||
|
elseif index==5 then
|
|||
|
proStr="光"
|
|||
|
elseif index==6 then
|
|||
|
proStr="暗"
|
|||
|
end
|
|||
|
return proStr
|
|||
|
end
|
|||
|
--界面销毁时调用(用于子类重写)
|
|||
|
function SingleRecruitPanel:OnDestroy()
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
return SingleRecruitPanel
|