264 lines
12 KiB
Lua
264 lines
12 KiB
Lua
require("Base/BasePanel")
|
|
LikeAbilityPanel = Inherit(BasePanel)
|
|
--<size=32><color=#fdf5e5>全体生命</color></size> --白色
|
|
--<size=32><color=#fc902c>特权</color></size>--橙色
|
|
--<size=32><color=#fed97f>总好感度属性:</color></size> --黄色
|
|
--<color=#00FF00>+500</color></size> --绿色
|
|
local pos = {
|
|
["h_haogandu_1"] = {mask = Vector3.New(-2.78,-0.75,0),icon = Vector3.New(-3.4,-7.19,0),index = 1} ,
|
|
["h_haogandu_2"] = {mask = Vector3.New(4.26,-1.12,0),icon = Vector3.New(4.47,-5.81,0),index = 2} ,
|
|
["h_haogandu_3"] = {mask = Vector3.New(-16.15,0,0),icon = Vector3.New(-15.2,-5.05,0),index = 3} ,
|
|
}
|
|
local sortOrder = 0
|
|
local tabs = {}
|
|
local tabsImg = {"z_icon_01_zh", "r_hero_huo 1_zh", "r_hero_feng 1_zh", "r_hero_shui 1_zh", "r_hero_dadi 1_zh","z_icon_qingjinbao"}
|
|
local proId = 0
|
|
local heroData = {}
|
|
function LikeAbilityPanel:InitComponent()
|
|
self.spLoader = SpriteLoader.New()
|
|
self.help = Util.GetGameObject(self.transform, "help")
|
|
self.helpPos = self.help:GetComponent("RectTransform").localPosition
|
|
self.btnBack = Util.GetGameObject(self.transform, "btnBack")
|
|
self.heroGrid = Util.GetGameObject(self.transform, "heroScroll")
|
|
self.heroPre = Util.GetGameObject(self.transform, "heroPre")
|
|
local v = self.heroGrid:GetComponent("RectTransform").rect
|
|
self.heroScroll = SubUIManager.Open(SubUIConfig.ScrollCycleView,self.heroGrid.transform,self.heroPre, nil, Vector2.New(v.width, v.height), 1, 4, Vector2.New(50,50))
|
|
self.btnPrant = Util.GetGameObject(self.gameObject, "Tabs")
|
|
for i = 0, 5 do
|
|
tabs[i] = Util.GetGameObject(self.btnPrant,"grid/Btn" .. i)
|
|
if tabsImg[i + 1] then
|
|
Util.GetGameObject(tabs[i], "Image"):GetComponent("Image").sprite = self.spLoader:LoadSprite(tabsImg[i + 1])
|
|
end
|
|
end
|
|
self.selectBtn = Util.GetGameObject(self.btnPrant, "selectBtn")
|
|
|
|
self.likeabilityBtn = Util.GetGameObject(self.gameObject, "likeabilityBtn")
|
|
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, "di/pro")
|
|
self.proContent = Util.GetGameObject(self.pro, "content")
|
|
self.proGrid = Util.GetGameObject(self.transform, "di/proScroll")
|
|
self.proList = {}
|
|
|
|
self.noneGo = Util.GetGameObject(self.transform, "NoneImage")
|
|
|
|
self.effect1 = Util.GetGameObject(self.likeabilityDi.transform, "fx_haogandu-dengji01")
|
|
self.effect2 = Util.GetGameObject(self.likeabilityDi.transform, "fx_haogandu-dengji02")
|
|
self.effect3 = Util.GetGameObject(self.likeabilityDi.transform, "fx_haogandu-dengji03")
|
|
self.effect1.gameObject:SetActive(false)
|
|
self.effect2.gameObject:SetActive(false)
|
|
self.effect3.gameObject:SetActive(false)
|
|
|
|
--逍遥游入口
|
|
self.btnXiaoYao=Util.GetGameObject(self.gameObject,"xiaoyaoBtn")
|
|
self.btnXiaoYaoLock=Util.GetGameObject(self.btnXiaoYao,"lock")
|
|
self.btnXiaoYaoIcon=Util.GetGameObject(self.btnXiaoYao,"Image")
|
|
self.btnXiaoYaoIcon:GetComponent("Image").sprite=self.spLoader:LoadSprite("x_xiaoyaoyou_daanniu_zh")
|
|
self.xiaoyaoRedPoint=Util.GetGameObject(self.btnXiaoYao,"redPoint")
|
|
self.btnXiaoYaoTextPar = Util.GetGameObject(self.btnXiaoYao,"curValue")
|
|
self.btnXiaoYaoText = Util.GetGameObject(self.btnXiaoYao,"curValue/num"):GetComponent("Text")
|
|
end
|
|
|
|
function LikeAbilityPanel:BindEvent()
|
|
for i = 0, 5 do
|
|
Util.AddClick(tabs[i], function()
|
|
if i == proId then
|
|
proId = ProIdConst.All
|
|
else
|
|
proId = i
|
|
end
|
|
heroData = LikabilityManager.GetCurSortHeroListData(proId)
|
|
self:SetSelectBtn()
|
|
self:UpdataHeroDataPanel()
|
|
end)
|
|
end
|
|
Util.AddClick(self.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.help, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Likeability,self.helpPos.x, self.helpPos.y)
|
|
end)
|
|
Util.AddClick(self.likeabilityBtn, function()
|
|
UIManager.OpenPanel(UIName.LikeabilityPopup)
|
|
end)
|
|
--逍遥游
|
|
Util.AddClick(self.btnXiaoYao,function()
|
|
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.XiaoYaoYou) then
|
|
XiaoYaoManager.OpenMapList()
|
|
else
|
|
local tip = ActTimeCtrlManager.GetFuncTip(FUNCTION_OPEN_TYPE.XiaoYaoYou)
|
|
PopupTipPanel.ShowTip(tip)
|
|
end
|
|
end)
|
|
BindRedPointObject(RedPointType.XiaoYaoYouRedPoint, self.xiaoyaoRedPoint)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function LikeAbilityPanel:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function LikeAbilityPanel:RemoveListener()
|
|
|
|
end
|
|
|
|
function LikeAbilityPanel:OnSortingOrderChange()
|
|
Util.SetParticleSortLayer(self.effect1,self.sortingOrder + 1)
|
|
Util.SetParticleSortLayer(self.effect2,self.sortingOrder + 1)
|
|
Util.SetParticleSortLayer(self.effect3,self.sortingOrder + 1)
|
|
end
|
|
|
|
function LikeAbilityPanel:OnOpen(_proId)
|
|
if _proId then
|
|
proId = _proId
|
|
else
|
|
proId = 0
|
|
end
|
|
end
|
|
|
|
function LikeAbilityPanel:OnShow()
|
|
heroData = LikabilityManager.GetCurSortHeroListData(proId)
|
|
self:SetSelectBtn()
|
|
self:UpdataHeroDataPanel()
|
|
self:UpdateTopLayoutPanel()
|
|
Util.SetParticleSortLayer(self.effect1,self.sortingOrder + 1)
|
|
Util.SetParticleSortLayer(self.effect2,self.sortingOrder + 1)
|
|
Util.SetParticleSortLayer(self.effect3,self.sortingOrder + 1)
|
|
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.XiaoYaoYou) then
|
|
Util.SetGray(self.btnXiaoYaoIcon.gameObject,true)
|
|
self.btnXiaoYaoTextPar.gameObject:SetActive(false)
|
|
self.btnXiaoYaoLock.gameObject:SetActive(true)
|
|
else
|
|
Util.SetGray(self.btnXiaoYaoIcon.gameObject,false)
|
|
self.btnXiaoYaoTextPar.gameObject:SetActive(true)
|
|
self.btnXiaoYaoLock.gameObject:SetActive(false)
|
|
end
|
|
self.btnXiaoYaoText.text=string.format("%d/%d",BagManager.GetItemCountById(UpViewRechargeType.YunYouVle),PrivilegeManager.GetPrivilegeNumber(39))
|
|
CheckRedPointStatus(RedPointType.XiaoYaoYouRedPoint)
|
|
end
|
|
|
|
function LikeAbilityPanel: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.effect1.gameObject:SetActive(false)
|
|
self.effect2.gameObject:SetActive(false)
|
|
self.effect3.gameObject:SetActive(false)
|
|
if pos[config.Bg].index == 1 then
|
|
self.effect1.gameObject:SetActive(true)
|
|
elseif pos[config.Bg].index == 2 then
|
|
self.effect2.gameObject:SetActive(true)
|
|
else
|
|
self.effect3.gameObject:SetActive(true)
|
|
end
|
|
self.lv.text = lv
|
|
if LikabilityManager.CheckIsMaxLv(-1) then
|
|
self.likeabilitymask.fillAmount = 1
|
|
self.progress.text = "好感度最佳"
|
|
else
|
|
self.likeabilitymask.fillAmount = num/totalNum
|
|
self.progress.text = string.format("%s/%s",num,totalNum)
|
|
end
|
|
self:UpDataProList(lv)
|
|
end
|
|
|
|
function LikeAbilityPanel:UpDataProList(lv)
|
|
-- local pro1 = LikabilityManager.GetViewProData(1,-1,lv,"<color=#fed97f>总好感度属性:</color>","","<color=#%s><color=#fdf5e5>全体%s 全体%s</color></color>","<color=#%s><color=#fc902c>特权:</color>%s</color>",nil)
|
|
-- local pro2 = LikabilityManager.GetViewProData(1,lv,lv,"<color=#fed97f>当前等级加成:</color>","","<color=#%s><color=#fc902c>属性:</color>%s %s</color>","<color=#%s><color=#fc902c>特权:</color>%s</color>",nil)
|
|
local pro1 = LikabilityManager.GetViewProData(1,-1,lv,"<color=#fed97f>好感度属性总加成:</color>","","<color=#%s><color=#fdf5e5>全体%s 全体%s \n全体%s 全体%s</color></color>","",nil)
|
|
local pro2 = LikabilityManager.GetViewProData(1,-1,lv,"<color=#fed97f>好感度特权总加成:</color>","","","<color=#%s>%s</color>",nil)
|
|
for i = 1,#self.proList do
|
|
self.proList[i].go.gameObject:SetActive(false)
|
|
end
|
|
self:UpDataProSingleList(pro1,1)
|
|
--self:UpDataProSingleList(pro2,2)
|
|
end
|
|
|
|
function LikeAbilityPanel:UpDataProSingleList(data,index)
|
|
if not self.proList[index] then
|
|
self.proList[index] = {}
|
|
self.proList[index].go = newObjToParent(self.pro,self.proGrid)
|
|
self.proList[index].title = Util.GetGameObject(self.proList[index].go, "title"):GetComponent("Text")
|
|
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
|
|
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].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
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function LikeAbilityPanel:UpdataHeroDataPanel()
|
|
if not heroData or #heroData < 1 then
|
|
self.noneGo.gameObject:SetActive(true)
|
|
self.heroScroll.gameObject:SetActive(false)
|
|
else
|
|
self.noneGo.gameObject:SetActive(false)
|
|
self.heroScroll.gameObject:SetActive(true)
|
|
end
|
|
self.heroScroll:ForeachItemGO(function(index,go)
|
|
go.gameObject:SetActive(false)
|
|
end)
|
|
self.heroScroll:SetData(heroData, function (index, go)
|
|
self:SingleHeroDataShow(go, heroData[index])
|
|
end)
|
|
end
|
|
|
|
function LikeAbilityPanel:SingleHeroDataShow(_go,data)
|
|
local card = Util.GetGameObject(_go.transform, "card")
|
|
local bg = Util.GetGameObject(card, "bg")
|
|
local icon = Util.GetGameObject(card, "icon"):GetComponent("Image")
|
|
icon.sprite = self.spLoader:LoadSprite(GetResourcePath(data.Painting))
|
|
--SetHEeroLiveToward(icon.gameObject,data.Toward)
|
|
SetHeroBg(self.spLoader,card ,bg ,data.Star,data.Quality)
|
|
local pro = Util.GetGameObject(_go.transform, "card/pro/Image"):GetComponent("Image")
|
|
pro.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(data.PropertyName))
|
|
local choose = Util.GetGameObject(card, "choosed")
|
|
choose.gameObject:SetActive(false)
|
|
local num,lv,totalNum = LikabilityManager.GetTotalHeroLikeLv(data.Id)
|
|
local level = Util.GetGameObject(card, "likeability/lv"):GetComponent("Text")
|
|
level.text = lv
|
|
Util.AddOnceClick(card, function()
|
|
UIManager.OpenPanel(UIName.HeroLikeAbilityPanel,data)
|
|
end)
|
|
end
|
|
|
|
function LikeAbilityPanel:SetSelectBtn()
|
|
self.selectBtn.transform:SetParent(tabs[proId].transform)
|
|
self.selectBtn:GetComponent("RectTransform").localPosition = Vector3.zero
|
|
end
|
|
|
|
function LikeAbilityPanel:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function LikeAbilityPanel:OnDestroy()
|
|
self.spLoader:Destroy()
|
|
self.proList = {}
|
|
tabs = {}
|
|
ClearRedPointObject(RedPointType.XiaoYaoYouRedPoint, self.xiaoyaoRedPoint)
|
|
end
|
|
return LikeAbilityPanel |