--移动组件 local ExpUISystem = {} --加载需要的模块 local EventSystem = require('Event/EventSystem') local FirstPersonEventDispatcher = require"Battle/Logic/Event/FirstPersonEventDispatcher" local pairs=pairs local ipairs=ipairs local math=math local string=string local FP=FP local DISTANCE_IN_TARGET = 35*35 local DISTANCE_OUT_TARGET = 60*60 local Enum_BubbleType = { ByTime = 1, ByDistance = 2, } local BubbleChecker = {} local private = { --血量改变冒字合批字典,key为entityId和batch的组合 batchHPChangeTaskDic = {}, _bubbleExpEntityDic = {}, _curTargetEntity = nil, --锁定UI当前锁定的人(目前是Boss血条) _targetEntityDic = {}, --锁定UI可以锁定的人字典(目前是Boss血条)(不包含当前) --以后多boss时候再考虑,现在策划没需求,没有办法做 _inTargetUI = false, } local EventID=EventID local LuaConst=LuaConst local LogicUpdateManager = LogicUpdateManager local EntityHeadUIModule = require("View/Battle/BattleEntityUI/EntityUIModule/EntityHeadUIModule") --Tick function ExpUISystem.OnUpdate(deltaTime) for k,v in pairs(private.batchHPChangeTaskDic) do ExpUISystem.OnHPChange(v.expEntity, v.caster, v.delta, v.value, v.init,v.hpChangeType,nil ,v.isAboutMe) private.batchHPChangeTaskDic[k] = nil end for k, expEntity in pairs(private._bubbleExpEntityDic) do local characterData = expEntity.Entity.components.base.CurCharacterData if BubbleChecker[characterData.BubbleType](expEntity,characterData,deltaTime) then SystemManager.ShowBubbleDialogue(expEntity.Entity,characterData.BubbleID) end end if private._curTargetEntity and LogicUpdateManager._curEntity then local mainPos = LogicUpdateManager._curEntity.components.move.LogicPos local targetPos = private._curTargetEntity.components.move.LogicPos if private._inTargetUI then if FP.V2.IsDistanceSqrGreater(mainPos, targetPos, DISTANCE_OUT_TARGET) then EventSystem.Dispatch(EventID.UIBattle_Level_SetUpBoss,false) private._inTargetUI = false end else if not FP.V2.IsDistanceSqrGreater(mainPos, targetPos, DISTANCE_IN_TARGET) then local expEntity = private._curTargetEntity.ExpEntity expEntity.components.ui.LastAM = FP.tonumberV1(expEntity.Entity.components.attr.am) EventSystem.Dispatch(EventID.UIBattle_Level_SetUpBoss, true, expEntity.Entity:GetCharacterID(), expEntity.Entity.EntityID) private.InitUISystem(expEntity) private._inTargetUI = true end end end end function ExpUISystem.Clear() for k, v in pairs(private._bubbleExpEntityDic) do private._bubbleExpEntityDic[k] = nil end private._inTargetUI = false private._curTargetEntity = nil end --[[ 激活 --]] function ExpUISystem.OnBorn(expEntity) local entity = expEntity.Entity local characterData = entity.components.base.CurCharacterData ExpUISystem.DispatchModelUIEvent(expEntity) --for bubble if BubbleChecker[characterData.BubbleType] then private._bubbleExpEntityDic[entity.EntityID] = expEntity end end function ExpUISystem.DispatchModelUIEvent(expEntity) local entity = expEntity.Entity local logicInitData = entity._logicInitData --TODO 修改结构,直接调用ExpEntity的CreateModel接口 if logicInitData.isSyncMove or logicInitData.isStatue or LevelManager.IsShowHeroNameInNoBattleLevel() then EventSystem.Dispatch(EventID.UIBattle_NameElement_Create, expEntity, expEntity:GetPlayerModelName()) else local characterData = entity.components.base.CurCharacterData local monsterFeature = entity.components.base.CurMonsterFeature local type = logicInitData.CharacterType local name = "" if type == LuaConst.CharacterType.Hero or type == LuaConst.CharacterType.Illusion then if LevelManager.IsShowHeroLifeBarLevel() then name = expEntity:GetPlayerModelName() else ExpUISystem.CreatePetUIName(expEntity) return end elseif type == LuaConst.CharacterType.NPC then if Const_IDS[characterData.NpcNameIDS] and Const_IDS[characterData.NPCTitleIDS] then name = UIUtils.GetLocalizedTxt(Const_IDS[characterData.NpcNameIDS]) local title = UIUtils.GetLocalizedTxt(Const_IDS[characterData.NPCTitleIDS]) if title and string.len(title) > 0 then title = UTL.Color.FormatTextByColor(characterData.Color, title) name = title .. '\n' .. name end else if not Const_IDS[characterData.NpcNameIDS] then logging.error(LTAG.ERROR, "HYW : 找不到IDS : ", characterData.NpcNameIDS) return end if not Const_IDS[characterData.NPCTitleIDS] then logging.error(LTAG.ERROR, "HYW : 找不到IDS : ", characterData.NPCTitleIDS) return end end elseif monsterFeature.HeadHpUIType > 0 then if Const_IDS[characterData.MonsterNameIDS] then if entity.isRetinue then name = string.FormatByIdsKey(characterData.MonsterNameIDS, entity:GetMasterEntity() and entity:GetMasterEntity()._logicInitData.Name or "") else name = UIUtils.GetLocalizedTxt(Const_IDS[characterData.MonsterNameIDS]) end else logging.error(LTAG.ERROR, "HYW : 找不到IDS: ", characterData.MonsterNameIDS, " characterID : ", characterData.ID) return end end ExpUISystem.DispatchModelUIByType(monsterFeature.HeadHpUIType, expEntity, name) if type == LuaConst.CharacterType.Illusion and LevelManager.IsSyncWorldBossLevel() then if LogicUpdateManager._curEntity then if LevelPlayerManager.IsSameGuild(LogicUpdateManager._curEntity, entity) or LogicUpdateManager._curEntity == entity:GetMasterEntity() then entity.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Blue) entity.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.White) entity.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.Blue) elseif LogicUpdateManager._curEntity.components.target:IsIgnoreEnemey(entity) then entity.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Yellow) entity.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.White) entity.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.White) else entity.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Red) entity.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.Red) entity.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.Red) end else entity.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Red) entity.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.Red) entity.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.Red) end end end end function ExpUISystem.DispatchModelUIByType(elementType, expEntity, name) if elementType == LuaConst.HeadHpUIType.NameElement then EventSystem.Dispatch(EventID.UIBattle_NameElement_Create, expEntity, name) elseif elementType == LuaConst.HeadHpUIType.GeneralElement then EventSystem.Dispatch(EventID.UIBattle_GeneralElement_Create, expEntity, name) elseif elementType == LuaConst.HeadHpUIType.HeroElement then EventSystem.Dispatch(EventID.UIBattle_HeroElement_Create, expEntity, name) elseif elementType == LuaConst.HeadHpUIType.Model3DUI then expEntity:CreateModel3DUI() end end function ExpUISystem.OnActive(expEntity) if not expEntity.hasModelUI then ExpUISystem.OnBorn(expEntity) private.InitUISystem(expEntity) else expEntity:SetModelUIVisible(true) end local entity = expEntity.Entity local featureData = entity.components.base.CurMonsterFeature if featureData.ShowBossUI and not private._inTargetUI then if private._curTargetEntity then if BattleDataGetter.GetBossPriority(entity.EntityID) < BattleDataGetter.GetBossPriority(private._curTargetEntity.EntityID) then private._curTargetEntity = entity end else private._curTargetEntity = entity end end end function ExpUISystem.OnSwitchHero(fromExpEntity, toExpEntity) if not toExpEntity.hasModelUI then ExpUISystem.OnBorn(toExpEntity) private.InitUISystem(toExpEntity) else toExpEntity:SetModelUIVisible(true) end if fromExpEntity.modelUIImageColorType then toExpEntity:SetModelUIImageColor(fromExpEntity.modelUIImageColorType) else toExpEntity:UpdateModelUIImageColor() end fromExpEntity:UpdateModelUIImageColor() toExpEntity:SetModelUI_Name(toExpEntity:GetPlayerModelName(fromExpEntity:GetCurNameColor())) fromExpEntity:SetModelUI_Name(fromExpEntity:GetPlayerModelName()) fromExpEntity:UpdateModelHeadGuildShow() toExpEntity:UpdateModelHeadGuildShow() local battlePropNumDic = toExpEntity.Entity.components.battleProp.propTotalNumDic for battlePropID, count in pairs(battlePropNumDic) do if count > 0 then local battlePropData = DataSheetManager.BattlePropData:GetDataByID(battlePropID) ExpUISystem.SetVisibleBattlePropExtraUI(fromExpEntity, battlePropData.ExtraUIType, false) ExpUISystem.SetVisibleBattlePropExtraUI(toExpEntity, battlePropData.ExtraUIType, true) end end end function ExpUISystem.OnDisActive(expEntity, contentPet) expEntity:SetModelUIVisible(false, contentPet) end function ExpUISystem.OnChangeAvatar(expEntity) if expEntity.Entity:IsPlayerSelf() then EventSystem.Dispatch(EventID.UIBattle_ChangeAvatar, false) end end function ExpUISystem.OnFightModeChanged(entity,fightMode) if entity:IsPlayerSelf() then ExpUISystem.RefreshEnemyModelUINameColor(entity) end end --entity要求传入一个主玩家的entity function ExpUISystem.RefreshEnemyModelUINameColor(entity) local allEnemy2dList = TargetManager.Get2DEnemyList(entity) for i,enemyList in ipairs(allEnemy2dList) do for j,enemy in ipairs(enemyList) do if LevelPlayerManager.IsSameGuild(entity, enemy) then enemy.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Blue) enemy.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.White) enemy.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.Blue) elseif entity.components.target:IsIgnoreEnemey(enemy) then enemy.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Yellow) enemy.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.White) enemy.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.White) else enemy.ExpEntity:SetModelUIImageColor(LuaConst.BloodBarColorType.Red) enemy.ExpEntity:SetModelUINameColor(LuaConst.BloodBarColorType.Red) enemy.ExpEntity:ChangeModelUI_NameColor(UTL.Color.ModelNameColor.Red) end end end end function ExpUISystem.OnDead(expEntity) local entity = expEntity.Entity local characterData = entity.components.base.CurCharacterData if private._curTargetEntity == entity then private._curTargetEntity = BattleDataGetter.GetMainBoss() --ExpUISystem.OnDead会在LevelFunction的OnEntityDead之后,所以这里直接GetMainBoss获得的是expEntity这个boss死亡后的主boss if private._curTargetEntity == nil then EventSystem.Dispatch(EventID.UIBattle_Level_SetUpBoss,false) private._inTargetUI = false end end --for bubble if BubbleChecker[characterData.BubbleType] then private._bubbleExpEntityDic[entity.EntityID] = nil end --小兵被打死隐藏血条 if entity._logicInitData.CharacterType == LuaConst.CharacterType.Monster and expEntity.RenderEntity then expEntity.RenderEntity:SetModel3DUIOnMonsterDead() end --当前该玩家死亡,不显示名字血条UI( 包括宠物的头顶名字 ) expEntity:SetModelUIVisible(false, true) end function ExpUISystem.OnRevive(expEntity) if expEntity.Entity:IsHero() then EventSystem.Dispatch(EventID.Player_Revive,expEntity.Entity) end if expEntity.Entity._logicInitData.IsPlayerSelf then UIManager.CloseView(Const_UI_Lua.UIEnum.UIBattleRelivePanel) if LevelManager.IsSyncLevel() then UIManager.CloseView(Const_UI_Lua.UIEnum.UISyncTeamPVPRevive) end end private.InitUISystem(expEntity) if expEntity.Entity:IsActive() then expEntity:SetModelUIVisible(true, true) end end function ExpUISystem.ShowNoRealTimeAttrChangeTips(expEntity, casterEntity, attrType, delta, viewerType) local number = delta if number >= 0 then number = math.ceil(number) else number = math.floor(number) end if LuaConst.UIDamageType[attrType] then expEntity:CreateHurtNumber(delta, expEntity.Entity:IsPlayerSelf(), LuaConst.UIDamageType[attrType]) end end function private.BatchHPChange(expEntity, caster, delta, value, init,hpChangeType,batch,isAboutMe) local key = expEntity.Entity.EntityID .. batch local task = private.batchHPChangeTaskDic[key] if not task then task = {} task.expEntity = expEntity task.key = key task.delta = 0 task.value = value task.init = init task.value = value task.hpChangeType = hpChangeType task.isAboutMe = isAboutMe private.batchHPChangeTaskDic[key] = task end task.caster = caster task.delta = task.delta + delta task.value = value --用新的替换旧的就可以 end function ExpUISystem.OnRefreshBossHP() EventSystem.Dispatch(EventID.UIBattle_RefreshBossHP) end --batch:伤害冒字合批显示的批次,nil表示不合批 function ExpUISystem.OnHPChange(expEntity, caster, delta, value, init, hpChangeType, batch ,isAboutMe) if batch then --合批 private.BatchHPChange(expEntity,caster,delta,value,init,hpChangeType,batch ,isAboutMe) else local entity = expEntity.Entity local comp_Attr = entity.components.attr local hp = FP.tonumberV1(value) local pc = FP.tonumberV1(comp_Attr.pc) local maxHp = FP.tonumberV1(comp_Attr:GetAttrValue(LuaConst.AttrType.hplmt)) --model ui if not expEntity.IgnoreUIHpChange then expEntity:SetModelUI_HP(hp, pc, maxHp, init) end --hurt number if caster then if isAboutMe then local comp_ExpUI = expEntity.components.ui local number = FP.tonumberV1(delta) if number >= 0 then number = math.ceil(number) else number = math.floor(number) end local uiDamageType = comp_ExpUI.CurUIDamageType if hpChangeType == LuaConst.EHpChangeType.NORMAL or hpChangeType == LuaConst.EHpChangeType.DOT then uiDamageType = comp_ExpUI.CurUIDamageType comp_ExpUI.CurUIDamageType = LuaConst.UIDamageType.Normal else if hpChangeType == LuaConst.EHpChangeType.DAMAGE_RETURN then uiDamageType = LuaConst.UIDamageType.DamageReturn elseif hpChangeType == LuaConst.EHpChangeType.LIFE_STEAL then uiDamageType = LuaConst.UIDamageType.LifeSteal end end if uiDamageType ~= LuaConst.UIDamageType.Invalid and number ~= 0 then local isSelf = entity:SelfAndMasterIsPlayerSelf() expEntity:CreateHurtNumber(number, isSelf, uiDamageType) end end end --battle ui local featureData = entity.components.base.CurMonsterFeature if featureData.ShowBossUI then EventSystem.Dispatch(EventID.UIBattle_BossHPChanged, hp, maxHp, expEntity.Entity.EntityID, FP.tonumberV1(delta)) elseif entity:IsHero() then EventSystem.Dispatch(EventID.UIBattle_PlayerHPMessageChanged, entity) end end end function ExpUISystem.OnSAChange(expEntity,value,init) if expEntity.Entity:IsMainEntityOfPlayer() then local attr = expEntity.Entity.components.attr local sa = FP.tonumberV1(value) local maxSa = FP.tonumberV1(attr:GetAttrValue(LuaConst.AttrType.salmt)) --battle ui if expEntity.Entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_AttackPad_UpdateMusouState, sa, maxSa) end end end function ExpUISystem.OnAMChange(expEntity,value,init) if expEntity.Entity.isPickupItem then return end local attr = expEntity.Entity.components.attr local am = FP.tonumberV1(value) local maxAm = FP.tonumberV1(attr:GetAttrValue(LuaConst.AttrType.amlmt)) --model ui expEntity:SetModelUI_AM(am, maxAm, init) local entity = expEntity.Entity --battle ui local monsterFeature = entity.components.base.CurMonsterFeature local lastAM = expEntity.components.ui.LastAM if monsterFeature.ShowBossUI then EventSystem.Dispatch(EventID.UIBattle_BossAMChanged, am, maxAm, lastAM, entity) elseif monsterFeature.AMOPlayEff then --如精英怪虚弱时 血条上播放特效 if am <= 0 then EventSystem.Dispatch(EventID.UIBattle_GeneralElement_BreakAmmor, expEntity:GetRenderEntity()) end end expEntity.components.ui.LastAM = am end function ExpUISystem.OnPCChange(expEntity,lmtDelta,init , showHurt) local comp_Attr = expEntity.Entity.components.attr --local comp_UI = expEntity.components.ui local isPlayerSelf = expEntity.Entity._logicInitData.IsPlayerSelf local pc = comp_Attr:GetAttrValueNum(LuaConst.RealtimeAttrType.pc) local hp = comp_Attr:GetAttrValueNum(LuaConst.RealtimeAttrType.hp) local maxHp = FP.tonumberV1(comp_Attr:GetAttrValue(LuaConst.AttrType.hplmt)) --[[ local delta = FP.tonumberV1(lmtDelta) comp_UI.LastPCLmt = comp_UI.LastPCLmt + delta if comp_UI.LastPCLmt < 0 or pc == 0 then comp_UI.LastPCLmt = 0 end ]]-- --model ui expEntity:SetModelUI_HP(hp, pc, maxHp, init) --battle ui if expEntity.Entity:IsHero() then EventSystem.Dispatch(EventID.UIBattle_PlayerHPMessageChanged ,expEntity.Entity) end if showHurt then expEntity:CreateHurtNumber(0, isPlayerSelf, LuaConst.UIDamageType.Absord) end end function ExpUISystem.OnFastPlayOver(expEntity) private.InitUISystem(expEntity) private.TryActiveInteractPanel(expEntity) end function private.InitUISystem(expEntity) local comp_Attr = expEntity.Entity.components.attr if comp_Attr then ExpUISystem.OnHPChange(expEntity, nil, FP.Const.Zero, comp_Attr:GetAttrValue(LuaConst.RealtimeAttrType.hp),true) local sa = FP.newV1(0) local playerID = expEntity.Entity:GetPlayerID() if playerID > 0 then local entities = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) if entities then sa = entities[1]:GetAttrValue(LuaConst.RealtimeAttrType.sa) end else sa = comp_Attr:GetAttrValue(LuaConst.RealtimeAttrType.sa) end ExpUISystem.OnSAChange(expEntity,sa,true) ExpUISystem.OnAMChange(expEntity, comp_Attr:GetAttrValue(LuaConst.RealtimeAttrType.am),true) ExpUISystem.OnPCChange(expEntity,FP.Const.Zero,true) ExpUISystem.OnRefreshBossHP() ExpUISystem.TryInitFourCountryScore(expEntity) ExpUISystem.TryInitGuildWarLevel(expEntity) end end function ExpUISystem.TryInitFourCountryScore(expEntity) if BattleDataGetter.IsFourCountry() then local playerScore = BattleDataGetter.GetFourCountryScoreOfPlayerID(expEntity.Entity:GetPlayerID()) EventSystem.Dispatch(EventID.UIBattle_Element_SetHeadUI, expEntity.RenderEntity, EntityHeadUIModule.HeadUIType.FourCountryScore, playerScore) end end function ExpUISystem.TryInitGuildWarLevel(expEntity) if BattleDataGetter.IsGuildWarLevel() then if expEntity.Entity:GetCampID() == BattleDataGetter.GetMyCampID() then EventSystem.Dispatch(EventID.UIBattle_Element_UpdateLevel, expEntity.RenderEntity, MDL.GuildWar.GetGuildWarLevel()) else EventSystem.Dispatch(EventID.UIBattle_Element_UpdateLevel, expEntity.RenderEntity, MDL.GuildWar.GetGuildWarEnemyLevel()) end end end function private.TryActiveInteractPanel(expEntity) local entity = expEntity.Entity if entity == LogicUpdateManager._curEntity then MDL.Interact.OnFastPlayOver() end end function private.sub(delta,realDelta) return -FP.tonumberV1(delta) end function private.add(delta,realDelta) return FP.tonumberV1(delta) end function private.mul(delta,realDelta) return FP.tonumberV1(realDelta) end function private.div(delta,realDelta) return FP.tonumberV1(realDelta) end function ExpUISystem.UpdateEntityHeadGuildShow(entity) entity.ExpEntity:UpdateModelHeadGuildShow() end function ExpUISystem.ChangeEntityName(entity,name) entity.ExpEntity:SetModelUI_Name(name) end function ExpUISystem.ChangeEntityGuildEscort(entity, quality) entity.ExpEntity:SetModelUI_GuildEscort(quality) end function ExpUISystem.ChangeEntityTitle(entity,titleID) entity.ExpEntity:SetModelUI_Title(titleID) end function ExpUISystem.ChangeEntityCountry(entity, ...) entity.ExpEntity:SetModelUICountry(...) end --称号层级最高显示 function ExpUISystem.TopEntityTitle(entity) entity.ExpEntity:TopShowTitle() end function ExpUISystem.OnAttackEnter(expEntity , skillData) if not string.isNilOrEmpty(skillData.BubbleID) then SystemManager.ShowBubbleDialogue(expEntity.Entity,skillData.BubbleID) end if not string.isNilOrEmpty(skillData.DialogueID) then EventSystem.Dispatch(EventID.UI_MainShowDialogue, skillData.DialogueID) end end --[[ 上马 -无马加载马 --]] function ExpUISystem.OnRideHorse(expEntity) EventSystem.Dispatch(EventID.UI_OnHorse ,expEntity.Entity, true) end --[[ 下马 --]] function ExpUISystem.OnOffHorse(expEntity) EventSystem.Dispatch(EventID.UI_OnHorse ,expEntity.Entity, false) end function ExpUISystem.OnDriveEntity(expEntity, interactIndex) local driveEntity = expEntity.Entity.components.drive.DriveEntity if driveEntity and expEntity.Entity == LogicUpdateManager._curEntity then -- 玩家自己上车时改变的玩家自己的视野,不能改其他玩家的 local driveData = driveEntity.components.drive:GetDriveData() if driveData then AuxUtil.SetMaxDistModelUI(driveData.DistanceModelUI) EventSystem.Dispatch(EventID.UIBattle_Element_SetMaxDistSqrModelUI, driveData.DistanceModelUI) end end --换名字 local name = expEntity.Entity._logicInitData.Name ExpUISystem.ChangeEntityName(driveEntity,name) EventSystem.Dispatch(EventID.Player_DriveEntity , driveEntity, expEntity.Entity, interactIndex) -- 查询载具的所有的buff ,如果有显示UI的buff则要显示出来 local carBuffList = driveEntity.components.buff.CurBuffObjectList for i,buffObject in ipairs(carBuffList) do local needSpecialView_updateData = nil local buffUpdateData = buffObject.BuffUpdateData local buffData = buffObject.BuffInfoData if buffData.SpecialViewType > 0 then local buffUpdateList = buffObject.BuffUpdateList if buffUpdateData and buffUpdateData.BuffLayer > 0 then needSpecialView_updateData = buffUpdateData end if not needSpecialView_updateData and buffUpdateList then for i, updateData in ipairs(buffUpdateList) do if updateData.BuffLayer > 0 then needSpecialView_updateData = updateData break; end end end if needSpecialView_updateData then FirstPersonEventDispatcher.UI_MainEntityAddSpecialViewBuff(expEntity.Entity, buffData, FP.tonumberV1(needSpecialView_updateData.BuffTimer)) end end end end function ExpUISystem.OnOffDriveEntity(expEntity, driveEntity) --换名字 local characterData = driveEntity.components.base.CurCharacterData local name = UIUtils.GetLocalizedTxt(Const_IDS[characterData.MonsterNameIDS]) ExpUISystem.ChangeEntityName(driveEntity,name) if driveEntity and driveEntity == LogicUpdateManager._curEntity then -- 玩家自己下车时改变的玩家自己的视野,不能改其他玩家的 AuxUtil.SetMaxDistModelUI() EventSystem.Dispatch(EventID.UIBattle_Element_SetMaxDistSqrModelUI, nil) end EventSystem.Dispatch(EventID.Player_OffDriveEntity , expEntity.Entity, driveEntity) end function ExpUISystem.OnInteractStart(entity, interactIndex) EventSystem.Dispatch(EventID.UI_Interact_Start, entity, interactIndex) end function ExpUISystem.OnInteractSucceed(entity) EventSystem.Dispatch(EventID.UI_Interact_Over, entity) end --region --*********** 气泡相关逻辑 ************-- Bubble function ExpUISystem.ShowBubbleDialogue(expEntity, dialogueID) local model_Dialogue = MDL.Dialogue local type = model_Dialogue.GetDialogueTypeByID(dialogueID) local random = type == model_Dialogue.DialogueType.BubbleRandom expEntity:StartBubble(dialogueID,model_Dialogue.GetDialogueIndex(dialogueID,random)) end BubbleChecker[Enum_BubbleType.ByTime] = function(expEntity,characterData,deltaTime) local comp_UI = expEntity.components.ui if not comp_UI.BubbleCtrl then comp_UI.BubbleCtrl = characterData.BubbleParam2 > 0 and math.random(characterData.BubbleParam1,characterData.BubbleParam2) or characterData.BubbleParam1 end if comp_UI.BubbleCtrl < 0 then comp_UI.BubbleCtrl = characterData.BubbleParam2 > 0 and math.random(characterData.BubbleParam1,characterData.BubbleParam2) or characterData.BubbleParam1 return true end comp_UI.BubbleCtrl = comp_UI.BubbleCtrl - deltaTime end BubbleChecker[Enum_BubbleType.ByDistance] = function(expEntity,characterData,deltaTime) local mainEntity = LogicUpdateManager._curEntity if not mainEntity then return end local comp_UI = expEntity.components.ui local pos = expEntity.Entity.components.move.LogicPos local mainPos = mainEntity.components.move.LogicPos if not FP.V2.IsDistanceGreater(mainPos, pos, characterData.BubbleParam1) then if not comp_UI.BubbleCtrl then comp_UI.BubbleCtrl = true return true end return false end comp_UI.BubbleCtrl = false end --endregion 气泡相关逻辑 function ExpUISystem.ShowDialogueWithName(entity, ids) local name = entity._logicInitData.Name if string.isNilOrEmpty(name) then name = UIUtils.GetLocalizedTxt(Const_IDS[entity.components.base.CurCharacterData.NameIDS]) end local tipsStr = string.FormatByIdsKey(ids,name) EventSystem.Dispatch(EventID.UI_MainShowTips, tipsStr) end --showTime时长:秒 。只对top黄底和top蓝底 生效 function ExpUISystem.ShowBattleReport(entity, idsStr, str, showType, showTime) local tipsStr = string.FormatByIdsKey(idsStr,str) if showType == 0 then -- top黄底 EventSystem.Dispatch(EventID.UI_MainShowYellowTips, tipsStr, showTime) elseif showType == 1 then -- top蓝底 EventSystem.Dispatch(EventID.UI_MainShowTips, tipsStr, showTime) elseif showType == 2 then -- 敲鼓的战报 EventSystem.Dispatch(EventID.UI_MainShowBattleReport, tipsStr) else -- top黄底文字(默认) EventSystem.Dispatch(EventID.UI_MainShowYellowTips, tipsStr, showTime) end end --region 道具相关 function ExpUISystem.SetVisibleBattlePropExtraUI(expEntity, UIType, isVisible, initCD) if UIType == LuaConst.EnumBattlePropExtraUIType.HeadBossIcon then expEntity:SetModelUIDragonArteryGeneral(isVisible) if isVisible and expEntity.Entity == LogicUpdateManager._curEntity and initCD then CTL.Sound.PlayGameSound("UI_die_daojishi") TimerUtil.Interval(function () CTL.Sound.PlayGameSound("UI_die_daojishi") end, 1,initCD/1000 - 1) end end end --endregion 道具相关 --region 宠物相关 function ExpUISystem.ChangePetName(expEntity, petName) expEntity:SetPetUI_Name(petName) end function ExpUISystem.CreatePetUIName(expEntity) EventSystem.Dispatch(EventID.UIBattle_NameElement_Create, expEntity, nil, true) end --endregion 宠物相关 return ExpUISystem