require("Base/BasePanel") require("Modules/RoleInfo/RoleInfoPanel") SkillInfoPopup = Inherit(BasePanel) local this = SkillInfoPopup local nextCfg --初始化组件(用于子类重写) 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.skillTypeText=Util.GetGameObject(this.skillTypeImage.transform,"Text") this.icon = Util.GetGameObject(self.transform, "Content/IconBG/Icon"):GetComponent("Image") this.skillName = Util.GetGameObject(self.transform, "Content/Title/Text"):GetComponent("Text") this.desGrid = Util.GetGameObject(self.transform, "Content/desGrid") this.desList = {} for i = 1,2 do this.desList[i] = {} this.desList[i].go = Util.GetGameObject(this.desGrid, "des"..i) this.desList[i].des = Util.GetGameObject(this.desList[i].go, "Text"):GetComponent("Text") end this.hintTxt=Util.GetGameObject(self.transform,"Content/desGrid/Text"):GetComponent("Text") this.hintTxt2=Util.GetGameObject(self.transform,"Content/desGrid/Text2"):GetComponent("Text") this.line=Util.GetGameObject(self.transform,"Content/desGrid/line") 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] nextCfg=args[6] local soulLv=args[7] local isFaBao = args[8] 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,以获取妖灵师最高等级 this.skillTypeText.gameObject:SetActive(false) this.skillTypeImage.enabled = true -- 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.skillTypeImage.sprite=this.spLoader:LoadSprite(GetSkillType(curSkillData)) -- this.cureffect.transform:DOAnchorPosY(0,0,true) -- this.cureffect.text = GetCurrSkillConfigDesc(curSkillData.skillConfig,soulLv) for i = 1,#this.desList do this.desList[i].go.gameObject:SetActive(false) end this.desList[1].go.gameObject:SetActive(true) local des1 if isFaBao then des1 = GetCurrSkillConfigDesc(curSkillData.skillConfig,soulLv)..isFaBao else des1 = GetCurrSkillConfigDesc(curSkillData.skillConfig,soulLv) end if curSkillData.isOpen then if curSkillData.needStar==14 then --this.hintTxt.text=" ".."飞升3解锁" des1="".."飞升3解锁".."".."\n"..des1 else --this.hintTxt.text=" ".. des1=""..NumToSimplenessFont[curSkillData.needStar].."星解锁\n"..""..des1 end --des1="" end this.desList[1].des.text=des1 if nextCfg then this.desList[2].go.gameObject:SetActive(true) this.hintTxt2.gameObject:SetActive(false) this.line:SetActive(true) this.hintTxt2.text=" ".."11星解锁" this.desList[2].des.text = "觉醒后效果:\n"..GetCurrSkillConfigDesc(nextCfg.skillConfig,soulLv) else this.hintTxt2.gameObject:SetActive(false) this.line:SetActive(false) end if curSkillData.isOpen then --LogError("skillList[i].needStar=="..skillList[i].needStar) this.hintTxt.gameObject:SetActive(false) if curSkillData.needStar==14 then this.hintTxt.text=" ".."飞升3解锁" else this.hintTxt.text=" "..NumToSimplenessFont[curSkillData.needStar].."星解锁" end else this.hintTxt.gameObject:SetActive(false) 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