英雄解锁和强制上阵的判定
This commit is contained in:
parent
ce6c6feee3
commit
9be9feefbd
@ -38,6 +38,9 @@ local LocalizationGlobalConst =
|
|||||||
REWARD_PREVIEW_DESC = "REWARD_PREVIEW_DESC",
|
REWARD_PREVIEW_DESC = "REWARD_PREVIEW_DESC",
|
||||||
HERO_DESC_8 = "HERO_DESC_8",
|
HERO_DESC_8 = "HERO_DESC_8",
|
||||||
HERO_DESC_9 = "HERO_DESC_9",
|
HERO_DESC_9 = "HERO_DESC_9",
|
||||||
|
|
||||||
|
BATTLE_DESC_8 = "BATTLE_DESC_8",
|
||||||
|
HERO_DESC_10 = "HERO_DESC_10",
|
||||||
}
|
}
|
||||||
|
|
||||||
return LocalizationGlobalConst
|
return LocalizationGlobalConst
|
||||||
@ -38,6 +38,9 @@ local localization_global =
|
|||||||
["REWARD_PREVIEW_DESC"] = "奖励预览",
|
["REWARD_PREVIEW_DESC"] = "奖励预览",
|
||||||
["HERO_DESC_8"] = "使用",
|
["HERO_DESC_8"] = "使用",
|
||||||
["HERO_DESC_9"] = "信息",
|
["HERO_DESC_9"] = "信息",
|
||||||
|
|
||||||
|
["HERO_DESC_10"] = "通关章节{0}解锁",
|
||||||
|
["BATTLE_DESC_8"] = "还有可上阵英雄",
|
||||||
}
|
}
|
||||||
|
|
||||||
return localization_global
|
return localization_global
|
||||||
@ -20,6 +20,10 @@ function ChapterManager:openBox(chapterId, index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ChapterManager:startFight()
|
function ChapterManager:startFight()
|
||||||
|
if not ModuleManager.FormationManager:formationIsFull() then
|
||||||
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8))
|
||||||
|
return
|
||||||
|
end
|
||||||
---- 通信
|
---- 通信
|
||||||
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
|
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,4 +17,25 @@ function FormationManager:upHeroToStageFormation(heroId, matchType)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FormationManager:formationIsFull()
|
||||||
|
local actvieMap = DataManager.HeroData:getMatchActiveHeroMap()
|
||||||
|
local formation = DataManager.FormationData:getStageFormation()
|
||||||
|
local count = 0
|
||||||
|
for matchtype = 1, GConst.BattleConst.ELEMENT_TYPE_COUNT do
|
||||||
|
if not formation[matchtype] or formation[matchtype] <= 0 then
|
||||||
|
if actvieMap[matchtype] and table.nums(actvieMap[matchtype]) > 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if count <= 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
return FormationManager
|
return FormationManager
|
||||||
@ -6,9 +6,11 @@ function HeroCell:init()
|
|||||||
self.heroBg = uiMap["hero_cell.hero_bg"]
|
self.heroBg = uiMap["hero_cell.hero_bg"]
|
||||||
self.check = uiMap["hero_cell.hero_bg.mask"]
|
self.check = uiMap["hero_cell.hero_bg.mask"]
|
||||||
self.matchImg = uiMap["hero_cell.hero_bg.match_img"]
|
self.matchImg = uiMap["hero_cell.hero_bg.match_img"]
|
||||||
|
self.progressBg = uiMap["hero_cell.hero_bg.progress_bg"]
|
||||||
self.progress = uiMap["hero_cell.hero_bg.progress"]
|
self.progress = uiMap["hero_cell.hero_bg.progress"]
|
||||||
self.progressTx = uiMap["hero_cell.hero_bg.progress_tx"]
|
self.progressTx = uiMap["hero_cell.hero_bg.progress_tx"]
|
||||||
self.lvTx = uiMap["hero_cell.hero_bg.lv_tx"]
|
self.lvTx = uiMap["hero_cell.hero_bg.lv_tx"]
|
||||||
|
self.unlockTx = uiMap["hero_cell.hero_bg.unlock_tx"]
|
||||||
self.isGray = false
|
self.isGray = false
|
||||||
self.baseObject:addClickListener(function()
|
self.baseObject:addClickListener(function()
|
||||||
if self.clickCallback then
|
if self.clickCallback then
|
||||||
@ -27,6 +29,16 @@ function HeroCell:refresh(heroEntity, isGray)
|
|||||||
self.progressTx:setText(fragmentCount .. "/" .. needFragmentCount)
|
self.progressTx:setText(fragmentCount .. "/" .. needFragmentCount)
|
||||||
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
|
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
|
||||||
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, heroEntity:getLv()))
|
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, heroEntity:getLv()))
|
||||||
|
if heroEntity:isUnlock() then
|
||||||
|
self.lvTx:setVisible(true)
|
||||||
|
self.progressBg:setVisible(not heroEntity:isMaxLv())
|
||||||
|
self.unlockTx:setVisible(false)
|
||||||
|
else
|
||||||
|
self.lvTx:setVisible(false)
|
||||||
|
self.progressBg:setVisible(false)
|
||||||
|
self.unlockTx:setVisible(true)
|
||||||
|
self.unlockTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_10, heroEntity:getUnlcokChapter()))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroCell:refreshWithCfgId(id, isGray)
|
function HeroCell:refreshWithCfgId(id, isGray)
|
||||||
@ -41,6 +53,9 @@ function HeroCell:refreshWithCfgId(id, isGray)
|
|||||||
self.progressTx:setText(fragmentCount .. "/" .. needFragmentCount)
|
self.progressTx:setText(fragmentCount .. "/" .. needFragmentCount)
|
||||||
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
|
self.progress:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
|
||||||
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, lv))
|
self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, lv))
|
||||||
|
self.lvTx:setVisible(true)
|
||||||
|
self.progressBg:setVisible(true)
|
||||||
|
self.unlockTx:setVisible(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroCell:_refresh(heroInfo, isGray)
|
function HeroCell:_refresh(heroInfo, isGray)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ function HeroComp:init()
|
|||||||
return HERO_LIST_CELL
|
return HERO_LIST_CELL
|
||||||
end)
|
end)
|
||||||
self.scrollRect:addRefreshCallback(function(index, cell)
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||||
cell:refresh(index, self.heroList, self.stageFormation, self.allHeroCount, self.activeCount, function(cell, heroId)
|
cell:refresh(index, self.heroList, self.stageFormation, self.allHeroCount, self.unlockCount, function(cell, heroId)
|
||||||
self:onClickHero(cell, heroId)
|
self:onClickHero(cell, heroId)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -55,6 +55,8 @@ function HeroComp:init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function HeroComp:refresh()
|
function HeroComp:refresh()
|
||||||
|
self:clearAdapt()
|
||||||
|
self:adapt()
|
||||||
self.stageFormation = DataManager.FormationData:getStageFormation()
|
self.stageFormation = DataManager.FormationData:getStageFormation()
|
||||||
self:refreshStageFormation()
|
self:refreshStageFormation()
|
||||||
self:refreshScrollRect()
|
self:refreshScrollRect()
|
||||||
@ -95,11 +97,11 @@ end
|
|||||||
function HeroComp:refreshScrollRect()
|
function HeroComp:refreshScrollRect()
|
||||||
self:sortHeroList()
|
self:sortHeroList()
|
||||||
self.allHeroCount = #self.heroList
|
self.allHeroCount = #self.heroList
|
||||||
self.activeCount = DataManager.HeroData:getActiveHeroCount()
|
self.unlockCount = DataManager.HeroData:getUnlockHeroCount()
|
||||||
local lockCount = self.allHeroCount - self.activeCount
|
local lockCount = self.allHeroCount - self.unlockCount
|
||||||
local cellCount = 0
|
local cellCount = 0
|
||||||
if self.activeCount > 0 then
|
if self.unlockCount > 0 then
|
||||||
cellCount = cellCount + math.ceil(self.activeCount / 4)
|
cellCount = cellCount + math.ceil(self.unlockCount / 4)
|
||||||
end
|
end
|
||||||
if lockCount > 0 then
|
if lockCount > 0 then
|
||||||
cellCount = cellCount + math.ceil(lockCount / 4)
|
cellCount = cellCount + math.ceil(lockCount / 4)
|
||||||
@ -121,22 +123,26 @@ function HeroComp:sortHeroList()
|
|||||||
table.sort(self.heroList, function(a, b)
|
table.sort(self.heroList, function(a, b)
|
||||||
heroA = HeroData:getHeroById(a)
|
heroA = HeroData:getHeroById(a)
|
||||||
heroB = HeroData:getHeroById(b)
|
heroB = HeroData:getHeroById(b)
|
||||||
if heroA:isActived() and heroB:isActived() then
|
if heroA:isUnlock() == heroB:isUnlock() then
|
||||||
if heroA:getLv() == heroB:getLv() then
|
if heroA:isActived() and heroB:isActived() then
|
||||||
if heroA:getQlt() == heroB:getQlt() then
|
if heroA:getLv() == heroB:getLv() then
|
||||||
return a > b
|
if heroA:getQlt() == heroB:getQlt() then
|
||||||
|
return a > b
|
||||||
|
else
|
||||||
|
return heroA:getQlt() > heroB:getQlt()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return heroA:getQlt() > heroB:getQlt()
|
return heroA:getLv() > heroB:getLv()
|
||||||
end
|
end
|
||||||
|
elseif heroA:isActived() and not heroB:isActived() then
|
||||||
|
return true
|
||||||
|
elseif heroB:isActived() and not heroA:isActived() then
|
||||||
|
return false
|
||||||
else
|
else
|
||||||
return heroA:getLv() > heroB:getLv()
|
return a > b
|
||||||
end
|
end
|
||||||
elseif heroA:isActived() and not heroB:isActived() then
|
|
||||||
return true
|
|
||||||
elseif heroB:isActived() and not heroA:isActived() then
|
|
||||||
return false
|
|
||||||
else
|
else
|
||||||
return a > b
|
return heroA:isUnlock()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -166,4 +172,33 @@ function HeroComp:onClickHero(cell, heroId)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroComp:adapt()
|
||||||
|
local addH = GFunc.calculateFitSizeY()
|
||||||
|
local uiMap = self:getBaseObject():genAllChildren()
|
||||||
|
local scrollRect = uiMap["hero_ui.scrollrect"]
|
||||||
|
local viewport = uiMap["hero_ui.scrollrect.viewport"]
|
||||||
|
if not self.rectDefaultSize then
|
||||||
|
self.rectDefaultSize = scrollRect:getSizeDelta()
|
||||||
|
end
|
||||||
|
if not self.viewDefaultSize then
|
||||||
|
self.viewDefaultSize = viewport:getSizeDelta()
|
||||||
|
end
|
||||||
|
scrollRect:setSizeDelta(self.rectDefaultSize.x, self.rectDefaultSize.y + addH)
|
||||||
|
viewport:setSizeDelta(self.viewDefaultSize.x, self.viewDefaultSize.y + addH)
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroComp:clearAdapt()
|
||||||
|
local uiMap = self:getBaseObject():genAllChildren()
|
||||||
|
local scrollRect = uiMap["hero_ui.scrollrect"]
|
||||||
|
local viewport = uiMap["hero_ui.scrollrect.viewport"]
|
||||||
|
if not self.rectDefaultSize then
|
||||||
|
self.rectDefaultSize = scrollRect:getSizeDelta()
|
||||||
|
end
|
||||||
|
if not self.viewDefaultSize then
|
||||||
|
self.viewDefaultSize = viewport:getSizeDelta()
|
||||||
|
end
|
||||||
|
scrollRect:setSizeDelta(self.rectDefaultSize.x, self.rectDefaultSize.y)
|
||||||
|
viewport:setSizeDelta(self.viewDefaultSize.x, self.viewDefaultSize.y)
|
||||||
|
end
|
||||||
|
|
||||||
return HeroComp
|
return HeroComp
|
||||||
@ -21,7 +21,7 @@ function ChapterData:init(data, notChangeChapterId)
|
|||||||
if not notChangeChapterId then
|
if not notChangeChapterId then
|
||||||
self.data.chapterId = data and data.chapterId or MIN_CHAPTER_ID
|
self.data.chapterId = data and data.chapterId or MIN_CHAPTER_ID
|
||||||
end
|
end
|
||||||
self.data.maxChapterId = data and data.maxChapterId or self.data.chapterId - 1
|
self.data.maxChapterId = 2--data and data.maxChapterId or self.data.chapterId - 1
|
||||||
self.data.chapterBoxInfo = data and data.chapterBoxInfo or {}
|
self.data.chapterBoxInfo = data and data.chapterBoxInfo or {}
|
||||||
self.data.chapterFightInfo = data and data.chapterFightInfo or {}
|
self.data.chapterFightInfo = data and data.chapterFightInfo or {}
|
||||||
end
|
end
|
||||||
@ -136,4 +136,8 @@ function ChapterData:getFightCost(chapterId)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ChapterData:getMaxChapterId()
|
||||||
|
return self.data.maxChapterId
|
||||||
|
end
|
||||||
|
|
||||||
return ChapterData
|
return ChapterData
|
||||||
@ -1,10 +1,13 @@
|
|||||||
local HeroEntity = require "app/userdata/hero/hero_entity"
|
local HeroEntity = require "app/userdata/hero/hero_entity"
|
||||||
local HeroData = class("HeroData", BaseData)
|
local HeroData = class("HeroData", BaseData)
|
||||||
|
|
||||||
|
local HERO_CFG = ConfigManager:getConfig("hero")
|
||||||
|
|
||||||
function HeroData:ctor()
|
function HeroData:ctor()
|
||||||
self.heroes = {}
|
self.heroes = {}
|
||||||
self.data.activeCount = 0
|
self.data.activeCount = 0
|
||||||
self.data.isDirty = false
|
self.data.isDirty = false
|
||||||
|
self.matchActiveHeroMap = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroData:clear()
|
function HeroData:clear()
|
||||||
@ -18,6 +21,17 @@ function HeroData:init(data)
|
|||||||
self:addHero(heroInfo.cfg_id, heroInfo.lv)
|
self:addHero(heroInfo.cfg_id, heroInfo.lv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for heroId, info in pairs(HERO_CFG) do
|
||||||
|
local entity = self:getHeroById(heroId)
|
||||||
|
if entity:isActived() then
|
||||||
|
local matchType = entity:getMatchType()
|
||||||
|
if not self.matchActiveHeroMap[matchType] then
|
||||||
|
self.matchActiveHeroMap[matchType] = {}
|
||||||
|
end
|
||||||
|
self.matchActiveHeroMap[matchType][entity:getCfgId()] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroData:addHero(cfgId, lv)
|
function HeroData:addHero(cfgId, lv)
|
||||||
@ -50,12 +64,33 @@ function HeroData:getActiveHeroCount()
|
|||||||
return self.data.activeCount
|
return self.data.activeCount
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroData:getUnlockHeroCount()
|
||||||
|
local count = 0
|
||||||
|
for id, entity in pairs(self.heroes) do
|
||||||
|
if entity:isUnlock() then
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
function HeroData:setHeroLv(id, lv)
|
function HeroData:setHeroLv(id, lv)
|
||||||
local entity = self:getHeroById(id)
|
local entity = self:getHeroById(id)
|
||||||
if not entity:isActived() then
|
if not entity:isActived() then
|
||||||
self.data.activeCount = self.data.activeCount + 1
|
self.data.activeCount = self.data.activeCount + 1
|
||||||
end
|
end
|
||||||
entity:setLv(lv)
|
entity:setLv(lv)
|
||||||
|
if entity:isActived() then
|
||||||
|
local matchType = entity:getMatchType()
|
||||||
|
if not self.matchActiveHeroMap[matchType] then
|
||||||
|
self.matchActiveHeroMap[matchType] = {}
|
||||||
|
end
|
||||||
|
self.matchActiveHeroMap[matchType][entity:getCfgId()] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroData:getMatchActiveHeroMap()
|
||||||
|
return self.matchActiveHeroMap
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroData:setDirty()
|
function HeroData:setDirty()
|
||||||
|
|||||||
@ -105,6 +105,10 @@ function HeroEntity:getCfgAtk(lv)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroEntity:getUnlcokChapter()
|
||||||
|
return self.config.unlock_chapter or 0
|
||||||
|
end
|
||||||
|
|
||||||
function HeroEntity:updateAllAttr()
|
function HeroEntity:updateAllAttr()
|
||||||
for k, v in pairs(self.baseAttrOriginal) do
|
for k, v in pairs(self.baseAttrOriginal) do
|
||||||
self.allAttr[k] = v
|
self.allAttr[k] = v
|
||||||
@ -156,6 +160,10 @@ function HeroEntity:canLvUp()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroEntity:isUnlock()
|
||||||
|
return self:getUnlcokChapter() <= DataManager.ChapterData:getMaxChapterId()
|
||||||
|
end
|
||||||
|
|
||||||
function HeroEntity:isActived()
|
function HeroEntity:isActived()
|
||||||
return self.data.lv >= self:getBeginLv()
|
return self.data.lv >= self:getBeginLv()
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user