显示属性
This commit is contained in:
parent
d0399fe460
commit
fd4e6d88c4
@ -75,6 +75,7 @@ function BattleManager:clear()
|
||||
self.battleController:clear()
|
||||
self.battleController = nil
|
||||
DataManager.BattleData:clear()
|
||||
self.bindUnitAttributeData = nil
|
||||
end
|
||||
|
||||
|
||||
@ -262,4 +263,64 @@ end
|
||||
|
||||
----------------------- end 一些公共相关的方法 -----------------------------
|
||||
|
||||
function BattleManager:bindBattleUnitAttribute(hashCode, side)
|
||||
if self.battleController then
|
||||
local team = nil
|
||||
if side == 1 then
|
||||
team = self.battleController.atkTeam
|
||||
else
|
||||
team = self.battleController.defTeam
|
||||
end
|
||||
local unitAttrHelper = nil
|
||||
local teamEntity = nil
|
||||
for _, unit in ipairs(team.unitList) do
|
||||
local code = unit.baseObject:getGameObject():GetHashCode()
|
||||
if code == hashCode then
|
||||
if side == 1 then
|
||||
unitAttrHelper = unit.baseObject:getComponent(typeof(CS.BF.BattleUnitAttr))
|
||||
else
|
||||
unitAttrHelper = unit.baseObject:getComponent(typeof(CS.BF.BattleUnitAttr))
|
||||
end
|
||||
teamEntity = unit.unitEntity.team
|
||||
break
|
||||
end
|
||||
end
|
||||
if unitAttrHelper and teamEntity then
|
||||
-- 创建并绑定相关数据
|
||||
if self.bindUnitAttributeData == nil then
|
||||
self.bindUnitAttributeData = {}
|
||||
end
|
||||
-- 组合必要数据
|
||||
local unitData = {}
|
||||
unitData.unitAttrHelper = unitAttrHelper
|
||||
unitData.teamEntity = teamEntity
|
||||
|
||||
self.bindUnitAttributeData[hashCode] = unitData
|
||||
-- bind方法
|
||||
unitAttrHelper:BindGetAttributeFunc(function(hashCode)
|
||||
self:getBattleUnitAttribute(hashCode)
|
||||
end)
|
||||
-- 刷新数据
|
||||
self:getBattleUnitAttribute(hashCode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 将lua端属性传回CS端
|
||||
function BattleManager:getBattleUnitAttribute(hashCode)
|
||||
if self.bindUnitAttributeData and self.bindUnitAttributeData[hashCode] then
|
||||
local data = self.bindUnitAttributeData[hashCode]
|
||||
local unitAttrHelper = data.unitAttrHelper
|
||||
local teamEntity = data.teamEntity
|
||||
if unitAttrHelper and teamEntity then
|
||||
local attr = {}
|
||||
for key, value in pairs(teamEntity.attr) do
|
||||
attr[key] = value
|
||||
end
|
||||
attr.sheild_hp = teamEntity.shieldHp
|
||||
unitAttrHelper:GetAttribute(json.encode(attr))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return BattleManager
|
||||
@ -91,7 +91,9 @@ end
|
||||
|
||||
function BattleUI:initHpNode()
|
||||
self.hpProgressLeft = self.uiMap["battle_ui.top_node.bg_l.atk_slider_green"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressRight = self.uiMap["battle_ui.top_node.bg_r.atk_slider_red"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressRight = self.uiMap["battle_ui.top_node.bg_r.def_slider_red"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressYellowLeft = self.uiMap["battle_ui.top_node.bg_l.atk_slider_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpProgressYellowRight = self.uiMap["battle_ui.top_node.bg_r.def_slider_yellow"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
||||
self.hpTextLeft = self.uiMap["battle_ui.top_node.atk_hp"]
|
||||
self.hpTextRight = self.uiMap["battle_ui.top_node.def_hp"]
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user