local TipsManager = class("TipsManager", BaseModule) TipsManager.ALIGN_TYPE = { ADAPTIVE = 0, CENTER = 1, TOP_LEFT = 2, TOP_CENTER = 3, TOP_RIGHT = 4, BOTTOM_LEFT = 5, BOTTOM_CENTER = 6, BOTTOM_RIGHT = 7, LEFT_TOP = 8, LEFT_CENTER =9, LEFT_BOTTOM = 10, RIGHT_TOP = 11, RIGHT_CENTER = 12, RIGHT_BOTTOM = 13 } function TipsManager:showHelpTips(params) params = params or {} UIManager:showUI("app/ui/tips/help_tips", params) end function TipsManager:showRewardTips(id, type, tarPrefabObj, alignType, params) if type == GConst.REWARD_TYPE.ITEM then self:showItemTips(id, tarPrefabObj, alignType) elseif type == GConst.REWARD_TYPE.EQUIP then self:showEquipTips(nil, id, params) elseif type == GConst.REWARD_TYPE.LEGACY then self:showLegacyTips(id) end end function TipsManager:showRewardsBox(params) UIManager:showUI("app/ui/tips/reward_box", params) end function TipsManager:showItemTips(id, tarPrefabObj, alignType) local params = { id = id, aniType = UIManager.ANI_TYPE.NONE, } if tarPrefabObj then alignType = alignType or TipsManager.ALIGN_TYPE.TOP_CENTER local tarCornerScreenPos, location = self:getCornerScreenPosition(tarPrefabObj, alignType) params.tarCornerScreenPos = tarCornerScreenPos params.location = location end UIManager:showUI("app/ui/tips/item_tips", params) end function TipsManager:showRewardsTips(rewards, customTitleStr, tarPrefabObj, alignType) local params = { rewards = rewards, customTitleStr = customTitleStr, aniType = UIManager.ANI_TYPE.NONE, } if tarPrefabObj then alignType = alignType or TipsManager.ALIGN_TYPE.TOP_CENTER local tarCornerScreenPos, location = self:getCornerScreenPosition(tarPrefabObj, alignType) params.tarCornerScreenPos = tarCornerScreenPos params.location = location end UIManager:showUI("app/ui/tips/rewards_tips", params) end ---- entity id 传入一个即可 function TipsManager:showEquipTips(entity, id, params) local params = { entity = entity, id = id, aniType = UIManager.ANI_TYPE.NONE, purifyLv = params and params.purifyLv } UIManager:showUI("app/ui/tips/equip_tips", params) end function TipsManager:showDescTips(desc, tarPrefabObj, alignType) local params = { desc = desc, aniType = UIManager.ANI_TYPE.NONE, } if tarPrefabObj then alignType = alignType or TipsManager.ALIGN_TYPE.TOP_CENTER local tarCornerScreenPos, location = self:getCornerScreenPosition(tarPrefabObj, alignType) params.tarCornerScreenPos = tarCornerScreenPos params.location = location end UIManager:showUI("app/ui/tips/desc_tips", params) end function TipsManager:getCornerScreenPosition(tarPrefabObj, alignType) local uiCamera = UIManager:getUICameraComponent() local rectTransform = tarPrefabObj:getComponent(GConst.TYPEOF_UNITY_CLASS.RECTTRANSFORM) local pivot = rectTransform.pivot local rect = rectTransform.rect local isTop local isRight local isCenter = false local screenPoint local location if alignType == TipsManager.ALIGN_TYPE.ADAPTIVE then local screenWidth, screenHeight = GFunc.getScreenSize() local tarMid = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), rect.height*(0.5 - pivot.y), 0)) local tarSp = uiCamera:WorldToScreenPoint(tarMid) if tarSp.x < screenWidth*0.45 then isRight = false elseif tarSp.x > screenWidth*0.55 then isRight = true else isCenter = true end if tarSp.y < screenHeight * 0.6 then isTop = true else isTop = false end if isTop then if isCenter then location = TipsManager.ALIGN_TYPE.TOP_CENTER else if isRight then location = TipsManager.ALIGN_TYPE.TOP_RIGHT else location = TipsManager.ALIGN_TYPE.TOP_LEFT end end local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), rect.height*(1 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) else if isCenter then location = TipsManager.ALIGN_TYPE.BOTTOM_CENTER else if isRight then location = TipsManager.ALIGN_TYPE.BOTTOM_RIGHT else location = TipsManager.ALIGN_TYPE.BOTTOM_LEFT end end local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), -rect.height*pivot.y, 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) end else location = alignType if alignType == TipsManager.ALIGN_TYPE.TOP_LEFT then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), rect.height*(1 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.TOP_CENTER then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), rect.height*(1 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.TOP_RIGHT then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), rect.height*(1 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.BOTTOM_LEFT then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), -rect.height*pivot.y, 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.BOTTOM_CENTER then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), -rect.height*pivot.y, 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.BOTTOM_RIGHT then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(0.5 - pivot.x), -rect.height*pivot.y, 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.LEFT_BOTTOM then local tarCorner = rectTransform:TransformPoint(BF.Vector3(-rect.width*pivot.x, rect.height*(0.5 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.LEFT_CENTER then local tarCorner = rectTransform:TransformPoint(BF.Vector3(-rect.width*pivot.x, rect.height*(0.5 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.LEFT_TOP then local tarCorner = rectTransform:TransformPoint(BF.Vector3(-rect.width*pivot.x, rect.height*(0.5 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.RIGHT_TOP then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(1 - pivot.x), rect.height*(0.5 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.RIGHT_CENTER then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(1 - pivot.x), rect.height*(0.5 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) elseif alignType == TipsManager.ALIGN_TYPE.RIGHT_BOTTOM then local tarCorner = rectTransform:TransformPoint(BF.Vector3(rect.width*(1 - pivot.x), rect.height*(0.5 - pivot.y), 0)) screenPoint = uiCamera:WorldToScreenPoint(tarCorner) end end return BF.Vector2(screenPoint.x, screenPoint.y), location end return TipsManager