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

81 lines
3.0 KiB
Lua

----- --家园建筑详情 -----
local this = {}
local HomeLand = ConfigManager.GetConfig(ConfigName.HomeLand)
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.HomeLandLevel)
local HomeLandTask = ConfigManager.GetConfig(ConfigName.HomeLandTask)
--传入父脚本模块
local parent
--传入特效层级
local sortingOrder=0
local data=nil
function this:InitComponent(gameObject)
this.spLoader = SpriteLoader.New()
this.cancelBtn = Util.GetGameObject(gameObject,"BtnCancel")
this.buildName = Util.GetGameObject(gameObject,"Content/buildName"):GetComponent("Text")
this.harvest = Util.GetGameObject(gameObject,"Content/harvest")
this.harvestNum = Util.GetGameObject(gameObject,"Content/harvest/Num"):GetComponent("Text")
this.harvestIcon = Util.GetGameObject(gameObject,"Content/harvest/Icon"):GetComponent("Image")
this.upgradeAdd = Util.GetGameObject(gameObject,"Content/upgrade/Num"):GetComponent("Text")
this.limit = Util.GetGameObject(gameObject,"Content/limit")
this.limitIcon = Util.GetGameObject(gameObject,"Content/limit/Icon"):GetComponent("Image")
this.limitNum = Util.GetGameObject(gameObject,"Content/limit/Num"):GetComponent("Text")
this.Desc = Util.GetGameObject(gameObject,"Content/GameObject/Desc"):GetComponent("Text")
end
function this:BindEvent()
Util.AddClick(this.cancelBtn,function()
parent:ClosePanel()
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_tanchuangdi3")
this.buildName.text = data.dataSingle.Name
if data.dataSingle.Rule then
this.upgradeAdd.text = string.format("%s%s级",HomeLand[data.dataSingle.Rule[1]].Name,data.dataSingle.Rule[2])
else
this.upgradeAdd.text = ""
end
if data.dataMain.Id == 5 then
this.limit:SetActive(false)
this.harvest:SetActive(false)
else
this.limit:SetActive(true)
this.harvest:SetActive(true)
this.limitIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(data.dataSingle.Storage[1][1]))
this.limitNum.text = data.dataSingle.Storage[1][2]
local v = ConfigManager.GetConfigData(ConfigName.PrivilegeTypeConfig,4022).Condition[1][2]/10000-1
local priValue = HomeLandManager.activePrivilege and string.format("<color=#00FF00>+%s</color>",math.ceil(data.dataSingle.Gain[2]*v)) or ""
this.harvestNum.text = string.format("%s %s/分钟",data.dataSingle.Gain[2],priValue)
this.harvestIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(data.dataSingle.Gain[1]))
end
this.Desc.text = data.dataMain.Desc
end
function this:OnClose()
data=nil
if parent then
parent.contents:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_hero_tanchuangdi")
end
end
function this:OnDestroy()
this.spLoader:Destroy()
end
return this