miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/SkillInfoPopup.lua

126 lines
4.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
require("Modules/RoleInfo/RoleInfoPanel")
SkillInfoPopup = Inherit(BasePanel)
local this = SkillInfoPopup
--初始化组件(用于子类重写)
function this:InitComponent()
this.spLoader = SpriteLoader.New()
this.content = Util.GetGameObject(self.transform, "Content"):GetComponent("RectTransform")
this.backBtn = Util.GetGameObject(self.transform, "Button")
this.skillTypeImage=Util.GetGameObject(self.transform,"Content/SkillTypeImage"):GetComponent("Image")
this.icon = Util.GetGameObject(self.transform, "Content/IconBG/Icon"):GetComponent("Image")
this.skillName = Util.GetGameObject(self.transform, "Content/Title/Text"):GetComponent("Text")
this.cureffect = Util.GetGameObject(self.transform, "Content/CurrentLvDesc/Text"):GetComponent("Text")
this.rect=Util.GetGameObject(self.transform,"Content"):GetComponent("RectTransform")
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddClick(this.backBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function this:AddListener()
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
end
function this:OnShow()
end
--界面打开时调用(用于子类重写)
function this:OnOpen(...)
this.rect=Util.GetGameObject(GameObject.Find("SkillInfoPopup").transform,"Content"):GetComponent("RectTransform")
this.curLvRect=Util.GetGameObject(self.transform,"Content"):GetComponent("RectTransform")
local args = { ... }
local curSkillData = args[1]
local openType = args[2]
local dividend = args[3] and args[3] or 10
local maxLv=1--args[4]
local skilltype =args[5]
if openType == 1 then
this.content.anchoredPosition = Vector2.New(0, 0)
elseif openType == 2 then
this.content.anchoredPosition = Vector2.New(144, -281.98)
elseif openType == 3 then
this.content.anchoredPosition = Vector2.New(0, 135)
elseif openType == 4 then
local panel=Util.GetGameObject(GameObject.Find("RoleInfoPopup").transform,"Scroll View/Viewport/Content"):GetComponent("RectTransform")
this.content:DOAnchorPos(Vector3(144,panel.anchoredPosition.y-342),0)
end
if args[6] then--如果有手动设置则使用手动设置的位置
this.content.anchoredPosition = args[6]
end
this.icon.sprite = this.spLoader:LoadSprite(GetResourcePath(curSkillData.skillConfig.Icon))
this.skillName.text = GetLanguageStrById(curSkillData.skillConfig.Name)
--获取RoleInfoPanel的curUpStarData以获取妖灵师最高等级
if curSkillData.skillConfig.Type == SkillType.Pu then
this.skillTypeImage.sprite=this.spLoader:LoadSprite(SkillIconType[SkillType.Pu])--普技
elseif curSkillData.skillConfig.Type == SkillType.Jue then
this.skillTypeImage.sprite=this.spLoader:LoadSprite(SkillIconType[SkillType.Jue])--绝技
elseif curSkillData.skillConfig.Type == SkillType.Bei then
this.skillTypeImage.sprite=this.spLoader:LoadSprite(SkillIconType[SkillType.Bei])--被动技
end
this.cureffect.transform:DOAnchorPosY(0,0,true)
this.cureffect.text = GetSkillConfigDesc(curSkillData.skillConfig)
local nextCfg
if curSkillData.skillConfig.Type==SkillType.Pu then
nextCfg = ConfigManager.TryGetConfigData(ConfigName.SkillConfig, curSkillData.skillConfig.Id+1)
elseif curSkillData.skillConfig.Type==SkillType.Jue then
nextCfg = ConfigManager.TryGetConfigData(ConfigName.SkillConfig, curSkillData.skillConfig.Id+1)
elseif curSkillData.skillConfig.Type==SkillType.Bei then
nextCfg = ConfigManager.TryGetConfigData(ConfigName.PassiveSkillConfig, curSkillData.skillConfig.Id+1)
end
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
this.spLoader:Destroy()
end
function this.CheckPointer()
local update
update = function()
if Input.GetMouseButtonDown(0) then
local v2 = Input.mousePosition
Log("鼠标点击坐标"..v2.x.." "..v2.y)
this.value0,this.value1= RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rect,v2,UIManager.camera,nil)
Log("对应UI坐标"..this.value1.x.." "..this.value1.y)
Log("面板位置坐标"..this.rect.localPosition.x.." "..this.rect.localPosition.y)
Log("面板大小"..this.curLvRect.sizeDelta.x.." "..this.curLvRect.sizeDelta.y)
if this.value1.x>this.curLvRect.sizeDelta.x and
this.value1.x<0-- and
then
return
end
this.rect=nil
this:ClosePanel()
UpdateBeat:Remove(update, this)
end
end
UpdateBeat:Add(update, this)
end
return SkillInfoPopup