From be28abd54c25837f62bf7b1b2c4718469b138210 Mon Sep 17 00:00:00 2001 From: JieLing Date: Sat, 13 Mar 2021 16:35:35 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"[=E6=88=98=E6=96=97]=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=20buff=20=E5=8F=A0=E5=B1=82=E8=A1=A8=E7=8E=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 491a6f311a04e51066d2ca6d6a0c9ba583fed71b. --- .../~Lua/Modules/Battle/Logic/Base/Buff.lua | 65 +++++---- .../Modules/Battle/View/Unit/BuffCtrl.lua | 130 ++---------------- .../Modules/Battle/View/Unit/BuffView.lua | 28 ++-- 3 files changed, 54 insertions(+), 169 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Buff.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Buff.lua index 94ef159780..e35ceff2a0 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Buff.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Base/Buff.lua @@ -263,40 +263,37 @@ function BuffManager:Update() buffList = self.buffDic.kvList[buff.type] end - -- 是覆盖类型的buff且有老buff buff表现层修改所有cover 字段没用了 注释 by:王振兴 2021/03/11 20:40 - -- if buff.cover and buffList.size > 0 then - -- local isCovered = false - -- for i=1, buffList.size do - -- local oldBuff = buffList.buffer[i] - -- if oldBuff.cover and oldBuff.target == buff.target and oldBuff.clear == buff.clear and oldBuff:OnCover(buff) then --判定该效果能否被覆盖 - -- -- 结束并回收老buff - -- oldBuff:OnEnd() - -- oldBuff.target.Event:DispatchEvent(BattleEventName.BuffEnd, oldBuff) - -- putBuff(oldBuff) - -- -- 覆盖老buff - -- buffList.buffer[i] = buff - -- buff:OnStart() - -- buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) - -- buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff) - -- isCovered = true - -- break - -- end - -- end - -- -- 没有覆盖,新buff - -- if not isCovered then - -- buffList:Add(buff) - -- buff:OnStart() - -- buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) - -- end - -- else - -- -- 新buff - -- buffList:Add(buff) - -- buff:OnStart() - -- buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) - -- end - buffList:Add(buff) - buff:OnStart() - buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) + -- 是覆盖类型的buff且有老buff + if buff.cover and buffList.size > 0 then + local isCovered = false + for i=1, buffList.size do + local oldBuff = buffList.buffer[i] + if oldBuff.cover and oldBuff.target == buff.target and oldBuff.clear == buff.clear and oldBuff:OnCover(buff) then --判定该效果能否被覆盖 + -- 结束并回收老buff + oldBuff:OnEnd() + oldBuff.target.Event:DispatchEvent(BattleEventName.BuffEnd, oldBuff) + putBuff(oldBuff) + -- 覆盖老buff + buffList.buffer[i] = buff + buff:OnStart() + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) + buff.target.Event:DispatchEvent(BattleEventName.BuffCover, buff) + isCovered = true + break + end + end + -- 没有覆盖,新buff + if not isCovered then + buffList:Add(buff) + buff:OnStart() + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) + end + else + -- 新buff + buffList:Add(buff) + buff:OnStart() + buff.target.Event:DispatchEvent(BattleEventName.BuffStart, buff) + end end -- 清除过期buff diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffCtrl.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffCtrl.lua index 7db1e66891..96641ccbec 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffCtrl.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffCtrl.lua @@ -159,66 +159,23 @@ end -- function BuffCtrl:AddBuffIcon(buff, icon) - local currBuff=buff - if not currBuff or not icon or icon == "" then + if not buff or not icon or icon == "" then return end - if not self.BuffIconList then self.BuffIconList = {} end - -- if not self.BuffIconList[buff.id] then - -- local buffGO = BattlePool.GetItem(self.buffRoot.transform, BATTLE_POOL_TYPE.BUFF_VIEW) - -- buffGO.transform.localScale = Vector3.one - -- buffGO.transform.localPosition = Vector3.zero - -- buffGO:SetActive(true) - -- self.BuffIconList[buff.id] = BuffView.New(buffGO, buff, icon) - -- else - -- self.BuffIconList[buff.id].count = self.BuffIconList[buff.id].count + 1 - -- self.BuffIconList[buff.id]:SetCount() - -- end - - LogRed(buff.id) - if not self.BuffIconList[currBuff.id] then - --便利所有之前存在的buff图标,有同类型,同数值的叠加,否则新建 - for key, value in pairs(self.BuffIconList) do - local buffType=self.BuffIconList[key].buff.type - if currBuff.type == self.BuffIconList[key].buff.type then - if buffType == BuffName.PropertyChange then - --属性 判断属性类型,属性值,属性修改类型 - local b = self.BuffIconList[key].buff - if self.BuffIconList[key].buffPropertyName == currBuff.propertyName and self.BuffIconList[key].buffCt == currBuff.changeType and self.BuffIconList[key].buffValue == currBuff.Value then - self.BuffIconList[key]:SetCount(self.BuffIconList[key].count+1) - return - end - --持续伤害类型,伤害系数 - elseif buffType==BuffName.DOT then - if self.BuffIconList[key].buffDamageType==currBuff.damageType and self.BuffIconList[key].buffDamageFactor==currBuff.damageFactor then - self.BuffIconList[key]:SetCount(self.BuffIconList[key].count+1) - return - end - --控制类型 - elseif buffType == BuffName.Control then - if self.BuffIconList[key].buffCtrlType==currBuff.ctrlType then - self.BuffIconList[key]:SetCount(self.BuffIconList[key].count+1) - return - end - elseif buffType == BuffName.HOT then - if self.BuffIconList[key].healValue==currBuff.healValue then - self.BuffIconList[key]:SetCount(self.BuffIconList[key].count+1) - return - end - end - end - end + if not self.BuffIconList[buff.id] then + local buffGO = BattlePool.GetItem(self.buffRoot.transform, BATTLE_POOL_TYPE.BUFF_VIEW) + buffGO.transform.localScale = Vector3.one + buffGO.transform.localPosition = Vector3.zero + buffGO:SetActive(true) + self.BuffIconList[buff.id] = BuffView.New(buffGO, buff, icon) + else + self.BuffIconList[buff.id].count = self.BuffIconList[buff.id].count + 1 + self.BuffIconList[buff.id]:SetCount() end - - local buffGO = BattlePool.GetItem(self.buffRoot.transform, BATTLE_POOL_TYPE.BUFF_VIEW) - buffGO.transform.localScale = Vector3.one - buffGO.transform.localPosition = Vector3.zero - buffGO:SetActive(true) - self.BuffIconList[currBuff.id] = BuffView.New(buffGO, buff, icon) end function BuffCtrl:RemoveBuffIcon(buff) if not buff then @@ -227,69 +184,10 @@ function BuffCtrl:RemoveBuffIcon(buff) if not self.BuffIconList then return end - -- if self.BuffIconList[buff.id] then - -- local count=self.BuffIconList[buff.id].count - -- if count==1 then - -- self.BuffIconList[buff.id]:Dispose() - -- self.BuffIconList[buff.id] = nil - -- else - -- self.BuffIconList[buff.id]:SetCount(count-1) - -- end - -- return - -- end - - --便利所有之前存在的buff图标,有同类型,同数值的叠加,否则新建 - for key, value in pairs(self.BuffIconList) do - local buffType = self.BuffIconList[key].buff.type - local floor = self.BuffIconList[key].count - - if buff.type == buffType then - if buffType == BuffName.PropertyChange then - --属性 判断属性类型,属性值,属性修改类型 - if self.BuffIconList[key].buffPropertyName==buff.propertyName and self.BuffIconList[key].buffValue==buff.Value and self.BuffIconList[key].buffCt==buff.changeType then - if floor==1 then - self.BuffIconList[key]:Dispose() - self.BuffIconList[key] = nil - else - self.BuffIconList[key]:SetCount(floor-1) - end - return - end - --持续伤害类型,伤害系数 - elseif buffType == BuffName.DOT then - if self.BuffIconList[key].buffDamageType==buff.damageType and self.BuffIconList[key].buffDamageFactor==buff.damageFactor then - if floor==1 then - self.BuffIconList[key]:Dispose() - self.BuffIconList[key] = nil - else - self.BuffIconList[key]:SetCount(floor-1) - end - return - end - --控制类型 - elseif buffType == BuffName.Control then - if self.BuffIconList[key].buffCtrlType==buff.ctrlType then - if floor==1 then - self.BuffIconList[key]:Dispose() - self.BuffIconList[key] = nil - else - self.BuffIconList[key]:SetCount(floor-1) - end - return - end - elseif buffType == BuffName.HOT then - if self.BuffIconList[key].healValue==buff.healValue then - if floor==1 then - self.BuffIconList[key]:Dispose() - self.BuffIconList[key] = nil - else - self.BuffIconList[key]:SetCount(floor-1) - end - return - end - end - end - end + if self.BuffIconList[buff.id] then + self.BuffIconList[buff.id]:Dispose() + self.BuffIconList[buff.id] = nil + end end -- 卸载所有动画 function BuffCtrl:RemoveAllBuffIcon() diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffView.lua b/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffView.lua index 5595c3617e..d556cfe92d 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffView.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/View/Unit/BuffView.lua @@ -7,14 +7,6 @@ function BuffView.New(go, buff, icon) instance.go = go instance.buff = buff - instance.buffPropertyName = buff.propertyName - instance.buffValue = buff.Value - instance.buffCt = buff.changeType - instance.buffDamageType = buff.damageType - instance.buffDamageFactor = buff.damageFactor - instance.buffCtrlType = buff.ctrlType - instance.healValue = buff.healValue - instance.levelText = Util.GetGameObject(go, "level"):GetComponent("Text") instance.layerText = Util.GetGameObject(go, "layer"):GetComponent("Text") instance.roundText = Util.GetGameObject(go, "round"):GetComponent("Text") @@ -24,15 +16,13 @@ function BuffView.New(go, buff, icon) instance.icon.sprite = Util.LoadSprite(icon) instance.icon.color = Color.New(1,1,1,1) - -- if buff.layer and buff.cover then - -- instance.levelText.text = tostring(buff.layer) - -- instance.count = buff.layer - -- else - -- instance.levelText.text = "" - -- instance.count = 1 - -- end - instance.levelText.text = "" - instance.count = 1 + if buff.layer and buff.cover then + instance.levelText.text = tostring(buff.layer) + instance.count = buff.layer + else + instance.levelText.text = "" + instance.count = 1 + end instance.layerText.text = "" instance.roundText.text = "" instance.hideFlag = false @@ -53,7 +43,7 @@ function BuffView:SetCount(count) count = self.count end - --if not self.buff.cover then + if not self.buff.cover then if count == 1 then --只有1个独立buff,不显示数字 self.layerText.text = "" self.count = 1 @@ -61,7 +51,7 @@ function BuffView:SetCount(count) self.layerText.text = tostring(count) self.count = count end - --end + end end function BuffView:SetLayer(buff)