miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View2/GeneralInfoPopup_HomeLandUp...

141 lines
5.8 KiB
Lua
Raw Normal View History

2021-12-24 18:20:18 +08:00
----- --家园建筑升级 -----
local this = {}
local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand)
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel)
local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask)
local costOneSec = ConfigManager.GetConfigData(ConfigName.SpecialConfig,100).Value
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local data=nil
2021-12-28 11:54:08 +08:00
local OPENTEXT = {
[1] = "祈福斋",
[2] = "望月居、摘星阁",
}
2021-12-24 18:20:18 +08:00
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
--当前两个名字
this.curName = Util.GetGameObject(gameObject,"Buildings/curName"):GetComponent("Text")
this.nextName = Util.GetGameObject(gameObject,"Buildings/nextName"):GetComponent("Text")
2021-12-28 11:54:08 +08:00
this.Content = Util.GetGameObject(gameObject,"Content")
this.Obtain = Util.GetGameObject(this.Content,"Obtain")
this.Cost = Util.GetGameObject(this.Content,"Cost")
2021-12-24 18:20:18 +08:00
--Obtain
2021-12-28 11:54:08 +08:00
this.limitIcon = Util.GetGameObject(this.Obtain,"limit/Icon"):GetComponent("Image")
this.limitNum = Util.GetGameObject(this.Obtain,"limit/Num"):GetComponent("Text")
this.limitAdd = Util.GetGameObject(this.Obtain,"limit/Add"):GetComponent("Text")
this.gainIcon = Util.GetGameObject(this.Obtain,"gain/Icon"):GetComponent("Image")
this.gainNum = Util.GetGameObject(this.Obtain,"gain/Num"):GetComponent("Text")
this.gainAdd = Util.GetGameObject(this.Obtain,"gain/Add"):GetComponent("Text")
--Open
this.Open = Util.GetGameObject(this.Content,"Open")
this.OpenText = Util.GetGameObject(this.Open,"Num"):GetComponent("Text")
2021-12-24 18:20:18 +08:00
--cost
2021-12-28 11:54:08 +08:00
this.cost1Icon1 = Util.GetGameObject(this.Cost,"cost1/Icon"):GetComponent("Image")
this.cost1Num1 = Util.GetGameObject(this.Cost,"cost1/Num"):GetComponent("Text")
this.cost2Name = Util.GetGameObject(this.Cost,"cost2/Text"):GetComponent("Text")
this.cost2Num = Util.GetGameObject(this.Cost,"cost2/Num"):GetComponent("Text")
2021-12-24 18:20:18 +08:00
--fastDone
2021-12-31 16:30:53 +08:00
this.fastDoneMoney = Util.GetGameObject(gameObject,"Btns/fastDone/Money")
2021-12-28 11:54:08 +08:00
this.fastDoneIcon = Util.GetGameObject(this.fastDoneMoney,"Icon"):GetComponent("Image")
this.fastDoneNum = Util.GetGameObject(this.fastDoneMoney,"Num"):GetComponent("Text")
2021-12-31 16:30:53 +08:00
this.fastDoneBtn = Util.GetGameObject(gameObject,"Btns/fastDone/BtnDo")
2021-12-24 18:20:18 +08:00
--Done
2021-12-31 16:30:53 +08:00
this.doneNum = Util.GetGameObject(gameObject,"Btns/Done/Money/Text"):GetComponent("Text")
this.doneBtn = Util.GetGameObject(gameObject,"Btns/Done/BtnDo")
2021-12-24 18:20:18 +08:00
end
function this:BindEvent()
Util.AddClick(this.fastDoneBtn, function()
-- local priviId = PrivilegeManager.GetPrivilegeRemainValue()
2021-12-28 18:27:31 +08:00
HomeLandManager.ResumeCost(data.dataSingle,string.split(costOneSec,"#"),function (num)
MsgPanel.ShowTwo(string.format("是否花费%s妖晶立即升级",num),function() end,function()
NetManager.ArchitectureOperateRequest({data.dataMain.Id},2,0,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.UI.OnUpdateData)
parent:ClosePanel()
end)
end,"取消","确定")
2021-12-24 18:20:18 +08:00
end)
end)
Util.AddClick(this.doneBtn, function()
2021-12-28 11:54:08 +08:00
HomeLandManager.ResumeCost(data.dataSingle,nil,function ()
NetManager.ArchitectureOperateRequest({data.dataMain.Id},1,0,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.UI.OnUpdateData)
parent:ClosePanel()
end)
2021-12-24 18:20:18 +08:00
end)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,_args)
2021-12-31 16:30:53 +08:00
data = _args
2021-12-24 18:20:18 +08:00
parent=_parent
sortingOrder =_parent.sortingOrder
2021-12-31 16:30:53 +08:00
-- parent.contents:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_tanchuangdi_01")
2021-12-24 18:20:18 +08:00
local curData = data.dataSingle
local nextData = HomeLandLevel[curData.Id + 1]
local str = string.split(costOneSec,"#")
this.curName.text = string.format("%s %s级",data.dataMain.Name,curData.level)
this.nextName.text = string.format("%s级",nextData.level)
2021-12-28 11:54:08 +08:00
this.Obtain:SetActive(false)
if curData.Storage then
this.Obtain:SetActive(true)
this.limitIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(curData.Storage[1][1]))
this.limitNum.text = curData.Storage[1][2]
this.limitAdd.text = string.format(" +%s",nextData.Storage[1][2] - curData.Storage[1][2])
this.gainIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(curData.Gain[1]))
this.gainNum.text = curData.Gain[2]
this.gainAdd.text = string.format(" +%s",nextData.Gain[2] - curData.Gain[2])
end
2021-12-24 18:20:18 +08:00
2021-12-28 11:54:08 +08:00
this.Open:SetActive(false)
if OPENTEXT[data.level] and curData.PoolID == 5 then
this.Open:SetActive(true)
this.OpenText.text = OPENTEXT[data.level]
end
2021-12-24 18:20:18 +08:00
2021-12-28 11:54:08 +08:00
this.Cost:SetActive(false)
if curData.Cost then
this.Cost:SetActive(true)
this.cost1Icon1.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(curData.Cost[1][1]))
2021-12-31 16:30:53 +08:00
local color1 = BagManager.GetTotalItemNum(curData.Cost[1][1]) >= curData.Cost[1][2] and "#FFEED6" or "red"
2021-12-28 11:54:08 +08:00
this.cost1Num1.text = string.format("<color=%s>%s</color>",color1,curData.Cost[1][2])
end
if curData.Rule then
this.cost2Name.text = HomeLand[curData.Rule[1]].Name
this.cost2Num.text = string.format("%s级",curData.Rule[2])
else
this.cost2Name.text = ""
this.cost2Num.text = ""
end
2021-12-24 18:20:18 +08:00
this.fastDoneIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(tonumber(str[2])))
this.fastDoneNum.text = math.ceil(curData.Time/tonumber(str[1]))*tonumber(str[3])
this.doneNum.text = string.format("耗时:%s",TimeToMS(curData.Time))
end
function this:OnClose()
data=nil
2021-12-31 16:30:53 +08:00
-- parent.contents:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_tanchuangdi")
2021-12-24 18:20:18 +08:00
end
function this:OnDestroy()
this.spLoader:Destroy()
end
return this