139 lines
4.9 KiB
Plaintext
139 lines
4.9 KiB
Plaintext
|
require("LuaUtil")
|
|||
|
require("Util")
|
|||
|
PropBaseAttrSub = {}
|
|||
|
|
|||
|
local _CombatText
|
|||
|
local _newCombatTextOne
|
|||
|
local _newCombatTextTwo
|
|||
|
function PropBaseAttrSub.Awake( )
|
|||
|
_CombatText = _Combat:GetComponent("Text")
|
|||
|
_newCombatTextOne = _newCombat:GetComponent("Text")
|
|||
|
_newCombatTextTwo = _newCombat1:GetComponent("Text")
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
function PropBaseAttrSub.OnEnable( )
|
|||
|
_newCombatTextTwo.gameObject:SetActive(true)
|
|||
|
_CombatText.gameObject:SetActive(false)
|
|||
|
_newCombatTextOne.gameObject:SetActive(false)
|
|||
|
PropBaseAttrSub.ShowNewAttr(_newCombatTextOne,_newCombatTextTwo)
|
|||
|
end
|
|||
|
local _isShowTime = 0
|
|||
|
local newStrList = {}
|
|||
|
function PropBaseAttrSub.Update( )
|
|||
|
_isShowTime = _isShowTime + CS.UnityEngine.Time.deltaTime
|
|||
|
-- <color=#ffba35>对玩家增加伤害</color> 11%<color=#3ce067>+8%(强化)</color><color=#3ce067>+10%(词条)</color><color=#3ce067>+207(狂化)</color>
|
|||
|
if _isShowTime >= 0.2 then
|
|||
|
_isShowTime = 0
|
|||
|
if _newCombatTextOne ~= nil and _newCombatTextOne.text ~= '' and _newCombatTextOne.text ~= nil then
|
|||
|
PropBaseAttrSub.ShowNewAttr(_newCombatTextOne,_newCombatTextTwo)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function PropBaseAttrSub.ShowNewAttr(_Attrs,_newAttrs)
|
|||
|
_newCombatTextTwo.gameObject:SetActive(true)
|
|||
|
_CombatText.gameObject:SetActive(false)
|
|||
|
_newCombatTextOne.gameObject:SetActive(false)
|
|||
|
|
|||
|
local PropertyName = '' --属性名
|
|||
|
local _newStr = '' --属性值字符串
|
|||
|
local shuxingzhi = 0 --属性值
|
|||
|
local _jiaHao = PropBaseAttrSub.split(_Attrs.text,"+")
|
|||
|
|
|||
|
if #_jiaHao < 2 then
|
|||
|
-- 没有属性加成
|
|||
|
_newCombatTextTwo.text = _Attrs.text
|
|||
|
return
|
|||
|
end
|
|||
|
|
|||
|
local _kong = PropBaseAttrSub.split(_Attrs.text," ")
|
|||
|
for i=1,#_kong do
|
|||
|
PropertyName = _kong[1]
|
|||
|
_newStr = _kong[2]
|
|||
|
-- ELog('属性名字。。'..PropertyName)
|
|||
|
-- ELog('新的字符串。。'.._newStr)
|
|||
|
local _danShuMingHao = PropBaseAttrSub.split(_newStr,"<")
|
|||
|
for ii=1,#_danShuMingHao do
|
|||
|
local shuxingzhiStr = _danShuMingHao[1]
|
|||
|
shuxingzhi = string.gsub(shuxingzhiStr, "%%", "")
|
|||
|
--ELog('属性值。。'..shuxingzhi)
|
|||
|
end
|
|||
|
end
|
|||
|
if shuxingzhi + 0 > 100 then
|
|||
|
_newCombatTextTwo.text = _Attrs.text
|
|||
|
PropBaseAttrSub.ShowUpdateStr()
|
|||
|
return
|
|||
|
end
|
|||
|
--计算得到
|
|||
|
local kuanghua = '' --狂化没有%
|
|||
|
local newKuanghua= '' --狂化有%
|
|||
|
-- 获取
|
|||
|
local zengjiadeV = '' -- 狂化百分比有%
|
|||
|
local newzengjiadeV = ''--狂化百分比没有%
|
|||
|
for j=1,#_jiaHao do
|
|||
|
|
|||
|
if j == #_jiaHao then
|
|||
|
kuanghua = _jiaHao[j]
|
|||
|
--ELog(kuanghua ..' 。。狂化')
|
|||
|
local variate =PropBaseAttrSub.split(kuanghua,"(")
|
|||
|
zengjiadeV = variate[1]
|
|||
|
newzengjiadeV = string.gsub(zengjiadeV, "%%", "")
|
|||
|
--ELog(newzengjiadeV ..' ..这是不是大于100')
|
|||
|
local int_newzengjiadeV = tonumber(newzengjiadeV)
|
|||
|
if int_newzengjiadeV+1 > 100 then
|
|||
|
newKuanghua = int_newzengjiadeV/100 .. '%' .. CS.GCGame.Table.StrDictionary.GetClientDictionaryString("#{5808}")
|
|||
|
-- ELog(newKuanghua..' 。。狂化百分比')
|
|||
|
else
|
|||
|
newKuanghua = int_newzengjiadeV .. '%' .. CS.GCGame.Table.StrDictionary.GetClientDictionaryString("#{5439}")
|
|||
|
--ELog(newKuanghua..' 。。不是狂化百分比')
|
|||
|
end
|
|||
|
end
|
|||
|
local geShu = #_jiaHao + 0
|
|||
|
local _mPbs = _jiaHao
|
|||
|
|
|||
|
if geShu == 1 then
|
|||
|
_newCombatTextTwo.text = _Attrs.text
|
|||
|
end
|
|||
|
if newKuanghua == '' then
|
|||
|
_newCombatTextTwo.text = _Attrs.text
|
|||
|
else
|
|||
|
|
|||
|
if geShu == 2 then
|
|||
|
_newCombatTextTwo.text = _mPbs[1] ..'+' ..newKuanghua .. '</color>'
|
|||
|
end
|
|||
|
if geShu == 3 then
|
|||
|
_newCombatTextTwo.text = _mPbs[1].. '+' .._mPbs[2] .. '+' ..newKuanghua .. '</color>'
|
|||
|
end
|
|||
|
if geShu == 4 then
|
|||
|
_newCombatTextTwo.text = _mPbs[1].. '+' .._mPbs[2] .. '+' .._mPbs[3] .. '+' ..newKuanghua .. '</color>'
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
PropBaseAttrSub.ShowUpdateStr()
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
function PropBaseAttrSub.ShowUpdateStr()
|
|||
|
local _finallyStr = string.gsub(_newCombatTextTwo.text, "%(", "(")
|
|||
|
_newCombatTextTwo.text = string.gsub(_finallyStr, "%)", ")")
|
|||
|
end
|
|||
|
|
|||
|
-- 参数:待分割的字符串,分割字符
|
|||
|
-- 返回:子串表.(含有空串)
|
|||
|
function PropBaseAttrSub.split(str, split_char)
|
|||
|
local sub_str_tab = {}
|
|||
|
while true do
|
|||
|
if split_char ~= nil then
|
|||
|
local pos = string.find(str, split_char)
|
|||
|
if not pos then
|
|||
|
table.insert(sub_str_tab,str)
|
|||
|
break
|
|||
|
end
|
|||
|
local sub_str = string.sub(str, 1, pos - 1)
|
|||
|
table.insert(sub_str_tab,sub_str)
|
|||
|
str = string.sub(str, pos + 1, string.len(str))
|
|||
|
end
|
|||
|
end
|
|||
|
return sub_str_tab
|
|||
|
end
|