------------------------------------------------ -- 作者: cy -- 日期: 2019-05-22 -- 文件: UIBossInfoTips.lua -- 模块: UIBossInfoTips -- 描述: Boss提示信息面板(快捷前往) ------------------------------------------------ local UIBossInfoTips = { AnimModule = nil, CloseBtn = nil, GoBtn = nil, HeadIconSpr = nil, NameLab = nil, LevelLab = nil, MonsterCfgID = 0, TargetCloneMapID = 0, CustomCfgID = 0, StartCountDown = false, BossType = 999, CurTime = 0, -- 计时器 CloseTime = 120 -- 自动关闭面板的时间 } -- 注册事件函数, 提供给CS端调用. function UIBossInfoTips:OnRegisterEvents() self:RegisterEvent(UIEventDefine.UIBossInfoTips_OPEN, self.OnOpen) self:RegisterEvent(UIEventDefine.UIBossInfoTips_CLOSE, self.OnClose) self:RegisterEvent(LogicLuaEventDefine.EID_EVENT_CROSSFUDI_DATA_RESULT, self.OnCrossFuDiResult) end -- 打开。obj.count = 4,obj[1] = monster配置表ID(用于获取BOSS名字、等级、头像), obj[2] = 目标cloneMapId,进入副本用 -- obj[3] = 自定义配置表ID(点击“立即前往”后,会存在BossInfoTipsSystem中,需要时自取) function UIBossInfoTips:OnOpen(obj, sender) if obj and #obj >= 2 then self.MonsterCfgID = obj[1] self.TargetCloneMapID = obj[2] if obj[3] then self.CustomCfgID = obj[3] end if obj[4] then self.BossType = obj[4] end end self.CSForm:Show(sender) self:SetAllInfo() end -- 关闭 function UIBossInfoTips:OnClose(obj, sender) self.CSForm:Hide() end function UIBossInfoTips:OnCrossFuDiResult(obj, sender) if GameCenter.CrossFuDiSystem.WaitFastEnter then if self.TargetCloneMapID == GameCenter.MapLogicSystem.MapCfg.MapId then local _bossCfg = DataConfig.DataCrossFudiBoss[self.CustomCfgID] if _bossCfg then local _posList = Utils.SplitStr(_bossCfg.Pos, "_") local _pos = Vector2(tonumber(_posList[1]), tonumber(_posList[2])) GameCenter.CrossFuDiSystem:SetCurSelectBossId(self.CustomCfgID) GameCenter.PathSearchSystem:SearchPathToPosBoss(true, _pos, self.CustomCfgID) end elseif self.TargetCloneMapID > 0 then GameCenter.CrossFuDiSystem:SetCurCityId(self.MonsterCfgID) GameCenter.CrossFuDiSystem:SetCurSelectBossId(self.CustomCfgID) GameCenter.CrossFuDiSystem:ReqCrossFudEnter(self.MonsterCfgID, 0) end GameCenter.CrossFuDiSystem.WaitFastEnter = false end end -- 第一只显示函数, 提供给CS端调用. function UIBossInfoTips:OnFirstShow() self.CSForm.UIRegion = UIFormRegion.NoticRegion; self:FindAllComponents(); self:RegUICallback(); end -- 显示之前的操作, 提供给CS端调用. function UIBossInfoTips:OnShowBefore() end -- 显示后的操作, 提供给CS端调用. function UIBossInfoTips:OnShowAfter() self.StartCountDown = true end -- 隐藏之前的操作, 提供给CS端调用. function UIBossInfoTips:OnHideBefore() end -- 隐藏之后的操作, 提供给CS端调用. function UIBossInfoTips:OnHideAfter() end -- 绑定UI组件的回调函数 function UIBossInfoTips:RegUICallback() UIUtils.AddBtnEvent(self.CloseBtn, self.OnClickCloseBtn, self) UIUtils.AddBtnEvent(self.GoBtn, self.OnClickGoBtn, self) end function UIBossInfoTips:OnClickCloseBtn() self:OnClose(nil, nil) end function UIBossInfoTips:OnClickGoBtn() -- 如果当前场景是个副本(或者跨服副本),那就是在副本中,不能跳转进去 if GameCenter.MapLogicSystem.MapCfg.Type == UnityUtils.GetObjct2Int(MapTypeDef.Copy) or GameCenter.MapLogicSystem.MapCfg.Type == UnityUtils.GetObjct2Int(MapTypeDef.CrossCopy) then Utils.ShowPromptByEnum("BossTipInCopy") return end if self.BossType == BossType.WorldBoss or self.BossType == BossType.GemBoss or self.BossType == BossType.SuitBoss then if self.TargetCloneMapID == GameCenter.MapLogicSystem.MapCfg.MapId then local _bossCfg = DataConfig.DataBossnewWorld[self.CustomCfgID] if _bossCfg then local _posList = Utils.SplitStr(_bossCfg.Pos, "_") local _pos = Vector2(tonumber(_posList[1]), tonumber(_posList[2])) GameCenter.PathSearchSystem:SearchPathToPosBoss(true, _pos, self.CustomCfgID) end elseif self.TargetCloneMapID > 0 then GameCenter.BossInfoTipsSystem.CustomCfgID = self.CustomCfgID GameCenter.DailyActivitySystem:ReqJoinActivity(4, self.TargetCloneMapID) end elseif self.BossType == BossType.SoulMonster then if self.TargetCloneMapID == GameCenter.MapLogicSystem.MapCfg.MapId then local _bossCfg = DataConfig.DataBossnewSoulBeasts[self.CustomCfgID] if _bossCfg then local _posList = Utils.SplitStr(_bossCfg.Pos, "_") local _pos = Vector2(tonumber(_posList[1]), tonumber(_posList[2])) GameCenter.PathSearchSystem:SearchPathToPosBoss(true, _pos, _bossCfg.Monsterid) end elseif self.TargetCloneMapID > 0 then GameCenter.SoulMonsterSystem.CurSelectSoulMonsterID = self.CustomCfgID GameCenter.CopyMapSystem:ReqEnterCopyMap(self.TargetCloneMapID, self.CustomCfgID); end elseif self.BossType == BossType.TianXuWar then if self.TargetCloneMapID == GameCenter.MapLogicSystem.MapCfg.MapId then local _bossCfg = DataConfig.DataUniverseBoss[self.CustomCfgID] if _bossCfg then local _posList = Utils.SplitStr(_bossCfg.Pos, "_") local _pos = Vector2(tonumber(_posList[1]), tonumber(_posList[2])) GameCenter.PathSearchSystem:SearchPathToPosBoss(true, _pos, _bossCfg.MonsterID) end elseif self.TargetCloneMapID > 0 then GameCenter.TerritorialWarSystem.CurSelectMonsterID = self.CustomCfgID GameCenter.DailyActivitySystem:ReqJoinActivity(109, self.TargetCloneMapID) end elseif self.BossType == BossType.FuDiBoss then if self.TargetCloneMapID == GameCenter.MapLogicSystem.MapCfg.MapId then local _bossCfg = DataConfig.DataGuildBattleBoss[self.CustomCfgID] if _bossCfg then local _posList = Utils.SplitStr(_bossCfg.Pos, "_") local _pos = Vector2(tonumber(_posList[1]), tonumber(_posList[2])) GameCenter.FuDiSystem.CurSelectBossId = self.CustomCfgID GameCenter.PathSearchSystem:SearchPathToPosBoss(true, _pos, self.MonsterCfgID) end elseif self.TargetCloneMapID > 0 then GameCenter.BossInfoTipsSystem.CustomCfgID = self.CustomCfgID GameCenter.FuDiSystem.CurSelectBossId = self.CustomCfgID GameCenter.DailyActivitySystem:ReqJoinActivity(207, self.TargetCloneMapID) end elseif self.BossType == BossType.CrossFuDi then GameCenter.CrossFuDiSystem:ReqAllCrossFudInfo() GameCenter.CrossFuDiSystem.WaitFastEnter = true elseif self.BossType == BossType.CrossHorseBoss then GameCenter.MountBossSystem.CurSelectBossID = self.CustomCfgID GameCenter.DailyActivitySystem:ReqJoinActivity(22, self.CustomCfgID) elseif self.BossType == BossType.NewBossHome then if self.TargetCloneMapID == GameCenter.MapLogicSystem.MapCfg.MapId then local _bossCfg = DataConfig.DataBossnewWorld[self.CustomCfgID] if _bossCfg then local _posList = Utils.SplitStr(_bossCfg.Pos, "_") local _pos = Vector2(tonumber(_posList[1]), tonumber(_posList[2])) GameCenter.PathSearchSystem:SearchPathToPosBoss(true, _pos, self.CustomCfgID) end elseif self.TargetCloneMapID > 0 then GameCenter.BossInfoTipsSystem.CustomCfgID = self.CustomCfgID GameCenter.DailyActivitySystem:ReqJoinActivity(101, self.TargetCloneMapID) end end end -- 查找所有组件 function UIBossInfoTips:FindAllComponents() local _myTrans = self.Trans; self.CloseBtn = UIUtils.FindBtn(_myTrans, "Container/Back/CloseBtn") self.GoBtn = UIUtils.FindBtn(_myTrans, "Container/Back/GoBtn") self.HeadIconSpr = UIUtils.FindSpr(_myTrans, "Container/Back/HeadIcon") self.NameLab = UIUtils.FindLabel(_myTrans, "Container/Back/Name") self.LevelLab = UIUtils.FindLabel(_myTrans, "Container/Back/Level") self.AnimModule = UIAnimationModule(self.Trans); self.AnimModule:AddAlphaScaleAnimation(self.Trans, 0, 1, 1, 0, 1, 1); end function UIBossInfoTips:SetAllInfo() local _monsterId = 0 if self.BossType == BossType.CrossFuDi then _monsterId = self.CustomCfgID else _monsterId = self.MonsterCfgID end local _monsterCfg = DataConfig.DataMonster[_monsterId] if _monsterCfg then if self.BossType == BossType.FuDiBoss then local gbCfg = DataConfig.DataGuildBattleBoss[self.CustomCfgID] if gbCfg ~= nil then UIUtils.SetTextByStringDefinesID(self.NameLab, gbCfg._Name) end elseif self.BossType == BossType.TianXuWar then UIUtils.SetTextByStringDefinesID(self.NameLab, _monsterCfg._Name) else -- UIUtils.SetTextByString(self.NameLab, Utils.GetMonsterName(_monsterCfg)) UIUtils.SetTextByStringDefinesID(self.NameLab, _monsterCfg._Name) end local _lv = _monsterCfg.Level if _lv == 0 then _lv = GameCenter.OfflineOnHookSystem:GetCurWorldLevel() end UIUtils.SetTextByEnum(self.LevelLab, "LevelValue", tostring(_lv)) local _uiIconBase = UIUtils.RequireUIIconBase(self.HeadIconSpr.transform) if _uiIconBase then _uiIconBase:UpdateIcon(_monsterCfg.Icon) end end end function UIBossInfoTips:Update(dt) if self.StartCountDown then if self.CurTime > self.CloseTime then self.CurTime = 0 self.StartCountDown = false self:OnClickCloseBtn() else self.CurTime = self.CurTime + dt end end end return UIBossInfoTips;