----- --家园装备升级 ----- local this = {} 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","生命"}, } function this:InitComponent(gameObject) this.spLoader = SpriteLoader.New() this.titleText=Util.GetGameObject(gameObject,"TitleText"):GetComponent("Text") this.titleText.text="摘星阁" this.Btn1 = Util.GetGameObject(gameObject,"Btn1") 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.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") end function this:BindEvent() Util.AddClick(this.Btn1,function() local data = HomeLandManager.EquipData[HomeLandManager.curEquip].configData 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 if BagManager.GetTotalItemNum(data.Cost[1][1]) < data.Cost[1][2] then PopupTipPanel.ShowTip(string.format("%s不足!",ItemConfig[data.Cost[1][1]].Name)) return end NetManager.EquipIntensifyRequset(HomeLandManager.curEquip,function () this:Refresh() end) end) Util.AddClick(this.Btn2,function() if HomeLandManager.GetAllCanUpgradeWithPopup() then this:Refresh() return end NetManager.EquipIntensifyRequset(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:OnShow(_parent,_args) data = _args parent=_parent sortingOrder =_parent.sortingOrder HomeLandManager.GetCurIndex() 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 = HomeLandManager.EquipData[i].configData.Level 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 data = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Rate--当前装备加成 local proData = EquipRankUp[HomeLandManager.levelProId].Rate--当前装备突破加成 local nextData = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id + 1].Rate--下一装备加成 local nextProData = EquipRankUp[HomeLandManager.levelProId + 1].Rate--下一装备突破加成 local num1 = data + proData[curIndex] -- LogYellow(tostring(data).." @ "..tostring(proData[curIndex])) local num2 = 0 if not HomeLandManager.GetCurIndexBtnsShow() then--如果都到达了等级上限 num2 = data + nextProData[curIndex] -- LogYellow(tostring(data).." $ "..tostring(nextProData[curIndex])) else num2 = nextData + proData[curIndex] -- LogYellow(tostring(nextData).." # "..tostring(proData[curIndex])) end this.Desc.text = string.format("神将佩戴的%s%s属性增加%s",TEXT[curIndex][1],TEXT[curIndex][3],num1).."%"..string.format("(%s",num2).."%)" --设置消耗 local limit = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Limit local cost = EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Cost this.costIcon.sprite = this.spLoader:LoadSprite(GetSpriteNameByItemId(cost[1][1])) if HomeLandManager.BuildData[limit[1]].level >= limit[2] then this.costCondition.text = "" this.costIcon.gameObject:SetActive(true) this.costNum.gameObject:SetActive(true) local color2 = BagManager.GetTotalItemNum(cost[1][1]) >= cost[1][2] and "#FFEED6" or "red" this.costNum.text = string.format("%s",color2,cost[1][2]) else this.costIcon.gameObject:SetActive(false) this.costNum.gameObject:SetActive(false) this.costCondition.text = string.format("%s需要到达%s级",HomeLand[limit[1]].Name,limit[2]) end --按钮和tips显示 local bool = HomeLandManager.GetCurIndexBtnsShow() -- 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级后方可进行突破",EquipStrengthen[HomeLandManager.EquipData[curIndex].Id].Level) if not bool and HomeLandManager.GetAllCanUpgrade() 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 = EquipRankUp[HomeLandManager.levelProId].Cost local color2 = BagManager.GetTotalItemNum(cost[1]) >= cost[2] and "#FFEED6" or "red" this.costNum.text = string.format("%s",color2,cost[2]) end end function this:OnClose() HomeLandManager.curEquip = 1 data=nil end function this:OnDestroy() this.SelectList = {} this.spLoader:Destroy() end return this