require("Base/BasePanel") RoleLikeabilityPopup = Inherit(BasePanel) --全体生命 --白色 --特权--橙色 --总好感度属性: --黄色 --+500 --绿色 function RoleLikeabilityPopup:InitComponent() self.spLoader = SpriteLoader.New() self.btnBack = Util.GetGameObject(self.transform, "BackMask") self.icon = Util.GetGameObject(self.transform, "scroll/likeability/icon"):GetComponent("Image") self.lvText = Util.GetGameObject(self.icon.transform, "lv"):GetComponent("Text") self.progress = Util.GetGameObject(self.transform, "scroll/likeability/di/progress"):GetComponent("Image") self.progressText = Util.GetGameObject(self.transform, "scroll/likeability/progressText"):GetComponent("Text") self.pro = Util.GetGameObject(self.transform, "pro") self.proContent = Util.GetGameObject(self.pro, "content") self.fenge = Util.GetGameObject(self.pro, "fenge") self.proGrid = Util.GetGameObject(self.transform, "scroll/proScroll/proScrollGrid") self.proGrid2Pos = self.proGrid:GetComponent("RectTransform").anchoredPosition self.pos = Util.GetGameObject(self.transform, "scroll/pos") self.proList = {} self.back = Util.GetGameObject(self.transform, "BG/BackBtn") end function RoleLikeabilityPopup:BindEvent() Util.AddClick(self.btnBack, function() self:ClosePanel() end) Util.AddClick(self.back, function() self:ClosePanel() end) end --添加事件监听(用于子类重写) function RoleLikeabilityPopup:AddListener() end --移除事件监听(用于子类重写) function RoleLikeabilityPopup:RemoveListener() end function RoleLikeabilityPopup:OnSortingOrderChange() end function RoleLikeabilityPopup:OnOpen(curheroData) self.curheroData = curheroData if not self.itemview then self.itemview = SubUIManager.Open(SubUIConfig.ItemView,self.pos.transform) end self.itemview.gameObject:SetActive(true) self.itemview:OnOpen(false,{curheroData.Id,0},1.1,true,false,false,self.sortingOrder) end function RoleLikeabilityPopup:OnShow() self:UpdateTopLayoutPanel() end function RoleLikeabilityPopup:UpdateTopLayoutPanel() local num,lv,totalNum = LikabilityManager.GetTotalHeroLikeLv(self.curheroData.Id) self.lvText.text = lv if LikabilityManager.CheckIsMaxLv(self.curheroData.Id) then self.progressText.text = "好感度最佳" self.progress.fillAmount = 1 else self.progressText.text = string.format("%s/%s",num,totalNum) self.progress.fillAmount = num/totalNum end self:UpDataProList(lv) end function RoleLikeabilityPopup:UpDataProList(lv) local pro2 = LikabilityManager.GetViewProData(self.curheroData.Id,lv,lv,"","好感度%s级(%s/%s)",""..self.curheroData.ReadingName.." %s %s","",nil,true) for i = 1,#self.proList do self.proList[i].go.gameObject:SetActive(false) end self:UpDataProSingleList(pro2,1,lv) end function RoleLikeabilityPopup:UpDataProSingleList(data,index,lv) if not self.proList[index] then self.proList[index] = {} self.proList[index].go = newObjToParent(self.pro,self.proGrid) end self.proList[index].go.gameObject:SetActive(true) self.proList[index].title = Util.GetGameObject(self.proList[index].go, "title"):GetComponent("Text") if data.content == "" then self.proList[index].title.gameObject:SetActive(false) else self.proList[index].title.gameObject:SetActive(true) self.proList[index].title.text = data.content end 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.fenge,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) * 3 end else self.proList[index][i].fenge.gameObject:SetActive(false) end end end if curIndex ~= 0 then local pos = self.proGrid:GetComponent("RectTransform").anchoredPosition pos.y = self.proGrid2Pos.y + 41 + curIndex*35 + (lv - 1)*11 self.proGrid:GetComponent("RectTransform").anchoredPosition = pos end end function RoleLikeabilityPopup:OnClose() end --界面销毁时调用(用于子类重写) function RoleLikeabilityPopup:OnDestroy() self.spLoader:Destroy() self.proList = {} SubUIManager.Close(self.itemview) self.itemview = nil self.proGrid:GetComponent("RectTransform").anchoredPosition = self.proGrid2Pos end return RoleLikeabilityPopup