123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953 |
- ---@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 = " <color=#BCB9B9>" .. str .. "%</color> "
- else
- str = " "
- precent = 1
- end
- precent = math.floor(precent * 100)
- --GUI:Text_setString(self.view.level, "等级" .. level .. str .. "<color=#FFFFFF>[" .. name .. "]</color>")
- 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防护值 <color=#1ADD2FFF>" .. shield .. "/" .. maxShield .. "</color>\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 = "连击技 <color=#1ADD2FFF>" .. self.comboValue .. "</color>%\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
|