miduo_client/Assets/ManagedResources/~Lua/Modules/Likability/LikeabilityPopup.lua

135 lines
5.6 KiB
Lua
Raw Normal View History

2021-09-26 09:54:58 +08:00
require("Base/BasePanel")
LikeabilityPopup = Inherit(BasePanel)
--<size=32><color=#fdf5e5>全体生命</color></size> --白色
--<size=32><color=#fc902c>特权</color></size>--橙色
--<size=32><color=#fed97f>总好感度属性:</color></size> --黄色
--<color=#5dc446>+500</color></size> --绿色
2021-09-27 21:35:55 +08:00
local pos = {
["h_haogandu_1"] = {mask = Vector3.zero,icon = Vector3.New(-3.4,0,0)} ,
["h_haogandu_2"] = {mask = Vector3.zero,icon = Vector3.New(-3.4,0,0)} ,
["h_haogandu_3"] = {mask = Vector3.New(-16.15,0,0),icon = Vector3.New(-18.84,0,0)} ,
}
2021-09-26 09:54:58 +08:00
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
2021-09-27 21:35:55 +08:00
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")
2021-09-26 13:55:57 +08:00
self.pro = Util.GetGameObject(self.transform, "pro")
2021-09-26 09:54:58 +08:00
self.proContent = Util.GetGameObject(self.pro, "content")
2021-09-27 15:45:23 +08:00
self.proGrid1 = Util.GetGameObject(self.transform, "scroll/proScrollgrid1")
self.proGrid2 = Util.GetGameObject(self.transform, "scroll/proScroll/proScrollgrid2")
2021-09-26 09:54:58 +08:00
self.proList = {}
end
function LikeabilityPopup:BindEvent()
Util.AddClick(self.btnBack, 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)
2021-09-27 21:35:55 +08:00
self.likeabilitymask.transform.localPosition = pos[config.Bg].mask
self.icon.transform.localPosition = pos[config.Bg].icon
2021-09-26 09:54:58 +08:00
self.lv.text = lv
2021-09-26 20:23:08 +08:00
if LikabilityManager.CheckIsMaxLv(-1) then
2021-09-26 09:54:58 +08:00
self.progress.text = "好感度最佳"
self.likeabilitymask.fillAmount = 1
else
2021-09-26 20:23:08 +08:00
self.progress.text = string.format("<color=#5dc446>%s</color>/%s",num,totalNum)
2021-09-26 09:54:58 +08:00
self.likeabilitymask.fillAmount = num/totalNum
end
self:UpDataProList(lv)
2021-09-26 13:55:57 +08:00
end
2021-09-26 09:54:58 +08:00
function LikeabilityPopup:UpDataProList(lv)
2021-09-27 21:35:55 +08:00
local pro1 = LikabilityManager.GetViewProData(1,-1,lv,"<color=#fed97f> 总好感度属性:</color>",""," <color=#%s>全体%s\n 全体%s</color>","",lv + 1)
local pro2 = LikabilityManager.GetViewProData(1,lv,lv,"<color=#fed97f> 当前等级加成:</color>","<color=#%s>%s级</color>","<color=#%s>属性加成:%s %s</color>","<color=#%s>特权加成:%s</color>",nil,true)
2021-09-26 09:54:58 +08:00
for i = 1,#self.proList do
self.proList[i].go.gameObject:SetActive(false)
end
2021-09-27 15:45:23 +08:00
self:UpDataProSingleList(pro1,1,self.proGrid1)
self:UpDataProSingleList(pro2,2,self.proGrid2)
2021-09-26 09:54:58 +08:00
end
2021-09-27 15:45:23 +08:00
function LikeabilityPopup:UpDataProSingleList(data,index,parent)
2021-09-26 09:54:58 +08:00
if not self.proList[index] then
self.proList[index] = {}
2021-09-27 15:45:23 +08:00
self.proList[index].go = newObjToParent(self.pro,parent.transform)
2021-09-26 13:55:57 +08:00
self.proList[index].title = Util.GetGameObject(self.proList[index].go, "title"):GetComponent("Text")
self.proList[index].fenge = Util.GetGameObject(self.proList[index].go, "Image")
2021-09-27 21:35:55 +08:00
self.proList[index].fengePre = Util.GetGameObject(self.proList[index].go, "fenge")
2021-09-26 13:55:57 +08:00
if index == 1 then
self.proList[index].fenge.gameObject:SetActive(false)
else
self.proList[index].fenge.gameObject:SetActive(true)
end
2021-09-26 09:54:58 +08:00
end
self.proList[index].go.gameObject:SetActive(true)
self.proList[index].title.text = data.content
for i = 1,math.max(#self.proList[index],#data.prolist) do
2021-09-26 13:55:57 +08:00
if not data.prolist[i] then
2021-09-26 09:54:58 +08:00
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)
2021-09-27 21:35:55 +08:00
self.proList[index][i].fenge = newObjToParent(self.proList[index].fengePre,self.proList[index].go)
2021-09-26 09:54:58 +08:00
self.proList[index][i].goText = self.proList[index][i].go:GetComponent("Text")
end
2021-09-26 13:55:57 +08:00
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
2021-09-27 21:35:55 +08:00
LogGreen("i:"..i)
if i%3 == 0 then
self.proList[index][i].fenge.gameObject:SetActive(true)
else
self.proList[index][i].fenge.gameObject:SetActive(false)
end
2021-09-26 09:54:58 +08:00
end
end
end
function LikeabilityPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function LikeabilityPopup:OnDestroy()
self.spLoader:Destroy()
self.proList = {}
end
return LikeabilityPopup