341 lines
16 KiB
Lua
341 lines
16 KiB
Lua
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
GodsWaySingleSingleWave = {}
|
||
|
||
function GodsWaySingleSingleWave:New(gameObject)
|
||
local b = {}
|
||
b.gameObject = gameObject
|
||
b.transform = gameObject.transform
|
||
setmetatable(b, { __index = GodsWaySingleSingleWave })
|
||
return b
|
||
end
|
||
local curType=0
|
||
--初始化组件(用于子类重写)
|
||
function GodsWaySingleSingleWave:InitComponent(go,_data,_curType)
|
||
self.spLoader = SpriteLoader.New()
|
||
curType=_curType
|
||
self.wave = Util.GetGameObject(go,"bg/leftLayout/num"):GetComponent("Text")
|
||
self.power = Util.GetGameObject(go,"bg/power/Text"):GetComponent("Text")
|
||
self.reward = Util.GetGameObject(go,"bg/rewardRect")
|
||
self.fight = Util.GetGameObject(go,"bg/fight")
|
||
self.pass = Util.GetGameObject(go,"bg/pass"):GetComponent("Image")
|
||
self.title = Util.GetGameObject(go,"bg/leftLayout/title"):GetComponent("Image")
|
||
self.rewardText = Util.GetGameObject(self.reward,"Text"):GetComponent("Text")
|
||
self.fightBtnIcon = Util.GetGameObject(self.fight,"layout/icon"):GetComponent("Image")
|
||
self.fightBtnNum = Util.GetGameObject(self.fight,"layout/num"):GetComponent("Text")
|
||
self.fightBtnText = Util.GetGameObject(self.fight,"layout/Text"):GetComponent("Text")
|
||
self.fightBtnRed = Util.GetGameObject(self.fight,"red")
|
||
self.fightBtnMask = Util.GetGameObject(self.fight,"mask"):GetComponent("Image")
|
||
self.bg = Util.GetGameObject(go,"bg"):GetComponent("Image")
|
||
self.rewardGrid = Util.GetGameObject(self.reward,"grid")
|
||
|
||
self.btn=Util.GetGameObject(go,"bg/btn")
|
||
self.data = _data
|
||
self.heroList={}
|
||
self.trailData = MonsterCampManager.GetCurFourElementMonsterInfo(_curType)
|
||
for i = 1, 3 do
|
||
table.insert(self.heroList,Util.GetGameObject(go,"bg/grid/Hero"..i))
|
||
end
|
||
self.rewardList = {}
|
||
for i = 1, self.rewardGrid.transform.childCount do
|
||
local temp = self:NewItemView(SubUIConfig.ItemView, self.rewardGrid.transform:GetChild(i-1).gameObject)
|
||
table.insert(self.rewardList,temp)
|
||
end
|
||
end
|
||
local teamIds={
|
||
[1]={3206,3207},
|
||
[2]={3203,3204,3205},
|
||
}
|
||
local curFloor=0
|
||
function GodsWaySingleSingleWave:OnOpen()
|
||
curFloor=GodsWayTowerManager.GetTowerFloorByType(curType)
|
||
self.fightBtnIcon.gameObject:SetActive(false)
|
||
self.fightBtnNum.gameObject:SetActive(false)
|
||
self.wave.text = "第"..self.data.wave.."层"
|
||
self.power.text = self.data.power
|
||
--self.title.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(self.trailData.fourElementType))
|
||
--self.bg.sprite = self.spLoader:LoadSprite(GetFourElementBgByType(self.trailData.fourElementType))
|
||
self:UpdatePrivilage()
|
||
if self.data.wave < curFloor then
|
||
self.pass.gameObject:SetActive(false)
|
||
self.fight.gameObject:SetActive(false)
|
||
self.reward.gameObject:SetActive(false)
|
||
else
|
||
self.pass.gameObject:SetActive(false)
|
||
self.fight.gameObject:SetActive(true)
|
||
self.rewardText.text = "挑战奖励"
|
||
|
||
self:SetIcon()
|
||
LogError("#self.rewardData===="..#self.rewardData)
|
||
if self.rewardData and #self.rewardData then
|
||
self:InitShowReward()
|
||
self.reward.gameObject:SetActive(true)
|
||
else
|
||
self.reward.gameObject:SetActive(false)
|
||
end
|
||
end
|
||
for i = 1, 3 do
|
||
self.heroList[i].gameObject:SetActive(false)
|
||
if self.data.herodatas[i] then
|
||
self.heroList[i].gameObject:SetActive(true)
|
||
self:SingleHeroDataShow(self.heroList[i],self.data.monsterConfig[i],self.data.herodatas[i],i,#self.data.herodatas)
|
||
end
|
||
end
|
||
|
||
Util.AddOnceClick(self.pass.gameObject, function()
|
||
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.FourElementMonster,self.trailData.fourElementType,self.data.wave)
|
||
end)
|
||
-- Util.AddOnceClick(self.hero, function()
|
||
-- UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.FourElementMonster,self.trailData.fourElementType,self.data.wave)
|
||
-- end)
|
||
Util.AddOnceClick(self.btn, function()
|
||
LogError("self.data.wave=="..self.data.wave)
|
||
UIManager.OpenPanel(UIName.GodsWayOtherTeamPanel,curType,self.data.wave)
|
||
end)
|
||
Util.AddOnceClick(self.fight, function()
|
||
local x = function()
|
||
NetManager.RequestDuoDuiChallenge(curType,curFloor,2,function(msg)
|
||
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1)
|
||
local freeId=GodsWayTowerManager.GetTowerFreeIdByType(curType)
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(freeId, 1)
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.FourEle.UpdatePri)
|
||
self:UpdatePrivilage()
|
||
end)
|
||
end
|
||
if self.data.wave == curFloor then
|
||
-- if self.freeTimes <=0 and self.buyTimes <= 0 then
|
||
-- PopupTipPanel.ShowTip("今日已无扫荡次数!")
|
||
-- return
|
||
-- end
|
||
-- if self.freeTimes <= 0 then
|
||
-- if BagManager.GetItemCountById(self.itemId) < self.costNum then
|
||
-- PopupTipPanel.ShowTip(string.format(Language[10298], itemConfig[self.itemId].Name))
|
||
-- return
|
||
-- end
|
||
-- local buyId=GodsWayTowerManager.GetTowerBuyIdByType(curType)
|
||
-- MsgPanel.ShowTwo(string.format("是否花费%s%s购买一次扫荡次数?",self.costNum,itemConfig[self.itemId].Name),function() end,function()
|
||
-- ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,self.storeDataId,1,function()
|
||
-- PrivilegeManager.RefreshPrivilegeUsedTimes(buyId, 1)
|
||
-- x()
|
||
-- end)
|
||
-- end,"取消","确定")
|
||
-- else
|
||
-- x()
|
||
--
|
||
PopupTipPanel.ShowTip("已通关最高层")
|
||
return
|
||
elseif self.data.wave == curFloor + 1 then
|
||
local teamType=0
|
||
local myTeams=teamIds[curType]
|
||
local floor=GodsWayTowerManager.GetTowerFloorByType(curType)
|
||
-- if self.trailData.canFightTime > 0 then
|
||
local windData={}
|
||
--我的队伍
|
||
local myTeamInfo={}
|
||
--敌方队伍
|
||
local enTeamInfo={}
|
||
--获取双方队伍数据
|
||
local allHeroTeam={}
|
||
local allEnTeam={}
|
||
local myTeamNum=0
|
||
for i = 1, #myTeams do
|
||
--local fightData=fightDataList[i]
|
||
local heroTeam={}
|
||
heroTeam.team={}
|
||
heroTeam.totalForce=FormationManager.GetFormationPower(myTeams[i])
|
||
--LogError("myforce=="..msg.recordData.yxldMyForce[i])
|
||
local enTeam={}
|
||
enTeam.team={}
|
||
|
||
--LogError("en force=="..msg.recordData.yxldDefForce[i])
|
||
local myteam=FormationManager.GetFormationByID(myTeams[i])
|
||
for j = 1, #myteam.teamHeroInfos do
|
||
myTeamNum=myTeamNum+1
|
||
local hero=myteam.teamHeroInfos[j]
|
||
local newHero={}
|
||
local heroData=HeroManager.GetSingleHeroData(hero.heroId)
|
||
newHero.heroTid=heroData.heroConfig.Id
|
||
--local pro=string.split(hero.property,"#")
|
||
newHero.level=heroData.lv
|
||
newHero.heroid=heroData.dynamicId
|
||
newHero.star=heroData.star
|
||
--newHero.godSoulLv = hero.godSoulLv
|
||
newHero.position=hero.position
|
||
newHero.skinId=heroData.skinId
|
||
table.insert(heroTeam.team,newHero)
|
||
end
|
||
LogError("Type====="..curType.." TowerNumber====="..floor.." TowerWave1"..i)
|
||
local monsterData=ConfigManager.TryGetConfigDataByThreeKey(ConfigName.DuoDuiTower,"Type",curType,"TowerNumber",floor+1,"TowerWave1",i)
|
||
if monsterData then
|
||
enTeam.totalForce=monsterData.Force
|
||
for j = 1, #monsterData.Hero do
|
||
local hero=monsterData.Hero[j]
|
||
local config=ConfigManager.GetConfigData(ConfigName.DuoDuiTowerHero,hero)
|
||
local newHero={}
|
||
newHero.heroTid=config.Hero
|
||
--local pro=string.split(hero.property,"#")
|
||
newHero.level=monsterData.Level
|
||
--newHero.heroid=hero.realId
|
||
newHero.star=monsterData.Star
|
||
--newHero.godSoulLv = hero.godSoulLv
|
||
newHero.position=j
|
||
--newHero.skinId=hero.skinId
|
||
table.insert(enTeam.team,newHero)
|
||
end
|
||
end
|
||
table.insert(allHeroTeam,heroTeam)
|
||
table.insert(allEnTeam,enTeam)
|
||
-- allHeroTeam[i]=heroTeam
|
||
-- allEnTeam[i]=enTeam
|
||
end
|
||
if myTeamNum==0 then
|
||
PopupTipPanel.ShowTip("编对为空,无法开战")
|
||
return
|
||
end
|
||
myTeamInfo.crossTeam=allHeroTeam
|
||
enTeamInfo.crossTeam=allEnTeam
|
||
|
||
windData.myTeamInfo=myTeamInfo
|
||
windData.defTeamInfo=enTeamInfo
|
||
windData.fightData=fightDataList
|
||
UIManager.OpenPanel(UIName.GodsWayBattleInfoPanel,windData,1,curType)
|
||
end
|
||
|
||
--end
|
||
end)
|
||
end
|
||
-- 初始化奖励显示
|
||
function GodsWaySingleSingleWave:InitShowReward()
|
||
for i = 1 ,#self.rewardList do
|
||
self.rewardList[i].gameObject:SetActive(false)
|
||
end
|
||
--LogError("#self.rewardData=="..#self.rewardData)
|
||
for i = 1,#self.rewardData do
|
||
if not self.rewardList[i] then
|
||
self.rewardList[i] = SubUIManager.Open(SubUIConfig.ItemView, self.rewardGrid.transform)
|
||
self.rewardList[i].gameObject:SetActive(false)
|
||
end
|
||
self.rewardList[i]:OnOpen(false, {self.rewardData[i].id,self.rewardData[i].num}, 0.55,false,false,false)
|
||
self.rewardList[i].gameObject:SetActive(true)
|
||
end
|
||
end
|
||
|
||
--设置每条英雄数据
|
||
function GodsWaySingleSingleWave:SingleHeroDataShow(go,monConfig,heroData,index,len)
|
||
local frame=Util.GetGameObject(go,"Bg1"):GetComponent("Image")
|
||
local icon=Util.GetGameObject(go, "Mask/icon"):GetComponent("RawImage")
|
||
--self.icon=Util.GetGameObject(self.hero, "Mask/icon"):GetComponent("Image")
|
||
local lv = Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
|
||
local pro = Util.GetGameObject(go, "Pro/Image"):GetComponent("Image")
|
||
local fg = Util.GetGameObject(go,"Bg2"):GetComponent("Image")
|
||
--self.starGrid = Util.GetGameObject(self.hero,"starGrid")
|
||
local starGrid = Util.GetGameObject(go,"StarGrid")
|
||
local name=Util.GetGameObject(go,"Name/Text"):GetComponent("Text")
|
||
Util.GetGameObject(go,"yuanImage"):SetActive(false)
|
||
Util.GetGameObject(go,"hpProgress"):SetActive(false)
|
||
Util.GetGameObject(go,"rageProgress"):SetActive(false)
|
||
--frame.sprite=self.spLoader:LoadSprite(GetHeroCardStarBg[monConfig.Star])
|
||
local liveName = heroData.painting
|
||
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, heroData.heroConfig.Id)
|
||
local scale = roleConfig.play_liveScale
|
||
local heroIndex=(self.data.wave-1)*len+index
|
||
--LogError("self.data.wave=="..self.data.wave.." index=="..index.." heroindex=="..heroIndex)
|
||
--icon.texture = CardRendererManager.GetSpineTexture((self.data.wave%6 == 0 and 12 or (self.data.wave%6 + 6)), liveName, Vector3.one * scale, livePos, true)
|
||
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2]+50, 0)
|
||
icon.texture = CardRendererManager.GetSpineTexture(heroIndex%12==0 and 12 or heroIndex%12, liveName, Vector3.one * scale, livePos, true)
|
||
icon.transform.localScale = Vector3.one
|
||
icon.transform.localPosition = Vector3.zero
|
||
lv.text = monConfig.Level
|
||
pro.sprite= self.spLoader:LoadSprite(GetProStrImageByProNum(heroData.property))
|
||
--self.icon.sprite = self.spLoader:LoadSprite(heroData.painting)
|
||
SetCardStars(starGrid,monConfig.Star)
|
||
fg.sprite = self.spLoader:LoadSprite(GetHeroCardStarFg[monConfig.Star])
|
||
name.text = heroData.name
|
||
end
|
||
|
||
function GodsWaySingleSingleWave:UpdatePrivilage()
|
||
LogError("curtype============"..curType)
|
||
self.storeDataId,self.itemId,self.costNum = GodsWayTowerManager.GetCost(curType)
|
||
self.freeTimes,self.buyTimes = GodsWayTowerManager.GetTimeTip(curType)
|
||
self:SetIcon()
|
||
end
|
||
|
||
function GodsWaySingleSingleWave:SetIcon()
|
||
Util.SetGray(self.fight,false)
|
||
self.fightBtnRed:SetActive(false)
|
||
if self.data.wave == curFloor then
|
||
self.rewardData = self.data.firstReward
|
||
--设置扫荡按钮
|
||
self.rewardText.text = "扫荡奖励"
|
||
if self.freeTimes > 0 then
|
||
self.fightBtnIcon.gameObject:SetActive(false)
|
||
self.fightBtnNum.gameObject:SetActive(false)
|
||
self.fightBtnRed:SetActive(true)
|
||
self.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","免费扫荡")
|
||
--self.fightBtnMask.sprite = self.spLoader:LoadSprite("r_guji_jihuianniu_02")
|
||
Util.SetGray(self.fight,false)
|
||
else
|
||
--self.fightBtnMask.sprite = self.spLoader:LoadSprite("r_guji_jihuianniu_02")
|
||
self.fightBtnIcon.gameObject:SetActive(false)
|
||
self.fightBtnNum.gameObject:SetActive(false)
|
||
self.fightBtnIcon.sprite = self.spLoader:LoadSprite(GetResourcePath(itemConfig[self.itemId].ResourceID))
|
||
local color = 0
|
||
LogError("self.itemId==="..self.itemId)
|
||
LogError("self.costNum=="..self.costNum)
|
||
if BagManager.GetItemCountById(self.itemId) < self.costNum then
|
||
color = "E71515"
|
||
else
|
||
color = "17232A"
|
||
end
|
||
self.fightBtnNum.text =string.format("<color=#%s>%s</color>",color,self.costNum)
|
||
--.fightBtnText.text = string.format("<color=#%s>%s</color>",color,"扫荡")
|
||
if self.buyTimes < 1 then
|
||
Util.SetGray(self.fight,true)
|
||
end
|
||
self.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","已通关")
|
||
end
|
||
else
|
||
self.rewardData = self.data.firstReward
|
||
LogError("self.data.wave=="..self.data.wave.." floor+1=="..curFloor+1)
|
||
if self.data.wave == curFloor + 1 then
|
||
--设置挑战fight
|
||
self.fightBtnIcon.gameObject:SetActive(false)
|
||
self.fightBtnNum.gameObject:SetActive(false)
|
||
--self.fightBtnMask:GetComponent("Image").sprite = self.spLoader:LoadSprite("s_shouchong_anniu")
|
||
self.fightBtnText.text = string.format("<color=#%s>%s</color>","17232A","挑战")
|
||
else
|
||
self.fight.gameObject:SetActive(false)
|
||
end
|
||
Util.SetGray(self.fight,false)
|
||
end
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function GodsWaySingleSingleWave:OnDestroy()
|
||
self.rewardList = {}
|
||
self.spLoader:Destroy()
|
||
end
|
||
function GodsWaySingleSingleWave:NewItemView(config, gameObject, ...)
|
||
local view = reimport(config.script)
|
||
local sub = view:New(gameObject)
|
||
sub.assetName = config.assetName
|
||
if sub.Awake then
|
||
sub:Awake()
|
||
end
|
||
if sub.InitComponent then
|
||
sub:InitComponent()
|
||
end
|
||
if sub.BindEvent then
|
||
sub:BindEvent()
|
||
end
|
||
if sub.AddListener then
|
||
sub:AddListener()
|
||
end
|
||
if sub.Update then
|
||
UpdateBeat:Add(sub.Update, sub)
|
||
end
|
||
if sub.OnOpen then
|
||
sub:OnOpen(...)
|
||
end
|
||
return sub
|
||
end
|
||
return GodsWaySingleSingleWave |