---@class KLUIPlayerInfoPanel:UIKmlLuaPanelBase
---@field view KLUIPlayerInfoPanelView
---@field exprienceTmeplateList table
---@field buffInfoTemplateList table
---@field KLUIBuffInfoListPanel KLUIBuffInfoListPanel
local KLUIPlayerInfoPanel = class(UIKmlLuaPanelBase)
local pkName = {
[0] = "全体",
[1] = "和平",
[4] = "组队",
[5] = "战盟",
}
---创建时调用一次
function KLUIPlayerInfoPanel:Init()
--local _, rootMinY = GUI:GetOffsetMin(self.view.root)
--local _, rootMaxY = GUI:GetOffsetMax(self.view.root)
--local _, sliderMinY = GUI:GetOffsetMin(self.view.sliderExperience)
--local _, sliderMaxY = GUI:GetOffsetMax(self.view.sliderExperience)
--local _, leftBgMinY = GUI:GetOffsetMin(self.view.leftBg)
--local _, leftBgMaxY = GUI:GetOffsetMax(self.view.leftBg)
--GUI:SetOffsetMin(self.view.root,0,rootMinY)
--GUI:SetOffsetMax(self.view.root,0,rootMaxY)
--GUI:SetOffsetMin(self.view.sliderExperience,0,sliderMinY)
--GUI:SetOffsetMax(self.view.sliderExperience,0,sliderMaxY)
--GUI:SetOffsetMin(self.view.leftBg,0,leftBgMinY)
--GUI:SetOffsetMax(self.view.leftBg,0,leftBgMaxY)
self.experienceTemplateList = {}
self.buffInfoTemplateList = {}
self.buffInfoList = {}
self.freeBuffInfo = {}
self.pkModeTemplateList = {}
-- local tbl = SL:GetConfigTable("cfg_free_buff")
if false then
---@param v cfg_free_buff_column
for i, v in pairs(tbl) do
if v.showType == 1 then
self.freeBuffInfo[v.id] = v
end
end
end
self.level = SL:GetMetaValue("LEVEL")
self:RefreshFastItem()
self.expEffects = TablePool()
end
---创建或者刷新界面数据时调用
function KLUIPlayerInfoPanel:Refresh()
self:Clear()
self:RefreshPlayerHp()
self:RefreshPlayerMp()
self:RefreshPlayerLevel()
self:RefreshExperienceAdd()
self:RefreshShield()
--self:RefreshAgsto()
self:InitPKMode()
self:RefreshComboSkillValue()
self:RefreshTotalExpGain()
local power = SL:GetMetaValue(EMetaVarGetKey.BATTERY)
GUI:SetLoadingbar_startper(self.view.sliderPower, power)
self.timer = SL:Schedule(self.timer,0, 30, -1, function()
local power = SL:GetMetaValue(EMetaVarGetKey.BATTERY)
GUI:SetLoadingbar_startper(self.view.sliderPower, power)
end)
--[[ self.MonthTime = SL:Schedule(self.MonthTime,0, 1, -1, function()
if InfoManager.monthCardInfo:IsHaveDayTime() then
---小于1天 大于0时才显示
GUI:SetActive(self.view.MonthCardBtn, true)
else
GUI:SetActive(self.view.MonthCardBtn, false)
end
end)
local index = 1
self.UIWeekTime = SL:Schedule(self.UIWeekTime,0, 0.2, -1, function()
if InfoManager.monthCardInfo:IsHaveDayTime() then
---闪烁
if index <= 0.2 then
index = 1
end
index = index - 0.15
SL:SetImageAlpha(self.view.MonthCardBtn, 1, 1, 1, index)
end
end)]]
end
---注册UI事件和服务器消息
function KLUIPlayerInfoPanel:RegistEvents()
SL:RegisterLUAEvent(LUA_EVENT_LEVELCHANGE, self.LUA_EVENT_LEVELCHANGE, self)--主角等级改变事件
SL:RegisterLUAEvent(LUA_EVENT_EXPCHANGE, self.OnExpUpdate, self)--主角经验改变事件
SL:RegisterLUAEvent(LUA_EVENT_HPCHANGE, self.RefreshPlayerHp, self)--主角血量改变事件
SL:RegisterLUAEvent(LUA_EVENT_SHIELDCHANGE, self.RefreshShield, self)--主角护盾值改变事件
SL:RegisterLUAEvent(LUA_EVENT_MPCHANGE, self.RefreshPlayerMp, self)--主角蓝量改变事件
SL:RegisterLUAEvent(LUA_EVENT_AGSTOCHANGE, self.RefreshAgsto, self)--主角技能值改变事件
SL:RegisterLUAEvent(LUA_EVENT_BUFFCHANHE, self.RefreshBuff, self)--主角buff改变事件
--SL:RegisterLUAEvent(LUA_EVENT_FREEBUFFCHANHE, self.RefreshFreeBuff, self)--主角免费buff改变事件
SL:RegisterLUAEvent(LUA_EVENT_PKMODE_CHANGE, self.LUA_EVENT_PKMODE_CHANGE, self)
SL:RegisterLUAEvent(LUA_EVENT_SWITCH_PKMODE, self.LUA_EVENT_SWITCH_PKMODE, self)
SL:RegisterLUAEvent(LUA_EVENT_CROSS_SERVER_PK_MODE, self.LUA_EVENT_CROSS_SERVER_PK_MODE, self)
SL:RegisterLUAEvent(LUA_EVENT_COMBOSKILL_PROGRESS, self.LUA_EVENT_COMBOSKILL_PROGRESS, self)
SL:RegisterLUAEvent(LUA_EVENT_INIT_SHORT_CUT, self.InitShortcutAfter, self)
SL:RegisterLUAEvent(LUA_EVENT_SELECT_ROLE, self.SelectAttackRole, self)
SL:RegisterLUAEvent(LUA_EVENT_RESET_ATTACK_ROLE, self.ResetAttackRole, self)
SL:RegisterLUAEvent(LUA_EVENT_PRIVILEGE_INFO_CHANGE, self.LUA_EVENT_PRIVILEGE_INFO_CHANGE, self)
SL:RegisterLUAEvent(LUA_EVENT_EXPERIENCE_ADD_CHANGE, self.LUA_EVENT_EXPERIENCE_ADD_CHANGE, self)
SL:RegisterLUAEvent(LUA_EVENT_MAIN_PLAYER_DIE, self.LUA_EVENT_MAIN_PLAYER_DIE, self)
SL:RegisterLUAEvent(LUA_EVENT_FastUseItem, self.LUA_EVENT_FastUseItem, self)
SL:RegisterLuaNetMsg(MessageDef.ResBagChangeMessage, self.ResBagChangeMessage,self)
SL:RegisterLUAEvent(Event.BagInfo_Change, self.BagInfo_Change, self)
SL:RegisterLUAEvent(LUA_EVENT_CLOSEWIN, self.LUA_EVENT_CLOSEWIN, self)
GUI:AddOnClickEvent(self.view.buffMenufoldBtn, self, self.OnClickBuffMenufoldBtn)
GUI:AddOnClickEvent(self.view.buffMenuexpandBtn, self, self.OnClickBuffMenuexpandBtn)
GUI:AddOnClickEvent(self.view.atkModelMenuBtn, self, self.OnClickAtkModelMenuToggle)
GUI:AddOnClickEvent(self.view.experienceMenufoldBtn, self, self.OnClickexperienceMenufoldBtn)
GUI:AddOnClickEvent(self.view.experienceMenuexpandBtn, self, self.OnClickexperienceMenuexpandBtn)
GUI:AddOnClickEvent(self.view.sliderSd, self, self.OnClickSdBtn)
GUI:AddOnClickEvent(self.view.sliderShield, self, self.OnClickShieldBtn)
GUI:AddOnClickEvent(self.view.experienceList, self, self.OnClickexperienceMenufoldBtn)
--GUI:AddOnClickEvent(self.view.MonthCardBtn, self, self.MonthCardBtn)
end
--[[function KLUIPlayerInfoPanel:MonthCardBtn()
local desc = "您的月卡剩余时间小于24小时,交易行交易税将\n提升至20%,是否购买增加月卡时间?"
GUI:UIPanel_Open("dev/ui/Common/Panel/KLUICommonTips/KLUICommonTipsPanel", nil, nil,
{ showTips = desc,
callback = self.btnCall, callbackData = nil, ui = self })
end]]
function KLUIPlayerInfoPanel:btnCall(callbackData)
GUI:UIPanel_Open("dev/outui/MonthCard/Panel/KLUIMonthCardMain/KLUIMonthCardMainPanel")
end
function KLUIPlayerInfoPanel:RefreshFastItem()
local fastItemList = SL:GetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST)
self.fastData = table.copyFrom({},fastItemList)
if not SL:HasConfig("cfg_item",self.fastData[1]) then
self.fastData[1] = 30010022
end
if not SL:HasConfig("cfg_item",self.fastData[2]) then
self.fastData[2] = 30010011
end
self.fastData_all_item = {}
GUI:DataListInitData(self.view.fast_data_list, function()
return self:FastDataListItemCountFunc()
end, function(realIndex)
return self:FastDataListItemGetFunc(realIndex)
end, function(realIndex, kmlcontrol)
return self:FastDataListItemInitFunc(realIndex, kmlcontrol)
end, function(realIndex, kmlcontrol)
return self:FastDataListItemUpdateFunc(realIndex, kmlcontrol)
end)
GUI:DataListUpdateData(self.view.fast_data_list)
end
--经验值变化回调
function KLUIPlayerInfoPanel:OnExpUpdate()
self:RefreshPlayerLevel()
if self.effectTimer then
SL:UnSchedule(self.effectTimer)
self.effectTimer = nil
end
self.effectTimer = SL:ScheduleOnce(0.5, function()
--local pos = self.view.sliderExperience_ballEndPos.rectTransform.position
local x,y,z = GUI:GetWorldPosition(self.view.sliderExperience_ballEndPos)
local effect = self:GetExpBallEffect()
SL:UIEffectDoMove(effect, Vector3.New(x,y,z), 0.8, function()
if not IsNil(effect.modelParent) then
effect.modelParent:SetActive(false)
self.expEffects:Push(effect)
end
end)
end)
end
function KLUIPlayerInfoPanel:LUA_EVENT_LEVELCHANGE()
self:RefreshPlayerLevel()
self:RefreshExperienceAdd()
end
--刷新等级
---@param data RoleChangeData
function KLUIPlayerInfoPanel:RefreshPlayerLevel(data)
local tbl = SL:GetConfig("cfg_global", 10000, "id")
local level = SL:GetMetaValue("LEVEL")
if tbl and self.level ~= level and level == tonumber(tbl.value) then
GUI:DataListUpdateData(self.view.fast_data_list)
end
self:OnClickexperienceMenufoldBtn()
self:RefreshPlayerExp()
end
--刷新经验加成
function KLUIPlayerInfoPanel:RefreshExperienceAdd()
local expriencePercent = 0
local freeBuffList = InfoManager.mainUIInfo.experienceAddInfoList
local t = table.copyFrom({},freeBuffList)
table.sort(t,function(a, b)
if a.type > b.type then
return true
end
return false
end)
local level = SL:GetMetaValue("LEVEL")
for i, v in pairs(t) do
if v.needLevel <= level then
---@type KLUIExperienceItem
local exprienceTmeplate = self.experienceTemplateList[v.type]
if not exprienceTmeplate then
exprienceTmeplate = GUI:UIPanel_Open("dev/ui/MainUI/Item/KLUIExperience/KLUIExperienceItem", self.view.experience_list, self, v, true)
self.experienceTemplateList[v.type] = exprienceTmeplate
else
exprienceTmeplate.args = v
exprienceTmeplate:Refresh()
end
if v.endTime > Time.GetServerTime() or v.endTime <=0 then
expriencePercent = expriencePercent + v.exp
end
if v.endTime > Time.GetServerTime() then
self:UpdateBuff(0,v)
else
self:UpdateBuff(1,v)
end
if v.lastCfgId ~= 0 and v.lastCfgId ~= v.cfgId then
self:UpdateBuff(1,{cfgId =v.lastCfgId})
if InfoManager.mainUIInfo.experienceAddInfoList[v.type] then
InfoManager.mainUIInfo.experienceAddInfoList[v.type].lastCfgId = 0
end
end
end
end
GUI:setVisible(self.view.arrow1, #self.experienceTemplateList > 0)
GUI:Text_setString(self.view.allExperienceTxt, expriencePercent .. "%")
end
--刷新经验条
function KLUIPlayerInfoPanel:RefreshPlayerExp()
---@type MeData
local level = SL:GetMetaValue("LEVEL")
local name = SL:GetServerName()
local exp = SL:GetMetaValue("EXP")
local expandExp = SL:GetMetaValue("EXPANDEXP")
local lvTbl = SL:GetConfig("cfg_level", level, "id")
local precent = (exp + expandExp) / lvTbl.exp
local str = string.format("%.2f", precent * 100)
local percent_ = precent
if precent >= 1 then
str = 100.0
percent_ = 1
end
if SL:HasConfig("cfg_level", level + 1, "id") then
str = " " .. str .. "% "
else
str = " "
precent = 1
end
precent = math.floor(precent * 100)
--GUI:Text_setString(self.view.level, "等级" .. level .. str .. "[" .. name .. "]")
GUI:Text_setString(self.view.level, "等级" .. level )
GUI:SetLoadingbar_startper(self.view.sliderExperience, precent)
--设置经验球飞行的终点坐标
local width = SL:GetMetaValue(EMetaVarGetKey.SCREEN_WIDTH)
local endX = width * percent_
--local pos = self.view.sliderExperience_ballEndPos.rectTransform.anchoredPosition
local pos = GUI:GetAnchoredPosition(self.view.sliderExperience_ballEndPos)
pos.x = endX
--self.view.sliderExperience_ballEndPos.rectTransform.anchoredPosition = pos
GUI:SetAnchoredPosition(self.view.sliderExperience_ballEndPos, pos)
end
--刷新血条
---@param data RoleChangeData
function KLUIPlayerInfoPanel:RefreshPlayerHp(data)
---@type MeData
local hp = SL:GetMetaValue("HP")
local maxHp = SL:GetMetaValue("MAXHP")
local precent = hp / maxHp
precent = math.floor(precent * 100)
GUI:Text_setString(self.view.hpTxt, tostring(hp))
GUI:SetLoadingbar_startper(self.view.sliderHp, precent)
end
--刷新蓝条
---@param data RoleChangeData
function KLUIPlayerInfoPanel:RefreshPlayerMp(data)
---@type MeData
local mp = SL:GetMetaValue("MP")
local maxMp = SL:GetMetaValue("MAXMP")
local precent = mp / maxMp
precent = math.floor(precent * 100)
GUI:Text_setString(self.view.mpTxt, tostring(mp))
GUI:SetLoadingbar_startper(self.view.sliderMp, precent)
end
--刷新护盾值
---@param data RoleChangeData
function KLUIPlayerInfoPanel:RefreshShield(data)
---@type MeData
local shield = SL:GetMetaValue("SHIELD")
local maxShield = SL:GetMetaValue("MAXSHIELD")
if maxShield ~= 0 then
local precent = shield / maxShield
precent = math.floor(precent * 100)
GUI:Text_setString(self.view.sdTxt, tostring(shield))
GUI:SetLoadingbar_startper(self.view.sliderSd, precent)
end
GUI:setVisible(self.view.sdContainer, maxShield ~= 0)
end
--刷新技能值
---@param data RoleChangeData
function KLUIPlayerInfoPanel:RefreshAgsto(data)
---@type MeData
local agsto = SL:GetMetaValue("AGSTO")
local maxAgsto = SL:GetMetaValue("MAXAGSTO")
if maxAgsto ~= 0 then
local precent = agsto / maxAgsto
precent = math.floor(precent * 100)
GUI:Text_setString(self.view.shieldTxt, tostring(agsto))
GUI:SetLoadingbar_startper(self.view.sliderShield, precent)
end
GUI:setVisible(self.view.shieldContainer, maxAgsto ~= 0)
end
--刷新buff
---@param eventId number
---@param eventData BuffChangeData
function KLUIPlayerInfoPanel:RefreshBuff(eventId, eventData)
if not eventData then
return
end
local rid = SL:GetMetaValue("MAIN_ACTOR_ID")
if eventData.roleId and rid ~= tostring(eventData.roleId) then
return
end
--0:Add 1:Remove 2:Update
if string.isNullOrEmpty(eventData.buff.buffTbl.showIcon) then
-- 图标为空不显示
return
end
self:UpdateBuff(eventData.updateType,{cfgId = eventData.buff.cfgId,endTime = eventData.buff.endTime,buffText=eventData.buff.buffText})
end
function KLUIPlayerInfoPanel:UpdateBuff(updateType,data)
if updateType == 0 and table.count(self.buffInfoTemplateList) < 4 then
--添加
self:AddOrRemoveBuff(data,true)
---@type KLBuffInfoItem
local buffInfoTemplateItem = self.buffInfoTemplateList[data.cfgId]
if not buffInfoTemplateItem then
buffInfoTemplateItem = GUI:UIPanel_Open("dev/ui/MainUI/Item/KLBuffInfo/KLBuffInfoItem", self.view.buffs_list, self, data, true)
self.buffInfoTemplateList[data.cfgId] = buffInfoTemplateItem
else
buffInfoTemplateItem.args = data
buffInfoTemplateItem:Refresh()
end
elseif updateType == 1 then
--移除
---@type KLBuffInfoItem
local buffInfoTemplateItem = self.buffInfoTemplateList[data.cfgId]
if buffInfoTemplateItem then
GUI:UIPanel_Close(nil, buffInfoTemplateItem)
end
self.buffInfoTemplateList[data.cfgId] = nil
self:AddOrRemoveBuff(data,false)
--有移除的后要把原来隐藏的buff显示出来
for i, v in ipairs(self.buffInfoList) do
if not self.buffInfoTemplateList[v.cfgId] and table.count(self.buffInfoTemplateList) < 4 then
buffInfoTemplateItem = GUI:UIPanel_Open("dev/ui/MainUI/Item/KLBuffInfo/KLBuffInfoItem", self.view.buffs_list, self, v, true)
self.buffInfoTemplateList[v.cfgId] = buffInfoTemplateItem
end
end
elseif updateType == 2 then
--更新
---@type KLBuffInfoItem
local buffInfoTemplateItem = self.buffInfoTemplateList[data.cfgId]
if buffInfoTemplateItem then
buffInfoTemplateItem.args = data
buffInfoTemplateItem:Refresh()
end
self:AddOrRemoveBuff(data,true)
end
if table.count(self.buffInfoTemplateList) >= 4 then
GUI:setVisible(self.view.buffMenuBtn, true)
if data.cfgId ~= 0 and updateType == 0 then
self:AddOrRemoveBuff(data,true)
end
else
GUI:setVisible(self.view.buffMenuBtn, false)
GUI:UIPanel_Close("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel")
end
local panel = GUI:GetUI("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel")
if panel then
panel.args = self.buffInfoList
panel:Refresh()
end
end
function KLUIPlayerInfoPanel:InitPKMode()
local pkInfo = { 0, 1, 4, 5 }
for i, pkMode in pairs(pkInfo) do
local pkTemplateItem = GUI:UIPanel_Open("dev/ui/MainUI/Item/KLPk/KLPkItem", self.view.atkModelMenu, self, { pkMode = pkMode, pkName = pkName[pkMode] or "" }, true)
table.insert(self.pkModeTemplateList, pkTemplateItem)
end
local pkMode = SL:GetMetaValue(EMetaVarGetKey.PKMODE)
GUI:Button_setTitleText(self.view.atkModelname, pkName[pkMode] or "")
end
function KLUIPlayerInfoPanel:LUA_EVENT_PKMODE_CHANGE(_, pkMode)
GUI:Button_setTitleText(self.view.atkModelname, pkName[pkMode] or "")
end
function KLUIPlayerInfoPanel:LUA_EVENT_SWITCH_PKMODE(_, pkMode)
self.expand = not self.expand
GUI:setVisible(self.view.atkModelMenu, self.expand)
if GlobalLuaEventManager.isCrossServer and GlobalLuaEventManager.isCrossServer == 1 then
if not SL:MeData_GetUnionId() or SL:MeData_GetUnionId() == 0 then
if pkMode ~= 0 then
SL:TipMessage("当前地图无法切换pk模式", 1, NoticeType.NoticeMid)
return
end
else
if pkMode ~= 5 then
SL:TipMessage("当前地图无法切换pk模式", 1, NoticeType.NoticeMid)
return
end
end
end
local tip = SL:GetMetaValue(EMetaVarGetKey.PKMODE_CAN_USE, pkMode)
if not string.isNullOrEmpty(tip) then
SL:TipMessage(tip, 1, NoticeType.NoticeMid)
return
end
SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, pkMode)
end
function KLUIPlayerInfoPanel:LUA_EVENT_CROSS_SERVER_PK_MODE(_, pkMode)
self.expand = false
GUI:setVisible(self.view.atkModelMenu, self.expand)
--SL:SetMetaValue(EMetaVarSetKey.SET_PKMODE, pkMode)
end
function KLUIPlayerInfoPanel:RefreshComboSkillValue()
local comboSkillId = SL:GetComboSkillId()
if comboSkillId and comboSkillId > 0 then
--RoleManager.me.skillEngine.skillCombo:SetSkillAutoReleaseSwitch(true)
SL:Skill_SetSkillAutoReleaseSwitch(true)
end
self:LUA_EVENT_COMBOSKILL_PROGRESS(_, 0)
end
function KLUIPlayerInfoPanel:RefreshTotalExpGain()
SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_GET_MONTH_PRIVILEGE_DATA)
SL:SendLuaNetMsg(LuaMessageIdToSever.TRIPLE_INCOME_PANEL)
end
---@param comboValue number -2,隐藏 -1,显示0 其他,正常显示
function KLUIPlayerInfoPanel:LUA_EVENT_COMBOSKILL_PROGRESS(_, comboValue)
local value, _ = math.modf(comboValue)
if value >= 100 then
value = 100
end
GUI:Text_setString(self.view.shieldTxt, tostring(value) .. "%")
GUI:SetLoadingbar_startper(self.view.sliderShield, value)
self.comboValue = value
SL:onLUAEvent(LUA_EVENT_COMBOVALUE_CHANGE, value)
end
function KLUIPlayerInfoPanel:OnClickBuffMenufoldBtn()
GUI:setVisible(self.view.buffMenufoldBtn, false)
GUI:setVisible(self.view.buffMenuexpandBtn, true)
local panel = GUI:GetUI("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel")
if not panel then
panel = GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel", nil, nil, self.buffInfoList)
else
panel.args = self.buffInfoList
panel:Refresh()
end
end
function KLUIPlayerInfoPanel:OnClickBuffMenuexpandBtn()
GUI:setVisible(self.view.buffMenufoldBtn, true)
GUI:setVisible(self.view.buffMenuexpandBtn, false)
GUI:UIPanel_Close("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel")
end
function KLUIPlayerInfoPanel:OnClickAtkModelMenuToggle()
self.expand = not self.expand
GUI:setVisible(self.view.atkModelMenu, self.expand)
end
function KLUIPlayerInfoPanel:OnClickexperienceMenufoldBtn()
GUI:setVisible(self.view.experienceList, false)
GUI:setVisible(self.view.experienceMenuexpandBtn, true)
GUI:setVisible(self.view.experienceMenufoldBtn, false)
GUI:setRotation(self.view.arrow1, 0)
end
function KLUIPlayerInfoPanel:OnClickexperienceMenuexpandBtn()
GUI:setVisible(self.view.experienceList, true)
GUI:setVisible(self.view.experienceMenuexpandBtn, false)
GUI:setVisible(self.view.experienceMenufoldBtn, true)
GUI:setRotation(self.view.arrow1, 180)
end
function KLUIPlayerInfoPanel:OnClickSdBtn()
local shield = SL:GetMetaValue("SHIELD")
local maxShield = SL:GetMetaValue("MAXSHIELD")
local des = "SD防护值 " .. shield .. "/" .. maxShield .. "\nPVP时受到的伤害,该伤害值以SD90%,血量10%的比例损耗\n若伤害值大于SD损耗,则剩余伤害仍从血量损耗\nSD最大值受人物等级和防御力影响"
GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLSDTip/KLSDTipPanel", nil, nil, { content = des, y = -237, width = 395, height = 90 })
end
function KLUIPlayerInfoPanel:OnClickShieldBtn()
--local agsto = SL:GetMetaValue("AGSTO")
--local maxAgsto = SL:GetMetaValue("MAXAGSTO")
if not self.comboValue then
self.comboValue = 0
end
local des = "连击技 " .. self.comboValue .. "%\n连击技会对周围目标造成伤害,且对主目标额外造成大量伤害\n连击能量达到100%后会自动施放连击技"
GUI:UIPanel_Open("dev/ui/MainUI/Panel/KLSDTip/KLSDTipPanel", nil, nil, { content = des, x = 330, y = -258, width = 390, height = 70 })
end
function KLUIPlayerInfoPanel:Close()
if self.timer then
SL:UnSchedule(self.timer)
self.timer = nil
end
if self.effectTimer then
SL:UnSchedule(self.effectTimer)
self.effectTimer = nil
end
--[[ if self.MonthTime then
SL:UnSchedule(self.MonthTime)
self.MonthTime = nil
end
if self.UIWeekTime then
SL:UnSchedule(self.UIWeekTime)
self.UIWeekTime = nil
end]]
--SL:SetImageAlpha(self.view.MonthCardBtn, 1, 1, 1, 1)
end
---清除数据
function KLUIPlayerInfoPanel:Clear()
---@param exprienceTmeplate KLUIExperienceItem
for i, exprienceTmeplate in pairs(self.experienceTemplateList) do
GUI:UIPanel_Close(nil, exprienceTmeplate)
end
self.experienceTemplateList = {}
---@param buffInfoTemplateItem KLBuffInfoItem
for i, buffInfoTemplateItem in pairs(self.buffInfoTemplateList) do
GUI:UIPanel_Close(nil, buffInfoTemplateItem)
end
self.buffInfoTemplateList = {}
GUI:UIPanel_Close("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel")
table.clear(self.buffInfoList)
---@param pkModeTemplate KLPkItem
for i, pkModeTemplate in pairs(self.pkModeTemplateList) do
GUI:UIPanel_Close(nil, pkModeTemplate)
end
self.pkModeTemplateList = {}
end
function KLUIPlayerInfoPanel:FastDataListItemCountFunc()
--local count = #self.fastData
--local maxShield = SL:GetMetaValue("MAXSHIELD")
--local maxAgsto = SL:GetMetaValue("MAXAGSTO")
--if maxShield == 0 or maxAgsto == 0 then
-- GUI:setPositionX(self.view.left,25)
-- GUI:setPositionX(self.view.right,18)
--else
-- count = count - 1
-- GUI:setPositionX(self.view.left,36)
-- GUI:setPositionX(self.view.right,-22)
--end
--GUI:setContentSize(self.view.fast_grid, count * 70, 64)
--return count
return 4
end
function KLUIPlayerInfoPanel:FastDataListItemGetFunc(realIndex)
local data = self.fastData[realIndex + 1]
local message = { cfgId = data, itemIndex = realIndex + 1 }
local item = GUI:UIPanel_Open("dev/ui/MainUI/Item/KLFast_PC/KLFastItem", self.view.fast_data_list, self, message, true)
self.fastData_all_item[item.view.root] = item
return item.view.root
end
function KLUIPlayerInfoPanel:FastDataListItemInitFunc(realIndex, kmlcontrol)
end
function KLUIPlayerInfoPanel:FastDataListItemUpdateFunc(realIndex, kmlcontrol)
local data = self.fastData[realIndex + 1]
local message = { cfgId = data, itemIndex = realIndex + 1 }
self.fastData_all_item[kmlcontrol]:RefreshItem(message)
end
function KLUIPlayerInfoPanel:InitShortcutAfter()
local fastItemList = SL:GetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST)
self.fastData = table.copyFrom({},fastItemList)
if not SL:HasConfig("cfg_item",self.fastData[1]) then
self.fastData[1] = 30010022
end
if not SL:HasConfig("cfg_item",self.fastData[2]) then
self.fastData[2] = 30010011
end
GUI:DataListUpdateData(self.view.fast_data_list)
end
function KLUIPlayerInfoPanel:SelectAttackRole(_id, select_id)
local is_open = false
local is_player = SL:GetMetaValue(EMetaVarGetKey.ACTOR_IS_PLAYER, select_id)
if is_player then
is_open = true
else
local is_monster = SL:GetMetaValue(EMetaVarGetKey.ACTOR_IS_MONSTER, select_id)
if is_monster then
local role = SL:GetRoleById(select_id)
local cfgId = role.data.serverData.cfgId
is_open = SL:MonsterIsShowHP(cfgId)
end
end
if InfoManager.redFortInfo.isEnter then
is_open = false
end
if is_open then
SL:OpenBossHp(select_id)
else
SL:CloseBossHp()
end
end
function KLUIPlayerInfoPanel:ResetAttackRole()
SL:CloseBossHp()
end
function KLUIPlayerInfoPanel:LUA_EVENT_PRIVILEGE_INFO_CHANGE()
-----特权收益
--local exp = PrivilegeCardManager.GetExperienceUp()
-----三倍收益
--if PrivilegeCardManager.tripleEarningsInfo then
-- if PrivilegeCardManager.tripleEarningsInfo.effectSec > 0 then
-- exp = (100 + exp) * 3 - 100
-- end
--end
--GUI:Text_setString(self.view.allExperienceTxt, exp .. "%")
end
function KLUIPlayerInfoPanel:LUA_EVENT_EXPERIENCE_ADD_CHANGE()
self:RefreshExperienceAdd()
end
function KLUIPlayerInfoPanel:LUA_EVENT_MAIN_PLAYER_DIE()
---@param buffInfoTemplateItem KLBuffInfoItem
for i, buffInfoTemplateItem in pairs(self.buffInfoTemplateList) do
GUI:UIPanel_Close(nil, buffInfoTemplateItem)
end
self.buffInfoTemplateList = {}
GUI:UIPanel_Close("dev/ui/MainUI/Panel/KLUIBuffInfoList/KLUIBuffInfoListPanel")
table.clear(self.buffInfoList)
end
---@return UIModel
function KLUIPlayerInfoPanel:GetExpBallEffect()
local effect = self.expEffects:Pop()
if next(effect) == nil then
local obj = GUI:GetGameObject(self.view.root)
---@type UIModelData
local t = { id = 148, tableName = "cfg_model_effect", parent = obj,
selfRotate = false, resetPosition = true, pos = { 0, 0, 0 }, scale = { 100, 100, 100 } }
--t.diffuseFlowing = DataManager.gmInfo.diffuseFlowing
t.diffuseFlowing = SL:GmInfo_GetDiffuseFlowing()
effect = SL:AddModelEffect(t)
end
effect.modelParent:SetActive(true)
local pos = effect.modelParent.transform.anchoredPosition
pos.x = 0
--pos.y = -self.view.root.rectTransform.localPosition.y
local _,ly,_ = GUI:GetLocalPosition(self.view.root)
pos.y = -ly
effect.modelParent.transform.anchoredPosition = pos
return effect
end
---获得药品后快捷栏自动选择
function KLUIPlayerInfoPanel:ResBagChangeMessage(id, message)
if not message.itemList or #message.itemList <= 0 then
return
end
---@type number[]
local fastItems = SL:GetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST)
local fast_list = {}
local hp_pill_itemId = 0
local mp_pill_itemId = 0
for i, v in ipairs(message.itemList) do
if v.item and v.item.cfgId and v.item.count and v.item.count > 0 then
---@type cfg_item_column
local tbl1 = SL:GetConfig("cfg_item",v.item.cfgId)
if tbl1.isFast and tbl1.isFast == 1 then
local isInsert = true
--蓝药
if tbl1.type==3 and tbl1.subType==1 and tbl1.id>=30010012 and tbl1.id<=30010022 then
if not SL:HasConfig("cfg_item",fastItems[1]) then
mp_pill_itemId = v.item.cfgId
else
--local tbl2 = ConfigManager.Get_cfg_item(fastItems[1])
local tbl2 = SL:GetConfig("cfg_item", fastItems[1])
if tbl1.rank > tbl2.rank then
mp_pill_itemId = v.item.cfgId
end
end
isInsert = false
end
--血药
if tbl1.type==3 and tbl1.subType==1 and tbl1.id>=30010001 and tbl1.id<=30010011 then
if not SL:HasConfig("cfg_item",fastItems[2]) then
hp_pill_itemId = v.item.cfgId
else
--local tbl2 = ConfigManager.Get_cfg_item(fastItems[2])
local tbl2 = SL:GetConfig("cfg_item", fastItems[2])
if tbl1.rank > tbl2.rank then
hp_pill_itemId = v.item.cfgId
end
end
isInsert = false
end
if isInsert then
table.insert(fast_list,{cfgId=v.item.cfgId,index=v.index,id=v.item.id,isJoin = 0})
end
end
end
end
if #fast_list > 0 then
local current_fast_list = {}
for i=1,#self.fastData,1 do
table.insert(current_fast_list,{cfgId=self.fastData[i],idx=i,is_new=false})
end
for i=1,#current_fast_list,1 do
local current_cfgId = current_fast_list[i].cfgId
if current_cfgId ~= 0 then
--local tbl1 = ConfigManager.Get_cfg_item(current_cfgId)
local tbl1 = SL:GetConfig("cfg_item", current_cfgId)
current_fast_list[i].Group = tbl1.Group
current_fast_list[i].rank = tbl1.rank
else
current_fast_list[i].Group = 0
current_fast_list[i].rank = 0
end
end
table.sort(current_fast_list, function(a, b)
if a.Group ~= b.Group then
return a.Group < b.Group
else
return a.rank < b.rank
end
end)
for i=1,#fast_list,1 do
local current_cfgId = fast_list[i].cfgId
--local tbl1 = ConfigManager.Get_cfg_item(current_cfgId)
local tbl1 = SL:GetConfig("cfg_item", current_cfgId)
fast_list[i].Group = tbl1.Group
fast_list[i].rank = tbl1.rank
end
table.sort(fast_list, function(a, b)
if a.Group ~= b.Group then
return a.Group < b.Group
else
return a.rank > b.rank
end
end)
for i=1,#current_fast_list,1 do
local current_cfgId = current_fast_list[i].cfgId
if current_cfgId ~= 0 then
for j=1,#fast_list,1 do
local data = fast_list[j]
if current_cfgId == data.cfgId then
fast_list[j].isJoin = 2
end
end
end
end
for i=1,#current_fast_list,1 do
if not current_fast_list[i].is_new then
local current_cfgId = current_fast_list[i].cfgId
if current_cfgId ~= 0 then
for j=1,#fast_list,1 do
local data = fast_list[j]
if data.isJoin == 0 and current_fast_list[i].Group == data.Group then
if data.rank > current_fast_list[i].rank then
current_fast_list[i].cfgId = data.cfgId
current_fast_list[i].is_new = true
fast_list[j].isJoin = 1
break
end
end
end
end
end
end
table.sort(current_fast_list, function(a, b)
return a.idx < b.idx
end)
for i=1,#current_fast_list,1 do
if not current_fast_list[i].is_new then
local current_cfgId = current_fast_list[i].cfgId
if current_cfgId == 0 then
for j=1,#fast_list,1 do
local data = fast_list[j]
if data.isJoin == 0 then
current_fast_list[i].cfgId = data.cfgId
current_fast_list[i].is_new = true
fast_list[j].isJoin = 1
break
end
end
end
end
end
for i=1,#current_fast_list,1 do
if current_fast_list[i].is_new and current_fast_list[i].idx >2 then
SL:SetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST, current_fast_list[i].idx, current_fast_list[i].cfgId, 0)
end
end
end
if mp_pill_itemId ~= 0 then
SL:SetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST, 1, mp_pill_itemId, 0)
end
if hp_pill_itemId ~= 0 then
SL:SetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST, 2, hp_pill_itemId, 0)
end
end
function KLUIPlayerInfoPanel:BagInfo_Change(id,message)
local hp_pill_itemId = -1
local mp_pill_itemId = -1
local itemList_ = SL:GetIsFastItemList()
---@type number[]
local fastItems = SL:GetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST)
for i, item in pairs(itemList_) do
---@type cfg_item_column
local tbl1 = SL:GetConfig("cfg_item",item.cfgId)
--蓝药
if tbl1.type==3 and tbl1.subType==1 and tbl1.id>=30010012 and tbl1.id<=30010022 then
local cfgId = fastItems[1]
if mp_pill_itemId ~= -1 then
cfgId = mp_pill_itemId
end
local ownerCount = SL:GetBagItemCount(cfgId)
if not SL:HasConfig("cfg_item",fastItems[1]) or ownerCount <=0 then
mp_pill_itemId = item.cfgId
else
--local tbl2 = ConfigManager.Get_cfg_item(cfgId)
local tbl2 = SL:GetConfig("cfg_item", cfgId)
if tbl1.rank > tbl2.rank then
mp_pill_itemId = item.cfgId
end
end
end
--血药
if tbl1.type==3 and tbl1.subType==1 and tbl1.id>=30010001 and tbl1.id<=30010011 then
local cfgId = fastItems[1]
if hp_pill_itemId ~= -1 then
cfgId = hp_pill_itemId
end
local ownerCount = SL:GetBagItemCount(cfgId)
if not SL:HasConfig("cfg_item",cfgId) or ownerCount <=0 then
hp_pill_itemId = item.cfgId
else
--local tbl2 = ConfigManager.Get_cfg_item(cfgId)
local tbl2 = SL:GetConfig("cfg_item", cfgId)
if tbl1.rank > tbl2.rank then
hp_pill_itemId = item.cfgId
end
end
end
end
local ownerCount = SL:GetBagItemCount(fastItems[1])
mp_pill_itemId = (mp_pill_itemId == -1 and ownerCount <= 0) and 0 or mp_pill_itemId
if mp_pill_itemId ~= -1 and fastItems[1] ~= mp_pill_itemId then
SL:SetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST, 1, mp_pill_itemId, 0)
end
ownerCount = SL:GetBagItemCount(fastItems[2])
hp_pill_itemId = (hp_pill_itemId == -1 and ownerCount <= 0) and 0 or hp_pill_itemId
if hp_pill_itemId ~= -1 and fastItems[2] ~= hp_pill_itemId then
SL:SetMetaValue(EMetaVarGetKey.FAST_ITEM_ID_LIST, 2, hp_pill_itemId, 0)
end
SL:onLUAEvent(LUA_EVENT_FASTITEM_CHANGE)
end
function KLUIPlayerInfoPanel:LUA_EVENT_CLOSEWIN(id,panelName)
if panelName == "KLUIBuffInfoListPanel" then
self:OnClickBuffMenuexpandBtn()
end
end
function KLUIPlayerInfoPanel:AddOrRemoveBuff(data,isAdd)
local isContains = false
local pos
for i, v in pairs(self.buffInfoList) do
if v.cfgId == data.cfgId then
isContains = true
pos = i
end
end
if isContains and pos and not isAdd then
table.remove(self.buffInfoList,pos)
end
if isAdd then
if isContains then
self.buffInfoList[pos] = data
else
table.insert(self.buffInfoList,data)
end
end
end
---快捷使用道具
---@param message {key:number}
function KLUIPlayerInfoPanel:LUA_EVENT_FastUseItem(_,message)
if not table.isNullOrEmpty(message) then
for i, v in pairs(self.fastData_all_item) do
if v.args and v.args.itemIndex==message.key then
v:BtnUseClick()
return
end
end
end
end
return KLUIPlayerInfoPanel