战斗力
This commit is contained in:
parent
f18eb91d53
commit
96fe08e143
@ -90,6 +90,8 @@ local MODULE_PATHS = {
|
|||||||
-- 天赋
|
-- 天赋
|
||||||
TalentManager = "app/module/talent/talent_manager",
|
TalentManager = "app/module/talent/talent_manager",
|
||||||
BagManager = "app/module/bag/bag_manager",
|
BagManager = "app/module/bag/bag_manager",
|
||||||
|
-- 战力/攻击力toast
|
||||||
|
PowerToastManager = "app/ui/common/power_toast_manager",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 这里的key对应func_open里的id
|
-- 这里的key对应func_open里的id
|
||||||
|
|||||||
@ -374,6 +374,7 @@ GConst.COLOR_CODE = {
|
|||||||
GREEN = "#A3FF94",
|
GREEN = "#A3FF94",
|
||||||
RED = "#FF5050",
|
RED = "#FF5050",
|
||||||
WHITE = "#FFFFFF",
|
WHITE = "#FFFFFF",
|
||||||
|
LIGHT_GREEN = "#2FFF91",
|
||||||
}
|
}
|
||||||
|
|
||||||
GConst.UI_EFFECT_ORDER = {
|
GConst.UI_EFFECT_ORDER = {
|
||||||
|
|||||||
@ -2047,4 +2047,23 @@ function GFunc.showCommonBoxUI(id, showTips)
|
|||||||
ModuleManager.CommonManager:showCommonBoxUI(id, showTips)
|
ModuleManager.CommonManager:showCommonBoxUI(id, showTips)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function GFunc.colorText(color, str)
|
||||||
|
local backStr = ""
|
||||||
|
backStr = string.format("<color=".. color.. ">%s</color>", str)
|
||||||
|
return backStr
|
||||||
|
end
|
||||||
|
|
||||||
|
--@region 战斗力
|
||||||
|
function GFunc.hidePowerToast()
|
||||||
|
ModuleManager.PowerToastManager:hideToast()
|
||||||
|
end
|
||||||
|
|
||||||
|
function GFunc.showPowerToast(before, after, posY)
|
||||||
|
if not before or not after then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ModuleManager.PowerToastManager:showToast(before, after, posY)
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
|
||||||
return GFunc
|
return GFunc
|
||||||
@ -35,6 +35,7 @@ function HeroManager:upgradeHeroFinish(result)
|
|||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
DataManager.HeroData:setHeroLv(result.hero.id, result.hero.level)
|
DataManager.HeroData:setHeroLv(result.hero.id, result.hero.level)
|
||||||
DataManager.HeroData:setDirty()
|
DataManager.HeroData:setDirty()
|
||||||
|
DataManager.HeroData:calcPower()
|
||||||
|
|
||||||
AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP)
|
AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP)
|
||||||
end
|
end
|
||||||
@ -59,6 +60,7 @@ function HeroManager:heroStarReqFinish(result)
|
|||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
DataManager.HeroData:onHeroStarUp(result.hero.id)
|
DataManager.HeroData:onHeroStarUp(result.hero.id)
|
||||||
DataManager.HeroData:setDirty()
|
DataManager.HeroData:setDirty()
|
||||||
|
DataManager.HeroData:calcPower()
|
||||||
|
|
||||||
AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP)
|
AudioManager:playEffect(AudioManager.EFFECT_ID.HERO_UP)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -111,4 +111,15 @@ function MaincityManager:isActivSideBarModule(moduleKey)
|
|||||||
return mainUI:isActivSideBarModule(moduleKey)
|
return mainUI:isActivSideBarModule(moduleKey)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@region 战斗力
|
||||||
|
function MaincityManager:checkShowPowerUI()
|
||||||
|
local curPower = DataManager.HeroData:getShowPower()
|
||||||
|
local lastPower = DataManager.HeroData:getLastPower()
|
||||||
|
if curPower ~= lastPower then
|
||||||
|
GFunc.hidePowerToast()
|
||||||
|
GFunc.showPowerToast(lastPower, curPower)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
|
||||||
return MaincityManager
|
return MaincityManager
|
||||||
129
lua/app/ui/common/power_toast_manager.lua
Executable file
129
lua/app/ui/common/power_toast_manager.lua
Executable file
@ -0,0 +1,129 @@
|
|||||||
|
local PowerToastManager = class("PowerToastManager", BaseModule)
|
||||||
|
|
||||||
|
function PowerToastManager:ctor()
|
||||||
|
end
|
||||||
|
|
||||||
|
function PowerToastManager:clear()
|
||||||
|
self:clearSeq()
|
||||||
|
end
|
||||||
|
|
||||||
|
function PowerToastManager:hideToast()
|
||||||
|
self:showEffect(false)
|
||||||
|
UIManager:hidePowerToast()
|
||||||
|
end
|
||||||
|
|
||||||
|
function PowerToastManager:showToast(before, after, posY)
|
||||||
|
self.before = before
|
||||||
|
self.after = after
|
||||||
|
self.posY = posY or 243
|
||||||
|
self.power = self.before
|
||||||
|
self.diffVal = self.after - self.before
|
||||||
|
self:clearSeq()
|
||||||
|
self.isNew = true
|
||||||
|
UIManager:getPowerToast(function(prefabObject)
|
||||||
|
prefabObject:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = true
|
||||||
|
|
||||||
|
local uiMap = prefabObject:genAllChildren()
|
||||||
|
self.bg = uiMap["power_change_toast.bg"]
|
||||||
|
self.powerTx = uiMap["power_change_toast.bg.power_tx"]
|
||||||
|
self.powerChange = uiMap["power_change_toast.bg.power_change_tx"]
|
||||||
|
-- self.powerSpine = uiMap["power_change_toast.bg.ui_spine_obj"]
|
||||||
|
-- self.effect1 = uiMap["power_change_toast.content.vfx_ui_zhanli_b01"]
|
||||||
|
-- self.effect2 = uiMap["power_change_toast.content.vfx_ui_zhanli_b03"]
|
||||||
|
|
||||||
|
self:showEffect(false)
|
||||||
|
self:showModuleUnlockAppearAnim()
|
||||||
|
-- self.powerSpine:playAnim("idle", false, true)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 出现
|
||||||
|
function PowerToastManager:showModuleUnlockAppearAnim()
|
||||||
|
self.bg:setAnchoredPositionY(self.posY)
|
||||||
|
self.bg:setLocalScale(1, 1, 1)
|
||||||
|
|
||||||
|
-- if self.animEffect == nil then
|
||||||
|
-- self.animEffect = self.effect1:createBindTweenSequence()
|
||||||
|
-- self.animEffect:AppendInterval(0.3)
|
||||||
|
-- self.animEffect:AppendCallback(function()
|
||||||
|
-- self:showEffect(true)
|
||||||
|
-- end)
|
||||||
|
-- self.animEffect:AppendInterval(1)
|
||||||
|
-- self.animEffect:AppendCallback(function()
|
||||||
|
-- self:showEffect(false)
|
||||||
|
-- end)
|
||||||
|
-- else
|
||||||
|
-- self.animEffect:Restart()
|
||||||
|
-- end
|
||||||
|
|
||||||
|
if self.animAppear == nil then
|
||||||
|
self.animAppear = self.bg:createBindTweenSequence()
|
||||||
|
local tween = DOTweenManager:createDOTweenTo(
|
||||||
|
function()
|
||||||
|
return self.power
|
||||||
|
end,
|
||||||
|
function(value)
|
||||||
|
local str = GFunc.num2Str3(math.floor(value))
|
||||||
|
local str2 = GConst.EMPTY_STRING
|
||||||
|
local color = GConst.COLOR_CODE.LIGHT_GREEN
|
||||||
|
if self.diffVal > 0 then
|
||||||
|
str2 = "+" .. GFunc.num2Str3(self.diffVal)
|
||||||
|
else
|
||||||
|
str2 = "-" .. GFunc.num2Str3(math.abs(self.diffVal))
|
||||||
|
color = "#FF77D7"
|
||||||
|
end
|
||||||
|
self.powerTx:setText(str)
|
||||||
|
self.powerChange:setText(GFunc.colorText(color, str2))
|
||||||
|
end,
|
||||||
|
self.after, 1.5)
|
||||||
|
self.animAppear:Append(tween)
|
||||||
|
-- self.animAppear:Insert(1.45, self.bg:getTransform():DOScale(1.15, 0.2):SetLoops(2, CS.DG.Tweening.LoopType.Yoyo))
|
||||||
|
self.animAppear:SetAutoKill(true)
|
||||||
|
self.animAppear:OnComplete(function()
|
||||||
|
self.isNew = false
|
||||||
|
self:performWithDelayGlobal(function()
|
||||||
|
if self.isNew then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
UIManager:hidePowerToast()
|
||||||
|
end, 0.5)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
self.animAppear:Restart()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function PowerToastManager:clearSeq()
|
||||||
|
if self.animEffect then
|
||||||
|
self.animEffect:Kill()
|
||||||
|
self.animEffect = nil
|
||||||
|
end
|
||||||
|
if self.animAppear then
|
||||||
|
self.animAppear:Kill()
|
||||||
|
self.animAppear = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function PowerToastManager:showEffect(show)
|
||||||
|
if self.effect1 then
|
||||||
|
self.effect1:setActive(false)
|
||||||
|
end
|
||||||
|
if self.effect2 then
|
||||||
|
self.effect2:setActive(false)
|
||||||
|
end
|
||||||
|
if not show then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.effect1 == nil or self.effect2 == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.effect1:setActive(true)
|
||||||
|
self.effect2:setActive(true)
|
||||||
|
self.effect1:play()
|
||||||
|
self.effect2:play()
|
||||||
|
self.effect1:setSortingOrder(28400, 0)
|
||||||
|
self.effect2:setSortingOrder(28400, 20)
|
||||||
|
end
|
||||||
|
|
||||||
|
return PowerToastManager
|
||||||
10
lua/app/ui/common/power_toast_manager.lua.meta
Normal file
10
lua/app/ui/common/power_toast_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2695af3eed3674b6ca2421472c798c35
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -244,6 +244,9 @@ function MainCityUI:_bind()
|
|||||||
end
|
end
|
||||||
self:refreshBottomRp()
|
self:refreshBottomRp()
|
||||||
end)
|
end)
|
||||||
|
self:bind(DataManager.HeroData, "isPowerDirty", function()
|
||||||
|
ModuleManager.MaincityManager:checkShowPowerUI()
|
||||||
|
end)
|
||||||
|
|
||||||
self:bind(DataManager.CollectionData, "isDirty", function()
|
self:bind(DataManager.CollectionData, "isDirty", function()
|
||||||
self:refreshBottomRp()
|
self:refreshBottomRp()
|
||||||
|
|||||||
@ -737,9 +737,35 @@ function UIManager:hideRollToast(killSeq)
|
|||||||
self.rollToast:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
self.rollToast:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function UIManager:getPowerToast(callback)
|
||||||
|
if not self.powerToast then
|
||||||
|
UIPrefabManager:loadUIWidgetAsync("assets/prefabs/ui/common/power_change_toast.prefab", self.toastNode, function (_prefabObject)
|
||||||
|
if self.powerToast then
|
||||||
|
_prefabObject:destroy()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_prefabObject:initPrefabHelper()
|
||||||
|
self.powerToast = _prefabObject
|
||||||
|
callback(_prefabObject)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
callback(self.powerToast)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---- 回到登录界面时 killseq为true
|
||||||
|
function UIManager:hidePowerToast()
|
||||||
|
if not self.powerToast then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ModuleManager.PowerToastManager:clear()
|
||||||
|
self.powerToast:getComponent(GConst.TYPEOF_UNITY_CLASS.CANVAS).enabled = false
|
||||||
|
end
|
||||||
|
|
||||||
function UIManager:hideToastAndMessageBox()
|
function UIManager:hideToastAndMessageBox()
|
||||||
self:hideToast()
|
self:hideToast()
|
||||||
self:hideRollToast()
|
self:hideRollToast()
|
||||||
|
self:hidePowerToast()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIManager:getMainCanvasTransform()
|
function UIManager:getMainCanvasTransform()
|
||||||
|
|||||||
@ -8,6 +8,7 @@ function HeroData:ctor()
|
|||||||
self.heroes = {}
|
self.heroes = {}
|
||||||
self.data.activeCount = 0
|
self.data.activeCount = 0
|
||||||
self.data.isDirty = false
|
self.data.isDirty = false
|
||||||
|
self.data.isPowerDirty = false
|
||||||
self.matchActiveHeroMap = {}
|
self.matchActiveHeroMap = {}
|
||||||
self.maxHeroLvOnInit = 0
|
self.maxHeroLvOnInit = 0
|
||||||
|
|
||||||
@ -39,6 +40,8 @@ function HeroData:init(data)
|
|||||||
self.matchActiveHeroMap[matchType][entity:getCfgId()] = true
|
self.matchActiveHeroMap[matchType][entity:getCfgId()] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:calcPower()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 是否是合法的英雄
|
-- 是否是合法的英雄
|
||||||
@ -338,4 +341,101 @@ function HeroData:calcAttr()
|
|||||||
end
|
end
|
||||||
-- endregion
|
-- endregion
|
||||||
|
|
||||||
|
--@region 战斗力
|
||||||
|
function HeroData:getShowPower()
|
||||||
|
if self.curPower == nil then
|
||||||
|
self:calcPower()
|
||||||
|
end
|
||||||
|
return self.curPower
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroData:getLastPower()
|
||||||
|
return self.lastPower or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroData:clearLastPower()
|
||||||
|
self.lastPower = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 计算战斗力
|
||||||
|
function HeroData:calcPower()
|
||||||
|
if self.lastPower then
|
||||||
|
self.lastPower = self.curPower
|
||||||
|
end
|
||||||
|
|
||||||
|
local attrPower = 0
|
||||||
|
local formation = DataManager.FormationData:getStageFormation()
|
||||||
|
for _, heroId in pairs(formation) do
|
||||||
|
local heroEntity = DataManager.HeroData:getHeroById(heroId)
|
||||||
|
if heroEntity then
|
||||||
|
attrPower = attrPower + heroEntity:getPower()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- -- 天赋战力
|
||||||
|
-- local talentPower = DataManager.TalentData:getPower()
|
||||||
|
-- -- 英雄战力
|
||||||
|
-- local forcePower = DataManager.ForceData:getPower()
|
||||||
|
-- -- 英雄皮肤战力
|
||||||
|
-- local forceSkinPower = DataManager.ForceData:getSkinPower()
|
||||||
|
-- -- 英雄装备战力
|
||||||
|
-- local equipPower = DataManager.ForceEquipData:getPower()
|
||||||
|
-- -- 领主时装战力
|
||||||
|
-- local skinPower = DataManager.SkinData:getPower()
|
||||||
|
-- -- 宝物战力
|
||||||
|
-- local collectionPower = DataManager.CollectionData:getPower()
|
||||||
|
-- -- 防线战力
|
||||||
|
-- local defenseLinePower = DataManager.DefenseLineData:getPower()
|
||||||
|
-- -- 防线皮肤战力
|
||||||
|
-- local defenseLineSkinPower = DataManager.DefenseLineData:getSkinPower()
|
||||||
|
-- -- 宠物战力
|
||||||
|
-- local petPower = DataManager.PetData:getPower()
|
||||||
|
-- -- 魔法书战力
|
||||||
|
-- local magicBookPower = DataManager.MagicBookData:getPower()
|
||||||
|
-- -- 魔法阵战力
|
||||||
|
-- local magicCirclePower = DataManager.MagicCircleData:getPower()
|
||||||
|
|
||||||
|
self.curPower = 0
|
||||||
|
self.curPower = self.curPower + attrPower
|
||||||
|
-- self.curPower = self.curPower + talentPower
|
||||||
|
-- self.curPower = self.curPower + forcePower
|
||||||
|
-- self.curPower = self.curPower + forceSkinPower
|
||||||
|
-- self.curPower = self.curPower + equipPower
|
||||||
|
-- self.curPower = self.curPower + skinPower
|
||||||
|
-- self.curPower = self.curPower + collectionPower
|
||||||
|
-- self.curPower = self.curPower + defenseLinePower
|
||||||
|
-- self.curPower = self.curPower + defenseLineSkinPower
|
||||||
|
-- self.curPower = self.curPower + petPower
|
||||||
|
-- self.curPower = self.curPower + magicBookPower
|
||||||
|
-- self.curPower = self.curPower + magicCirclePower
|
||||||
|
|
||||||
|
-- if EDITOR_MODE and self:getIsSelf() then
|
||||||
|
-- Logger.logHighlight("PlayerEntity 总战力:" .. self.curPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 属性战力:" .. attrPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 天赋战力:" .. talentPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 英雄战力:" .. forcePower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 英雄皮肤战力:" .. forceSkinPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 英雄装备战力:" .. equipPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 领主时装战力:" .. skinPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 宝物战力:" .. collectionPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 防线战力:" .. defenseLinePower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 防线皮肤战力:" .. defenseLineSkinPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 宠物战力:" .. petPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 魔法书战力:" .. magicBookPower)
|
||||||
|
-- Logger.logHighlight("PlayerEntity 魔法阵战力:" .. magicCirclePower)
|
||||||
|
-- end
|
||||||
|
|
||||||
|
if not self.lastPower then
|
||||||
|
self.lastPower = self.curPower
|
||||||
|
end
|
||||||
|
if self.lastPower ~= self.curPower then
|
||||||
|
self:setPowerDirty()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroData:setPowerDirty()
|
||||||
|
self.data.isPowerDirty = not self.data.isPowerDirty
|
||||||
|
end
|
||||||
|
--@endregion
|
||||||
|
|
||||||
return HeroData
|
return HeroData
|
||||||
@ -286,6 +286,7 @@ function HeroEntity:setLv(lv, onlyChangeLv)
|
|||||||
self.data.lv = lv
|
self.data.lv = lv
|
||||||
self:_updateAllBaseAttr()
|
self:_updateAllBaseAttr()
|
||||||
self:setDirty()
|
self:setDirty()
|
||||||
|
self:setAttrDirty()
|
||||||
|
|
||||||
if not onlyChangeLv then
|
if not onlyChangeLv then
|
||||||
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
|
||||||
@ -685,6 +686,7 @@ function HeroEntity:onHeroStarUp()
|
|||||||
self.data.star = self.data.star + 1
|
self.data.star = self.data.star + 1
|
||||||
self:setBaseAttrDirty()
|
self:setBaseAttrDirty()
|
||||||
self:setDirty()
|
self:setDirty()
|
||||||
|
self:setAttrDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:getMaxStar()
|
function HeroEntity:getMaxStar()
|
||||||
@ -725,7 +727,7 @@ function HeroEntity:setPowerDirty()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:getPower()
|
function HeroEntity:getPower()
|
||||||
if not self.curPower then
|
if not self.curPower or self.attrDirty then
|
||||||
self:getAllAttr()
|
self:getAllAttr()
|
||||||
end
|
end
|
||||||
return self.curPower
|
return self.curPower
|
||||||
@ -757,7 +759,7 @@ function HeroEntity:_getAttrPower()
|
|||||||
realValue = attrNum - 15000
|
realValue = attrNum - 15000
|
||||||
end
|
end
|
||||||
|
|
||||||
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR / GConst.DEFAULT_FACTOR + 0.0000001)
|
power = power + math.floor(realValue * cfg.power / GConst.DEFAULT_FACTOR + 0.0000001)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user