This commit is contained in:
Fang 2023-08-15 15:07:58 +08:00
parent 2aff8266ac
commit 8cfd6358d8
8 changed files with 84 additions and 46 deletions

View File

@ -26,7 +26,7 @@ end
function SkinManager:rspChangeSkin(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.HeroData:getHeroById(result.reqData.id):onChangeSkin(result.reqData.skin_id)
DataManager.SkinData:onUseSkin(result.reqData.id, result.reqData.skin_id)
end
end

View File

@ -69,9 +69,8 @@ function ActivityBountyComp:refresh()
self.txLvNum:setText(DataManager.ActivityData:getBountyLevel())
-- 档位展示
local curGrade = DataManager.ActivityData:getBountyGrade()
self.btnBuy1:setActive(curGrade < GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1)
self.btnBuy2:setActive(curGrade < GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2)
self.btnBuy1:setActive(not DataManager.ActivityData:isBountyGradeUnlock(GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1))
self.btnBuy2:setActive(not DataManager.ActivityData:isBountyGradeUnlock(GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2))
local gift1 = DataManager.ActivityData:getBountyGradeGiftCfg(GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1)
local gift2 = DataManager.ActivityData:getBountyGradeGiftCfg(GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2)

View File

@ -13,11 +13,10 @@ function ActivityBountyCell:refresh(level, data)
self.txLevel:setText(level)
local isGet
local curGrade = DataManager.ActivityData:getBountyGrade()
isGet = DataManager.ActivityData:isReceivedBountyReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE)
self.rewardCell1:refreshByConfig(DataManager.ActivityData:getBountyGradeReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE), isGet, isGet)
self.rewardCell1:showLock(curGrade < GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE)
self.rewardCell1:showLock(not DataManager.ActivityData:isBountyGradeUnlock(GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE))
if DataManager.ActivityData:canGetBountyReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE) then
self.rewardCell1.baseObject:addRedPoint(50, 50, 0.6)
self.rewardCell1:addClickListener(function()
@ -25,11 +24,12 @@ function ActivityBountyCell:refresh(level, data)
end)
else
self.rewardCell1.baseObject:removeRedPoint()
self.rewardCell1:addClickListener(nil)
end
isGet = DataManager.ActivityData:isReceivedBountyReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1)
self.rewardCell2:refreshByConfig(DataManager.ActivityData:getBountyGradeReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1), isGet, isGet)
self.rewardCell2:showLock(curGrade < GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1)
self.rewardCell2:showLock(not DataManager.ActivityData:isBountyGradeUnlock(GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1))
if DataManager.ActivityData:canGetBountyReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1) then
self.rewardCell2.baseObject:addRedPoint(50, 50, 0.6)
self.rewardCell2:addClickListener(function()
@ -37,11 +37,12 @@ function ActivityBountyCell:refresh(level, data)
end)
else
self.rewardCell2.baseObject:removeRedPoint()
self.rewardCell2:addClickListener(nil)
end
isGet = DataManager.ActivityData:isReceivedBountyReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2)
self.rewardCell3:refreshByConfig(DataManager.ActivityData:getBountyGradeReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2), isGet, isGet)
self.rewardCell3:showLock(curGrade < GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2)
self.rewardCell3:showLock(not DataManager.ActivityData:isBountyGradeUnlock(GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2))
if DataManager.ActivityData:canGetBountyReward(level, GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2) then
self.rewardCell3.baseObject:addRedPoint(50, 50, 0.6)
self.rewardCell3:addClickListener(function()
@ -49,6 +50,7 @@ function ActivityBountyCell:refresh(level, data)
end)
else
self.rewardCell3.baseObject:removeRedPoint()
self.rewardCell3:addClickListener(nil)
end
end

View File

@ -26,7 +26,7 @@ function CollectionCell:init()
end
function CollectionCell:onClickCollectionHero()
if DataManager.CollectionData:getCanCollectPoint(GConst.CollectionConst.TYPE.HERO, self.collectionData.id) > 0 then
if DataManager.CollectionData:canCollectPoint(GConst.CollectionConst.TYPE.HERO, self.collectionData.id) then
AudioManager:playEffect(AudioManager.EFFECT_ID.STAR_GET)
ModuleManager.CollectionManager:reqHeroPoint(self.collectionData.id)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.COLLECTION_CLICK_GET_POINT, self.imgIcon:getPosition())
@ -36,7 +36,7 @@ function CollectionCell:onClickCollectionHero()
end
function CollectionCell:onClickCollectionSkin()
if DataManager.SkinData:isUnlock(self.collectionData.id) and DataManager.CollectionData:getCanCollectPoint(GConst.CollectionConst.TYPE.SKIN, self.collectionData.id) > 0 then
if DataManager.SkinData:isUnlock(self.collectionData.id) and DataManager.CollectionData:canCollectPoint(GConst.CollectionConst.TYPE.SKIN, self.collectionData.id) then
ModuleManager.CollectionManager:reqSkinPoint(self.collectionData.id)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.COLLECTION_CLICK_GET_POINT, self.imgIcon:getPosition())
else
@ -81,7 +81,7 @@ function CollectionCell:showHero()
-- 刷新点数状态
local canGetValue = DataManager.CollectionData:getCanCollectPoint(GConst.CollectionConst.TYPE.HERO, self.collectionData.id)
-- Logger.logHighlight("id:"..self.collectionData.id..",level:"..heroEntity:getLv()..",canGetValue:"..canGetValue)
if canGetValue > 0 then
if DataManager.CollectionData:canCollectPoint(GConst.CollectionConst.TYPE.HERO, self.collectionData.id) then
self.txValue:setText("+" .. canGetValue)
self.txLevel:setText("<color=#FCFF13>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, heroEntity:getLv()).."</color>")
GFunc.getShakeSeq(self.txLevel, false, 1, true)
@ -89,7 +89,7 @@ function CollectionCell:showHero()
self.btnCollect:setActive(true)
self.txMax:setActive(false)
else
self.txValue:setText("+" .. heroEntity:getCollectionPoint())
self.txValue:setText("+" .. canGetValue)
self.txLevel:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, heroEntity:getLv()))
GFunc.getShakeSeq(self.txLevel, true)
self.btnCollect:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_3")
@ -122,24 +122,24 @@ function CollectionCell:showSkin()
-- 刷新点数状态
local canGetValue = DataManager.CollectionData:getCanCollectPoint(GConst.CollectionConst.TYPE.SKIN, self.collectionData.id)
-- Logger.logHighlight("id:"..self.collectionData.id..",canGetValue:"..canGetValue)
if DataManager.SkinData:isUnlock(self.collectionData.id) then
if canGetValue > 0 then
-- 已解锁,未领点数
self.txMax:setActive(false)
self.btnCollect:setActive(true)
self.btnCollect:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_green_3")
self.txValue:setText("+" .. canGetValue)
else
if DataManager.CollectionData:canCollectPoint(GConst.CollectionConst.TYPE.SKIN, self.collectionData.id) then
-- 已解锁,未领点数
self.txMax:setActive(false)
self.btnCollect:setActive(true)
self.btnCollect:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_green_3")
self.txValue:setText("+" .. canGetValue)
else
if DataManager.SkinData:isUnlock(self.collectionData.id) then
-- 已解锁,已领点数
self.btnCollect:setActive(false)
self.txMax:setActive(true)
else
-- 未解锁
self.txMax:setActive(false)
self.btnCollect:setActive(true)
self.btnCollect:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_3")
self.txValue:setText("+" .. canGetValue)
end
else
-- 未解锁
self.txMax:setActive(false)
self.btnCollect:setActive(true)
self.btnCollect:setSprite(GConst.ATLAS_PATH.COMMON, "common_btn_grey_3")
self.txValue:setText("+" .. canGetValue)
end
GFunc.centerTxAndImg(self.txValue, self.imgIcon, 2)
end

View File

@ -73,10 +73,13 @@ function HeroComp:init()
self:bind(DataManager.HeroData, "isDirty", function()
self:refreshCollectEntrance()
end)
self:bind(DataManager.SkinData, "isDirty", function()
self:refresh()
end)
end
function HeroComp:refresh(battleType)
self.battleType = battleType
self.battleType = battleType or self.battleType
self:clearAdapt()
self:adapt()

View File

@ -271,16 +271,16 @@ end
-- 战令--------------------------------------------------------------------------------------------------
-- 获取战令档位0免费档1、2付费档
function ActivityData:getBountyGrade()
if DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ActivityConst.BOUNTY_GIFT_ID_2) > 0 then
return GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2
-- 战令档位是否已解锁
function ActivityData:isBountyGradeUnlock(grade)
if grade == GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE then
return true
elseif grade == GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1 then
return DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ActivityConst.BOUNTY_GIFT_ID_1) > 0
elseif grade == GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY2 then
return DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ActivityConst.BOUNTY_GIFT_ID_2) > 0
end
if DataManager.ShopData:getGiftBoughtNum(PayManager.PURCHARSE_TYPE.ACT_GIFT, GConst.ActivityConst.BOUNTY_GIFT_ID_1) > 0 then
return GConst.ActivityConst.BOUNTY_GRADE_TYPE.PAY1
end
return GConst.ActivityConst.BOUNTY_GRADE_TYPE.FREE
return false
end
-- 获取战令档位礼包配置
@ -396,9 +396,8 @@ end
-- 战令奖励是否满足领取条件
function ActivityData:isReachBountyReward(level, grade)
local curLevel = self:getBountyLevel()
local curGrade = self:getBountyGrade()
if curLevel >= level then
return grade <= curGrade
return self:isBountyGradeUnlock(grade)
else
return false
end

View File

@ -40,12 +40,12 @@ function CollectionData:hasRedPoint()
-- 可领点数
for idx, data in pairs(self:getCollectList(GConst.CollectionConst.TYPE.HERO)) do
if self:getCanCollectPoint(GConst.CollectionConst.TYPE.HERO, data.id) > 0 then
if self:canCollectPoint(GConst.CollectionConst.TYPE.HERO, data.id) then
return true
end
end
for idx, data in pairs(self:getCollectList(GConst.CollectionConst.TYPE.SKIN)) do
if self:getCanCollectPoint(GConst.CollectionConst.TYPE.HERO, data.id) > 0 then
if self:canCollectPoint(GConst.CollectionConst.TYPE.SKIN, data.id) then
return true
end
end
@ -195,11 +195,10 @@ function CollectionData:getTargetOwnedPoint(id)
return curPoint
end
-- 获取可领取收集值小于等于0为无点数反之有可领取点数
function CollectionData:getCanCollectPoint(type, id)
-- 是否可收集点数
function CollectionData:canCollectPoint(type, id)
if type == GConst.CollectionConst.TYPE.HERO then
-- 基础奖励值 * 升级可领取次数
local result = 0
local heroEntity = DataManager.HeroData:getHeroById(id)
if heroEntity then
local curLevel = heroEntity:getLv()
@ -207,15 +206,45 @@ function CollectionData:getCanCollectPoint(type, id)
if collectedLevel == nil then
collectedLevel = 0
end
result = (curLevel - collectedLevel) * heroEntity:getCollectionPoint()
if collectedLevel >= curLevel then
return false
end
return true
end
return result
elseif type == GConst.CollectionConst.TYPE.SKIN then
if not DataManager.SkinData:isUnlock(id) then
return false
end
if self.collectSkin[id] and self.collectSkin[id] > 0 then
-- 已收集
return 0
return false
end
return true
end
end
-- 获取可领取收集值
function CollectionData:getCanCollectPoint(type, id)
if type == GConst.CollectionConst.TYPE.HERO then
-- 基础奖励值 * 升级可领取次数
local result = 0
local heroEntity = DataManager.HeroData:getHeroById(id)
if self:canCollectPoint(type, id) then
local curLevel = heroEntity:getLv()
local collectedLevel = self.collectHero[heroEntity:getCfgId()]
if collectedLevel == nil then
collectedLevel = 0
end
result = (curLevel - collectedLevel) * heroEntity:getCollectionPoint()
else
result = heroEntity:getCollectionPoint()
end
return result
elseif type == GConst.CollectionConst.TYPE.SKIN then
local cfg = ConfigManager:getConfig("skin")[id]
return cfg and cfg.skin_point or 0
end

View File

@ -305,4 +305,10 @@ function SkinData:onUnlockSkin(itemId)
self:setDirty()
end
-- 使用皮肤
function SkinData:onUseSkin(heroId, skinId)
DataManager.HeroData:getHeroById(heroId):onChangeSkin(skinId)
self:setDirty()
end
return SkinData