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

141 lines
5.9 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.

----- --家园建筑升级 -----
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
local OPENTEXT = {
[1] = "祈福斋",
[2] = "望月居、摘星阁",
}
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")
this.Content = Util.GetGameObject(gameObject,"Content")
this.Obtain = Util.GetGameObject(this.Content,"Obtain")
this.Cost = Util.GetGameObject(this.Content,"Cost")
--Obtain
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")
--cost
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")
this.cost2Num.text = ""
--fastDone
this.fastDoneMoney = Util.GetGameObject(gameObject,"Btns/fastDone/Money")
this.fastDoneIcon = Util.GetGameObject(this.fastDoneMoney,"Icon"):GetComponent("Image")
this.fastDoneNum = Util.GetGameObject(this.fastDoneMoney,"Num"):GetComponent("Text")
this.fastDoneBtn = Util.GetGameObject(gameObject,"Btns/fastDone/BtnDo")
--Done
this.doneNum = Util.GetGameObject(gameObject,"Btns/Done/Money/Text"):GetComponent("Text")
this.doneBtn = Util.GetGameObject(gameObject,"Btns/Done/BtnDo")
end
function this:BindEvent()
Util.AddClick(this.fastDoneBtn, function()
-- local priviId = PrivilegeManager.GetPrivilegeRemainValue()
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,"取消","确定")
end)
end)
Util.AddClick(this.doneBtn, function()
HomeLandManager.ResumeCost(data.dataSingle,nil,function ()
NetManager.ArchitectureOperateRequest({data.dataMain.Id},1,0,function ()
Game.GlobalEvent:DispatchEvent(GameEvent.UI.OnUpdateData)
parent:ClosePanel()
end)
end)
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent,_args)
data = _args
parent=_parent
sortingOrder =_parent.sortingOrder
-- parent.contents:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_tanchuangdi_01")
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)
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
this.Open:SetActive(false)
if OPENTEXT[data.level] and curData.PoolID == 5 then
this.Open:SetActive(true)
this.OpenText.text = OPENTEXT[data.level]
end
this.Cost:SetActive(false)
if curData.Cost then
this.Cost:SetActive(true)
this.cost1Icon1.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(curData.Cost[1][1]))
local color1 = BagManager.GetTotalItemNum(curData.Cost[1][1]) >= curData.Cost[1][2] and "#FFEED6" or "red"
this.cost1Num1.text = string.format("<color=%s>%s</color>",color1,curData.Cost[1][2])
end
if curData.Rule then
local color = HomeLandManager.BuildData[curData.Rule[1]].level < curData.Rule[2] and "FF0000" or "FFEED6"
this.cost2Name.text = string.format("<color=#%s>%s到达%s级</color>",color,HomeLand[curData.Rule[1]].Name,curData.Rule[2])
else
this.cost2Name.text = ""
end
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
-- parent.contents:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_tanchuangdi")
end
function this:OnDestroy()
this.spLoader:Destroy()
end
return this