miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/HomeLandEquipPopup.lua

334 lines
15 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
HomeLandEquipPopup = Inherit(BasePanel)
----- --家园装备升级 -----
local this = HomeLandEquipPopup
local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand)
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel)
local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask)
local EquipStrengthen = ConfigManager.GetConfig(ConfigName.EquipStrengthen)
local EquipRankUp = ConfigManager.GetConfig(ConfigName.EquipRankUp)
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local data=nil
local TEXT = {
[1] = {"武器","r_Equip_GuardianWeapon_0004","攻击"},
[2] = {"战甲","r_Equip_Coat_0005","护甲"},
[3] = {"头饰","r_Equip_HeadAccessory_0005","魔抗"},
[4] = {"战靴","r_equip_Shoes_0005","生命"},
}
local curSelectHero=nil
function this:InitComponent()
this.closeBtn=Util.GetGameObject(self.gameObject,"BG/BackBtn")
local gameObject=Util.GetGameObject(self.transform,"GeneralPopup_HomeLandEquip")
this.spLoader = SpriteLoader.New()
this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text")
this.titleText.text="摘星阁"
this.Btn1 = Util.GetGameObject(gameObject,"Btn1")
this.Btn1Text = Util.GetGameObject(gameObject,"Btn1/Text"):GetComponent("Text")
this.Btn2 = Util.GetGameObject(gameObject,"Btn2")
this.costCondition = Util.GetGameObject(gameObject,"Cost/Condition"):GetComponent("Text")
this.costIcon = Util.GetGameObject(gameObject,"Cost/Icon"):GetComponent("Image")
this.costNum = Util.GetGameObject(gameObject,"Cost/Num"):GetComponent("Text")
this.costIcon2 = Util.GetGameObject(gameObject,"Cost/Icon2"):GetComponent("Image")
this.costNum2 = Util.GetGameObject(gameObject,"Cost/Num2"):GetComponent("Text")
this.Cost = Util.GetGameObject(gameObject,"Cost")
this.Tips = Util.GetGameObject(gameObject,"Tips")
this.objList = {}
for i = 1, 4 do
this.objList[i] = {}
this.objList[i].Obj = Util.GetGameObject(gameObject,"Content/Grid/Pre ("..i..")")
this.objList[i].name = Util.GetGameObject(this.objList[i].Obj,"Name"):GetComponent("Text")
this.objList[i].level = Util.GetGameObject(this.objList[i].Obj,"Num"):GetComponent("Text")
this.objList[i].image = Util.GetGameObject(this.objList[i].Obj,"Icon"):GetComponent("Image")
this.objList[i].mask = Util.GetGameObject(this.objList[i].Obj,"Mask")
this.objList[i].select = Util.GetGameObject(this.objList[i].Obj,"Select")
end
this.Desc = Util.GetGameObject(gameObject,"Content/Desc"):GetComponent("Text")
this.heroPre = Util.GetGameObject(this.gameObject, "Scroll/HeroPre")
this.scroll = Util.GetGameObject(gameObject, "Scroll")
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,
this.heroPre, this.scrollBar, Vector2.New(1010, 490), 1, 5, Vector2.New(20, 20))
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
this.heroSelect=Util.GetGameObject(this.scroll,"Select")
end
function this:BindEvent()
Util.AddClick(this.closeBtn,function()
self:ClosePanel()
end)
Util.AddClick(this.Btn1,function()
local curLv=curSelectHero.equipStrong[HomeLandManager.curEquip]
local data =ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen,"Level",curLv)
if HomeLandManager.BuildData[data.Limit[1]].level < data.Limit[2] then
PopupTipPanel.ShowTip(string.format("%s到达%s级可升级",HomeLandManager.BuildData[data.Limit[1]].dataMain.Name,data.Limit[2]))
return
end
for i = 1, #data.Cost do
if BagManager.GetTotalItemNum(data.Cost[i][1]) < data.Cost[i][2] then
--PopupTipPanel.ShowTip(string.format("%s不足",ItemConfig[data.Cost[i][1]].Name))
PopupTipPanel.ShowTip("材料不足")
return
end
end
NetManager.EquipIntensifyRequset(curSelectHero.dynamicId,HomeLandManager.curEquip,function ()
this:Refresh()
end)
end)
Util.AddClick(this.Btn2,function()
if HomeLandManager.GetAllCanUpgradeWithPopup(curSelectHero) then
this:Refresh()
return
end
NetManager.EquipIntensifyRequset(curSelectHero.dynamicId,0,function ()
this:Refresh()
end)
end)
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, this.SetData)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold, this.SetData)
end
function this:OnOpen()
local _roleDatas = HeroManager.GetAllHeroDatas()
curSelectHero=_roleDatas[1]
this.SetHeroList(_roleDatas)
this:Refresh()
end
function this:Refresh()
for i = 1, 4 do
local go = this.objList[i]
go.select:SetActive(i == HomeLandManager.curEquip)
go.name.text = TEXT[i][1].."加持"
go.level.text = curSelectHero.equipStrong[i]~=nil and curSelectHero.equipStrong[i] or 0
go.image.sprite = this.spLoader:LoadSprite(TEXT[i][2])
Util.AddOnceClick(go.mask,function ()
HomeLandManager.curEquip = i
this:Refresh()
end)
end
--显示加持属性
this:SetData()
end
function this:SetData()
-- LogPink(HomeLandManager.EquipData[HomeLandManager.curEquip].Id)
local curIndex = HomeLandManager.curEquip
local curLv=0
if curSelectHero.equipStrong[curIndex] then
curLv=curSelectHero.equipStrong[curIndex]
end
local equipStrengthenConfig=ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen,"Level",curLv)
local equipRankUpConfig=ConfigManager.GetConfigDataByKey(ConfigName.EquipRankUp,"Level",curSelectHero.equipAdvanceLv)
--设置消耗
local limit = equipStrengthenConfig.Limit
local cost = equipStrengthenConfig.Cost
local data = equipStrengthenConfig.Rate--当前装备加成
local proData = equipRankUpConfig.Rate--当前装备突破加成
if cost then--如果有下一级
local nextEquipStrengthenConfig=ConfigManager.GetConfigDataByKey(ConfigName.EquipStrengthen,"Level",curLv+1)
local nextData = nextEquipStrengthenConfig.Rate--下一装备加成
local nextProData = EquipRankUp[equipRankUpConfig.id + 1].Rate--下一装备突破加成
local num1 = data + proData[curIndex]
local num2 = 0
if not equipStrengthenConfig.Limit2==equipRankUpConfig.Level then--如果都到达了等级上限
num2 = data + nextProData[curIndex]
else
num2 = nextData + proData[curIndex]
end
this.Desc.text = string.format("神将佩戴的%s%s属性增加%s",TEXT[curIndex][1],TEXT[curIndex][3],num1/100).."%"..string.format("<color=#00FF00>%s",num2/100).."%</color>"
this.Btn1Text.text = "强 化"
Util.SetGray(this.Btn1,false)
this.Btn1:GetComponent("Button").enabled = true
if HomeLandManager.BuildData[limit[1]].level >= limit[2] then
this.costCondition.text = ""
this.costIcon.gameObject:SetActive(true)
this.costNum.gameObject:SetActive(true)
this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1]))
local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFEED6" or "red"
this.costNum.text = string.format("<color=%s>%s</color>",color2,cost[1][2])
LogError("cost len=="..#cost)
if #cost>1 then
this.costIcon2.gameObject:SetActive(true)
this.costNum2.gameObject:SetActive(true)
this.costIcon2.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[2][1]))
local color3 = BagManager.GetTotalItemNum(cost[2][1]) >= cost[2][2] and "#FFEED6" or "red"
this.costNum2.text = string.format("<color=%s>%s</color>",color3,cost[2][2])
else
this.costIcon2.gameObject:SetActive(false)
this.costNum2.gameObject:SetActive(false)
end
else
this.costIcon.gameObject:SetActive(false)
this.costNum.gameObject:SetActive(false)
this.costIcon2.gameObject:SetActive(false)
this.costNum2.gameObject:SetActive(false)
this.costCondition.text = string.format("<color=red>%s需要到达%s级</color>",HomeLand[limit[1]].Name,limit[2])
end
--按钮和tips显示
local bool = equipStrengthenConfig.Limit2==equipRankUpConfig.Level
-- LogBlue("bool:"..tostring(bool))
this.Btn1:SetActive(bool)
this.Btn2:SetActive(not bool)
--不同显示
this.Cost:SetActive(bool)
this.Tips:SetActive(not bool)
this.costCondition.gameObject:SetActive(true)
this.Tips:GetComponent("Text").text = string.format("全部加持到达%s级后方可进行突破",equipStrengthenConfig.Level)
if not bool and HomeLandManager.GetAllCanUpgrade(curSelectHero) then
this.Cost:SetActive(true)
this.Tips:SetActive(false)
this.costIcon.gameObject:SetActive(true)
this.costNum.gameObject:SetActive(true)
this.costCondition.gameObject:SetActive(false)
--突破的消耗和升级不同
local cost = equipRankUpConfig.Cost
local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFEED6" or "red"
this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1]))
this.costNum.text = string.format("<color=%s>%s</color>",color2,cost[1][2])
if cost[2] then
this.costIcon2.gameObject:SetActive(true)
this.costNum2.gameObject:SetActive(true)
this.costIcon2.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[2][1]))
local color3 = BagManager.GetTotalItemNum(cost[2][1]) >= cost[2][2] and "#FFEED6" or "red"
this.costNum2.text = string.format("<color=%s>%s</color>",color3,cost[2][2])
else
this.costIcon2.gameObject:SetActive(false)
this.costNum2.gameObject:SetActive(false)
end
end
else
this.Btn1:SetActive(true)
this.Btn2:SetActive(false)
this.Btn1Text.text = "已达上限"
Util.SetGray(this.Btn1,true)
this.Btn1:GetComponent("Button").enabled = false
local num1 = data + proData[curIndex]
this.Desc.text = string.format("神将佩戴的%s%s属性增加%s",TEXT[curIndex][1],TEXT[curIndex][3],num1).."%"
this.Cost:SetActive(false)
this.Tips:SetActive(false)
end
end
---设置显示英雄列表
function this.SetHeroList(_roleDatas)
this.scrollView:SetData(_roleDatas, function(index, go)
if index==1 then
this.SetHeroSelect(go)
end
-- 基础显示
this.SingleHeroDataShow(go, _roleDatas[index])
end, true,false)
end
--设置每条英雄数据
function this.SingleHeroDataShow(_go, _heroData)
local go=_go
local heroData=_heroData
local frame=Util.GetGameObject(go,"frame"):GetComponent("Image")
local icon=Util.GetGameObject(go, "icon"):GetComponent("Image")
local lv= Util.GetGameObject(go, "lv/Text"):GetComponent("Text")
local pro= Util.GetGameObject(go, "proIcon"):GetComponent("Image")
local pos= Util.GetGameObject(go, "posIcon"):GetComponent("Image")
local teamList={}
for i = 1, 3 do
table.insert(teamList,Util.GetGameObject(go, "yxteamName/Image"..i))
end
local yxInfo=Util.GetGameObject(go, "yxteamName")
--local yxTeamName=Util.GetGameObject(go, "yxteamName/Text"):GetComponent("Text")
yxInfo:SetActive(false)
Util.GetGameObject(go, "posIcon"):SetActive(this.curFormationIndex == FormationTypeDef.FIGHT_LEVEL or this.curFormationIndex == FormationTypeDef.FIGHT_ASSISTANTLEVEL or
this.curFormationIndex == FormationTypeDef.FORMATION_QIJIESHILIAN)
local starGrid = Util.GetGameObject(go, "star")
local yuanImage = Util.GetGameObject(go, "yuanImage")
yuanImage.gameObject:SetActive(false)
local choosedObj = Util.GetGameObject(go, "choosed")
choosedObj.gameObject:SetActive(false)
local hpExp = Util.GetGameObject(go, "hpExp")
hpExp.gameObject:SetActive(false)
local redPot = Util.GetGameObject(go, "redpoint")
local changeProBtn=Util.GetGameObject(go,"proMaskObj")
if heroData.isNew and heroData.isNew == 1 then
redPot.gameObject:SetActive(true)
else
redPot.gameObject:SetActive(false)
end
if _heroData.property then
changeProBtn:SetActive(_heroData.property>=5)
pro.sprite= this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.property))
else
changeProBtn:SetActive(false)
LogError("+++++++")
pro.sprite= this.spLoader:LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName))
end
frame.sprite=this.spLoader:LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star))
icon.sprite=this.spLoader:LoadSprite(heroData.icon)
if HarmonyManager.IsChangeColor(heroData.dynamicId) then
-- body
lv.text="<color=#0f0>"..heroData.lv.."</color>"
elseif HarmonyManager:IsEnvoy(heroData.dynamicId) and HarmonyManager:HongMengTowerUpLimit() >= HarmonyManager.TowerStartLimit then
-- bod
lv.text="<color=#ffbe22>"..heroData.lv.."</color>"
else
lv.text=heroData.lv
end
pos.sprite = this.spLoader:LoadSprite(heroData.professionIcon)
local star,starType = heroData.GetStar(1)
local starSize = Vector2.New(30,30)
local starScale = -8
if starType == 3 then
starSize = Vector2.New(1,-15.65)
starScale = -13
elseif starType == 2 then
starSize = Vector2.New(60,57)
end
SetHeroStars(this.spLoader, starGrid, star,starType,starSize,starScale)
Util.AddOnceClick(go, function()
curSelectHero=_heroData
this:SetData()
this.SetHeroSelect(go)
end)
end
function this.SetHeroSelect(_heroObj)
this.heroSelect.transform:SetParent(_heroObj.transform)
this.heroSelect.transform.localPosition=Vector3.zero
end
function this:OnClose()
HomeLandManager.curEquip = 1
data=nil
end
function this:OnDestroy()
this.SelectList = {}
this.spLoader:Destroy()
this.scrollView = nil
end
return this