require("Base/BasePanel") LikeabilityPopup = Inherit(BasePanel) --全体生命 --白色 --特权--橙色 --总好感度属性: --黄色 --+500 --绿色 local pos = { ["h_haogandu_1"] = { mask = Vector3.New(-16.15, 0, 0), icon = Vector3.New(-3.4, -7.3, 0) }, ["h_haogandu_2"] = { mask = Vector3.New(3.93, -1.04, 0), icon = Vector3.New(4.49, -4.69, 0) }, ["h_haogandu_3"] = { mask = Vector3.New(-16.15, 0, 0), icon = Vector3.New(-15.5, -3.5, 0) }, } function LikeabilityPopup:InitComponent() self.spLoader = SpriteLoader.New() self.btnBack = Util.GetGameObject(self.transform, "BackMask") self.likeabilityBtn = Util.GetGameObject(self.gameObject, "scroll/likeability") self.likeabilityDi = Util.GetGameObject(self.likeabilityBtn, "di"):GetComponent("Image") --h_haogandu_1 h_haogandu_2 h_haogandu_3 self.likeabilitymask = Util.GetGameObject(self.likeabilityDi.transform, "mask"):GetComponent("Image") --self.likeabilitymask.fillAmount self.icon = Util.GetGameObject(self.likeabilityBtn, "icon") self.lv = Util.GetGameObject(self.likeabilityBtn, "icon/lv"):GetComponent("Text") self.progress = Util.GetGameObject(self.likeabilityBtn, "icon/progress"):GetComponent("Text") self.pro = Util.GetGameObject(self.transform, "pro") self.proContent = Util.GetGameObject(self.pro, "content") self.proGrid1 = Util.GetGameObject(self.transform, "scroll/proScrollgrid1") self.proGrid2 = Util.GetGameObject(self.transform, "scroll/proScroll/proScrollgrid2") self.proGrid2Pos = self.proGrid2:GetComponent("RectTransform").anchoredPosition self.proList = {} self.back = Util.GetGameObject(self.transform, "BG/BackBtn") end function LikeabilityPopup:BindEvent() Util.AddClick(self.btnBack, function() self:ClosePanel() end) Util.AddClick(self.back, function() self:ClosePanel() end) end --添加事件监听(用于子类重写) function LikeabilityPopup:AddListener() end --移除事件监听(用于子类重写) function LikeabilityPopup:RemoveListener() end function LikeabilityPopup:OnSortingOrderChange() end function LikeabilityPopup:OnOpen() end function LikeabilityPopup:OnShow() self:UpdateTopLayoutPanel() end function LikeabilityPopup:UpdateTopLayoutPanel() local num, lv, totalNum = LikabilityManager.GetTotalHeroLikeLv(-1) local config = ConfigManager.GetConfigDataByDoubleKey(ConfigName.LikeAbility, "Type", 1, "Level", lv) self.likeabilityDi.sprite = self.spLoader:LoadSprite(config.Bg) self.likeabilitymask.transform.localPosition = pos[config.Bg].mask self.icon.transform.localPosition = pos[config.Bg].icon self.lv.text = lv if LikabilityManager.CheckIsMaxLv(-1) then self.progress.text = Language[11670] self.likeabilitymask.fillAmount = 1 else self.progress.text = string.format("%s/%s", num, totalNum) self.likeabilitymask.fillAmount = num / totalNum end self:UpDataProList(lv) end function LikeabilityPopup:UpDataProList(lv) local pro1 = LikabilityManager.GetViewProData(1, -1, lv, Language[11680], "", Language[11681], "", lv + 1) --local pro2 = LikabilityManager.GetViewProData(1,lv,lv," 当前等级加成:","%s级","属性加成:%s %s","特权加成:%s",nil,true) for i = 1, #self.proList do self.proList[i].go.gameObject:SetActive(false) end self:UpDataProSingleList(pro1, 1, self.proGrid1) local skillData = {} skillData.title = Language[11682] local likeAbility = ConfigManager.GetConfigDataByKey(ConfigName.LikeAbility, "Level", lv) local skillArr = likeAbility.Skill local maxSkillArr = ConfigManager.GetConfigDataByKey(ConfigName.LikeAbility, "Level", 400).Skill skillData.content = "" for i = 1, #maxSkillArr do if skillArr ~= nil and i <= #skillArr then local passiveSkillConfig = ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig, maxSkillArr[i]) if skillData.content == "" then skillData.content = string.format("%s", passiveSkillConfig.Desc) else skillData.content = string.format("%s\n%s", skillData.content, passiveSkillConfig.Desc) end else local passiveSkillConfig = ConfigManager.GetConfigData(ConfigName.PassiveSkillConfig, maxSkillArr[i]) if skillData.content == "" then skillData.content = string.format("%s", passiveSkillConfig.Desc) else skillData.content = string.format("%s\n%s", skillData.content, passiveSkillConfig.Desc) end end end self:UpdateUnLockSkill(skillData, 2, self.proGrid2) end function LikeabilityPopup:UpDataProSingleList(data, index, parent, lv) if not self.proList[index] then self.proList[index] = {} self.proList[index].go = newObjToParent(self.pro, parent.transform) self.proList[index].title = Util.GetGameObject(self.proList[index].go, "title"):GetComponent("Text") self.proList[index].fenge = Util.GetGameObject(self.proList[index].go, "Image") self.proList[index].fengePre = Util.GetGameObject(self.proList[index].go, "fenge") end self.proList[index].go.gameObject:SetActive(true) self.proList[index].title.text = data.content local curIndex = 0 for i = 1, math.max(#self.proList[index], #data.prolist) do if not data.prolist[i] then self.proList[index][i].go.gameObject:SetActive(false) else if not self.proList[index][i] then self.proList[index][i] = {} self.proList[index][i].go = newObjToParent(self.proContent, self.proList[index].go) self.proList[index][i].fenge = newObjToParent(self.proList[index].fengePre, self.proList[index].go) self.proList[index][i].goText = self.proList[index][i].go:GetComponent("Text") end if data.prolist[i] == "" then self.proList[index][i].go.gameObject:SetActive(false) else self.proList[index][i].go.gameObject:SetActive(true) self.proList[index][i].goText.text = data.prolist[i] end if i % 3 == 0 then self.proList[index][i].fenge.gameObject:SetActive(true) if lv > math.ceil(i / 3) then curIndex = math.ceil(i / 3) * 4 end else self.proList[index][i].fenge.gameObject:SetActive(false) end end end if index == 1 then self.proList[index].fenge.gameObject:SetActive(false) else self.proList[index].fenge.gameObject:SetActive(true) if curIndex ~= 0 then local pos = self.proGrid2:GetComponent("RectTransform").anchoredPosition pos.y = self.proGrid2Pos.y + 41 + curIndex * 35 + (lv - 1) * 10 self.proGrid2:GetComponent("RectTransform").anchoredPosition = pos end end end function LikeabilityPopup:UpdateUnLockSkill(data, index, parent, lv) if not self.proList[index] then self.proList[index] = {} self.proList[index].go = newObjToParent(self.pro, parent.transform) self.proList[index].title = Util.GetGameObject(self.proList[index].go, "title"):GetComponent("Text") self.proList[index].content = Util.GetGameObject(self.proList[index].go, "content"):GetComponent("Text") self.proList[index].fenge = Util.GetGameObject(self.proList[index].go, "Image") self.proList[index].fengePre = Util.GetGameObject(self.proList[index].go, "fenge") end self.proList[index].go.gameObject:SetActive(true) self.proList[index].content.gameObject:SetActive(true) self.proList[index].title.text = data.title self.proList[index].content.text = data.content end function LikeabilityPopup:OnClose() end --界面销毁时调用(用于子类重写) function LikeabilityPopup:OnDestroy() self.spLoader:Destroy() self.proList = {} self.proGrid2:GetComponent("RectTransform").anchoredPosition = self.proGrid2Pos end return LikeabilityPopup