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

156 lines
6.4 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
require("Modules/RoleInfo/RoleInfoPanel")
SkillInfoPopup = Inherit(BasePanel)
local this = SkillInfoPopup
--初始化组件(用于子类重写)
function this:InitComponent()
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.skillLv = Util.GetGameObject(self.transform, "Content/IconBG/Level/Text"):GetComponent("Text")
this.skillName = Util.GetGameObject(self.transform, "Content/Title/Text"):GetComponent("Text")
-- this.desc = Util.GetGameObject(self.transform, "Content/Desc/Text"):GetComponent("Text")
this.cureffect = Util.GetGameObject(self.transform, "Content/CurrentLvDesc/Text"):GetComponent("Text")
-- this.skillNextObg = Util.GetGameObject(self.transform, "Content/NextLv")
-- this.skillNextObg:SetActive(false)
-- this.nextEffect = Util.GetGameObject(self.transform, "Content/NextLv/NextLvDesc/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(240.02, -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(220,panel.anchoredPosition.y-342),0)
end
this.icon.sprite = Util.LoadSprite(GetResourcePath(curSkillData.skillConfig.Icon))
--this.skillLv.text = curSkillData.skillConfig.Id % dividend --神奇的取等级
this.skillName.text = curSkillData.skillConfig.Name
--获取RoleInfoPanel的curUpStarData以获取妖灵师最高等级
if curSkillData.skillConfig.Type == SkillType.Pu then
this.skillTypeImage.sprite=Util.LoadSprite(SkillIconType[SkillType.Pu])--普技
elseif curSkillData.skillConfig.Type == SkillType.Jue then
this.skillTypeImage.sprite=Util.LoadSprite(SkillIconType[SkillType.Jue])--绝技
elseif curSkillData.skillConfig.Type == SkillType.Bei then
this.skillTypeImage.sprite=Util.LoadSprite(SkillIconType[SkillType.Bei])--被动技
end
local skillLogiData=ConfigManager.GetConfigData(ConfigName.SkillLogicConfig,curSkillData.skillConfig.Id)
local ShortDesc = curSkillData.skillConfig.ShortDesc or ""
-- local rateCasting=0
-- if skillLogiData.CD>0 then
-- rateCasting=skillLogiData.CD/1000
-- this.desc.text="施法率:"..rateCasting.."%".."\n".."最高等级<color=#DA9649><b>"..maxLv.."</b></color>".."\n"..ShortDesc
-- else
-- this.desc.text="最高等级<color=#DA9649><b>"..maxLv.."</b></color>".."\n"..ShortDesc
-- end
this.cureffect.transform:DOAnchorPosY(0,0,true)
--curSkillData.skillConfig.Id % dividend
2020-06-23 18:36:24 +08:00
this.cureffect.text = GetSkillConfigDesc(curSkillData.skillConfig)--Language[10470].."<color=#DA9649><b>".. 1 .."</b></color>\n"..
2020-05-09 13:31:21 +08:00
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
-- if nextCfg and nextCfg.Desc then
--this.skillNextObg:SetActive(true)
-- local nextLv=curSkillData.skillConfig.Id % dividend+1
-- if nextLv>5 then
-- nextLv=5
-- end
-- this.nextEffect.transform:DOAnchorPosY(0,0,true)
-- this.nextEffect.text ="等级".."<color=#DA9649><b>"..nextLv.."</b></color>\n"..GetSkillConfigDesc(nextCfg)
-- else
-- this.skillNextObg:SetActive(false)
-- end
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
end
function this.CheckPointer()
local update
update = function()
if Input.GetMouseButtonDown(0) then
local v2 = Input.mousePosition
2020-06-23 18:36:24 +08:00
Log(Language[11598]..v2.x.." "..v2.y)
2020-05-09 13:31:21 +08:00
this.value0,this.value1= RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rect,v2,UIManager.camera,nil)
2020-06-23 18:36:24 +08:00
Log(Language[11599]..this.value1.x.." "..this.value1.y)
Log(Language[11600]..this.rect.localPosition.x.." "..this.rect.localPosition.y)
Log(Language[11601]..this.curLvRect.sizeDelta.x.." "..this.curLvRect.sizeDelta.y)
2020-05-09 13:31:21 +08:00
if this.value1.x>this.curLvRect.sizeDelta.x and
this.value1.x<0-- and
--this.value1.y<this.curLvRect.localPosition.y and
--this.value1.y>this.curLvRect.localPosition.y
then
return
end
--if CheckLOrR(this.value)==0 then
-- return
--end
this.rect=nil
this:ClosePanel()
UpdateBeat:Remove(update, this)
end
end
UpdateBeat:Add(update, this)
end
2020-06-23 18:36:24 +08:00
return SkillInfoPopup;