local UIChangAnSiegeConstruct = UIViewClass() local TabIds = { Const_IDS.IDS_SiegeCity_InMBF_BuildTab_1, Const_IDS.IDS_SiegeCity_InMBF_BuildTab_2, Const_IDS.IDS_SiegeCity_InMBF_BuildTab_3, } local ChariotMinId = 8 local TowerFoundationFeatureId = 622021 --炮塔地基FeatureId local UpdateInterval = 0.3 local SiegeCityGoodsID = DataSheetManager.ConstData:GetDataByID("SiegeCityGoodsID").IntValue function UIChangAnSiegeConstruct:OnOpened(context) self:RegistSystemEvent(EventID.UI_ChangAnSiege_RefreshBuilding, self.RefreshBuilding) self.isSyncCityWarMainWaitingArea = BattleDataGetter.IsSyncCityWarMainWaitingArea() self:Init() if not self.isSyncCityWarMainWaitingArea then self:StartRepeatFunc(self.OnUpdateFun, UpdateInterval) end end function UIChangAnSiegeConstruct:Init() self.curSelectTabIndex = 0 self.curSelectBuildingIndex = 0 self.openingTowerUpdateIndex = 0 self.tankLimit = DataSheetManager.ConstData:GetDataByID("SiegeCityTankLimit").IntValue self.towerLimit = DataSheetManager.ConstData:GetDataByID("SiegeCityTowerLimit").IntValue self.buildPower = BattleDataGetter.GetMyPlayerInfo().siegeCityCanBuild or false self.isDefendCountry = MDL.ChangAnSiege.IsDefendCountry() self.state_Camp:SetState(self.isDefendCountry and 1 or 0) self.towersState = {} self.tanksState = {} self:InitTowers() self:InitTanks() for _,v in ipairs(TabIds) do self.loop_CASLeftConstructTab:AddData(v, 0) end self.loop_CASLeftConstructTab:SelectIndex(0) UIUtils.SetActive(self.group_Tips.gameObject, false) end function UIChangAnSiegeConstruct:InitTowers() for _, strategicPoint in ipairs(self.group_Construct.group_StrategicPoints) do UIUtils.SetActive(strategicPoint.img_StrategicPointsSelected, false) UIUtils.SetActive(strategicPoint.img_ConstructIcon, false) UIUtils.SetActive(strategicPoint.img_Operational, false) UIUtils.SetActive(strategicPoint.img_Plus, self.buildPower and self.isDefendCountry) end end function UIChangAnSiegeConstruct:InitTanks() for i = 1, self.tankLimit do self:InstantiateCollection(self.group_Construct.tank_Content, self.group_Construct.cell_TankTemplate.gameObject) UIUtils.SetActive(self.group_Construct.tank_Content[i].gameObject, true) self.group_Construct.tank_Content[i].state_Tank:SetState(0) for index, chariot in ipairs(self.group_Construct.tank_Content[i].group_chariot) do local cfg = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(index + ChariotMinId - 1) UIUtils.SetLabel(chariot.txt_Coin, cfg.SiegeCityBuildingCost) UIUtils.SetActive(chariot.img_Selected, false) end end end function UIChangAnSiegeConstruct:OnUpdateFun(deltaTime, timeSinceUpdate) if self.curSelectTabIndex == 0 then self:RefreshTower() self:RefreshTank() end end function UIChangAnSiegeConstruct:RefreshBuilding() self:RefreshTower() UIUtils.SetActive(self.group_Tips.gameObject, false) self:CloseAllOperational() end function UIChangAnSiegeConstruct:Refresh() UIUtils.SetActive(self.group_Construct.gameObject, self.curSelectTabIndex == 0) UIUtils.SetActive(self.group_ConstructionAtlas.gameObject, self.curSelectTabIndex ~= 0) if self.curSelectTabIndex == 0 then self:RefreshTower() self:RefreshTank() else self:RefreshConstructionAtlas() end end function UIChangAnSiegeConstruct:RefreshTower() self.towerCfgData = {} self.towerNum = 0 if self.isSyncCityWarMainWaitingArea then for i = 1, 6 do UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_ConstructIcon, false) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_UpgradeableIcon, false) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_Hp, false) self.towerCfgData[i] = nil self.towersState[i] = nil end else self.towerEntityData = BattleDataGetter.GetCityWarTowerEntityList() --长度为6的数组,元素是对应地块的炮塔entity for i, entity in ipairs(self.towerEntityData) do if entity.featureID ~= TowerFoundationFeatureId then local charId = entity:GetCharacterID() local cfg = CTL.ChangAnSiege.GetSiegeCityBuildCfgByMonsterID(charId) UIUtils.SetImageByAssetBundle(self.group_Construct.group_StrategicPoints[i].img_ConstructIcon, cfg.SiegeCityBuildingIcon) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_ConstructIcon, true) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_UpgradeableIcon, self:IsCanUpdate(cfg)) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_Hp, true) self:RefreshNextConstructIcon(i, cfg) self:RefreshTowerHp(entity, i) self.towerCfgData[i] = cfg if not self.towersState[i] then self.towersState[i] = charId CTL.Sound.PlayGameSound("UI_strongpoint_light") elseif self.towersState[i] ~= charId then self.towersState[i] = charId CTL.Sound.PlayGameSound("UI_equipment_02") end self.towerNum = self.towerNum + 1 else -- 地基 UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_ConstructIcon, false) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_UpgradeableIcon, false) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[i].img_Hp, false) self.towerCfgData[i] = nil self.towersState[i] = nil end end if self.isDefendCountry and self.openingTowerUpdateIndex > 0 and self.towerEntityData[self.openingTowerUpdateIndex].featureID == TowerFoundationFeatureId then UIUtils.SetActive(self.group_Construct.group_StrategicPoints[self.openingTowerUpdateIndex].img_Operational, false) UIUtils.SetActive(self.group_Construct.group_StrategicPoints[self.openingTowerUpdateIndex].img_StrategicPointsSelected, false) self.openingTowerUpdateIndex = 0 end end UIUtils.SetLabel(self.group_Construct.txt_Turret, string.FormatByIdsId(Const_IDS.IDS_SiegeCity_InMBF_Building_Des_1, self.towerNum, self.towerLimit)) end function UIChangAnSiegeConstruct:RefreshNextConstructIcon(index, cfg) if #cfg.SiegeCityBuildingNext > 0 then local nextBuildingCfg = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(cfg.SiegeCityBuildingNext[1]) UIUtils.SetImageByAssetBundle(self.group_Construct.group_StrategicPoints[index].group_SubordinateConstruction1.img_ConstructIcon, nextBuildingCfg.SiegeCityBuildingIcon) local nextBuildingCfg = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(cfg.SiegeCityBuildingNext[2]) UIUtils.SetImageByAssetBundle(self.group_Construct.group_StrategicPoints[index].group_SubordinateConstruction3.img_ConstructIcon, nextBuildingCfg.SiegeCityBuildingIcon) end end function UIChangAnSiegeConstruct:RefreshTank() if self.isSyncCityWarMainWaitingArea then self.tankNum = 0 else self.tankEntityData = BattleDataGetter.GetCityWarVehicleEntityList() if self.tankEntityData then self.tankNum = #self.tankEntityData else self.tankNum = 0 end for i = 1, #self.group_Construct.tank_Content do self:UpdateTanksInfo(self.tankEntityData[i],i, i > self.tankNum) end end UIUtils.SetLabel(self.group_Construct.txt_Chariot, string.FormatByIdsId(Const_IDS.IDS_SiegeCity_InMBF_Building_Des_2, self.tankNum, self.tankLimit)) end --更新战车信息 function UIChangAnSiegeConstruct:UpdateTanksInfo(data, i, isEmpty) local tank = self.group_Construct.tank_Content[i] if isEmpty then self.tanksState[i] = nil if self.isDefendCountry then tank.state_Tank:SetState(0) return end if i == self.tankNum + 1 then --加号 UIUtils.SetActive(tank.btn_Add, self.buildPower) UIUtils.SetActive(tank.img_ConstructIcon, false) UIUtils.SetActive(tank.img_Hp, false) return end tank.state_Tank:SetState(0) return end tank.state_Tank:SetState(2) local hpPercent = FP.tonumberV1(data.components.attr:HitPointPercents()) local charId = data:GetCharacterID() local monstercfg = DataSheetManager.MonsterData:GetDataByID(charId) local buildingHp = DataSheetManager.MonsterValueData:GetDataByGroupID_Difficulty(monstercfg.AdaptiveParam,1).hplmt UIUtils.SetLabel(self.group_Construct.tank_Content[i].txt_hp, buildingHp*hpPercent.."/"..buildingHp) local cfg = CTL.ChangAnSiege.GetSiegeCityBuildCfgByMonsterID(charId) UIUtils.SetImageByAssetBundle(self.group_Construct.tank_Content[i].img_ConstructIcon, cfg.SiegeCityBuildingIcon) if not self.tanksState[i] then self.tanksState[i] = charId CTL.Sound.PlayGameSound("UI_strongpoint_light") elseif self.tanksState[i] ~= charId then self.tanksState[i] = charId CTL.Sound.PlayGameSound("UI_equipment_02") end end function UIChangAnSiegeConstruct:IsCanUpdate(cfg) if self.isDefendCountry and self.buildPower then if #cfg.SiegeCityBuildingNext > 0 then for i = 1, 2 do local nextBuildingCfg = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(cfg.SiegeCityBuildingNext[i]) if self:IsSiegeCityGoodsEnough(nextBuildingCfg.SiegeCityBuildingCost) then return true end end end end return false end function UIChangAnSiegeConstruct:RefreshTowerHp(entity, index) local hpPercent = FP.tonumberV1(entity.components.attr:HitPointPercents()) local monstercfg = DataSheetManager.MonsterData:GetDataByID(entity:GetCharacterID()) local buildingHp = DataSheetManager.MonsterValueData:GetDataByGroupID_Difficulty(monstercfg.AdaptiveParam,1).hplmt UIUtils.SetLabel(self.group_Construct.group_StrategicPoints[index].txt_hp, buildingHp*hpPercent.."/"..buildingHp) end local function constructionSort(a,b) if a.SiegeCityBuildingRank == b.SiegeCityBuildingRank then return a.SiegeCityBuildingID < b.SiegeCityBuildingID end return a.SiegeCityBuildingRank < b.SiegeCityBuildingRank end function UIChangAnSiegeConstruct:RefreshConstructionAtlas() self.maxConstructionIndex = -1 local constructionData = {} if self.curSelectTabIndex == 1 then for _, v in DataSheetManager.SiegeCityBuild:GetEnumerator() do if v.SiegeCityBuildingType == MDL.ChangAnSiege.SiegeCityBuildingType.Turret then table.insert(constructionData, v) self.maxConstructionIndex = self.maxConstructionIndex + 1 end end elseif self.curSelectTabIndex == 2 then for _, v in DataSheetManager.SiegeCityBuild:GetEnumerator() do if v.SiegeCityBuildingType == MDL.ChangAnSiege.SiegeCityBuildingType.WarCar then table.insert(constructionData, v) self.maxConstructionIndex = self.maxConstructionIndex + 1 end end end table.sort(constructionData, constructionSort) self.group_ConstructionAtlas.loop_ConstructionAtlas:ReloadAll(constructionData) self.curSelectBuildingIndex = 0 self.group_ConstructionAtlas.loop_ConstructionAtlas:SelectIndex(0, true) end function UIChangAnSiegeConstruct:RefreshConstructionInfo(info) UIUtils.SetImageByAssetBundle(self.group_ConstructionAtlas.img_main_ConstructIcon, info.SiegeCityBuildingDraw) self.group_ConstructionAtlas.img_main_ConstructIcon:SetNativeSize() UIUtils.SetImageByAssetBundle(self.group_ConstructionAtlas.img_ConstructIcon, info.SiegeCityBuildingIcon) UIUtils.SetLabelText(self.group_ConstructionAtlas.txt_ConstructName, Const_IDS[info.SiegeCityBuildingName]) UIUtils.SetLabel(self.group_ConstructionAtlas.txt_Coin, info.SiegeCityBuildingCost) if self.curSelectTabIndex == 1 then self.group_ConstructionAtlas.state_Info:SetState(0) UIUtils.SetLabelText(self.group_ConstructionAtlas.txt_SkillInfo1, Const_IDS[info.SiegeCityBuildingDes]) if #info.SiegeCityBuildingNext > 0 then local nextBuilding1 = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(info.SiegeCityBuildingNext[1]) UIUtils.SetLabelText(self.group_ConstructionAtlas.txt_Upgrade1, Const_IDS[nextBuilding1.SiegeCityBuildingName]) local nextBuilding2 = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(info.SiegeCityBuildingNext[2]) UIUtils.SetLabelText(self.group_ConstructionAtlas.txt_Upgrade2, Const_IDS[nextBuilding2.SiegeCityBuildingName]) UIUtils.SetActive(self.group_ConstructionAtlas.group_Info3, true) else UIUtils.SetLabel(self.group_ConstructionAtlas.txt_Upgrade1, "") UIUtils.SetLabel(self.group_ConstructionAtlas.txt_Upgrade2, "") UIUtils.SetActive(self.group_ConstructionAtlas.group_Info3, false) end else UIUtils.SetLabelText(self.group_ConstructionAtlas.txt_SkillInfo2, Const_IDS[info.SiegeCityBuildingDes]) self.group_ConstructionAtlas.state_Info:SetState(1) end local monstercfg = DataSheetManager.MonsterData:GetDataByID(info.SiegeCityNpcID) local buildingHp = DataSheetManager.MonsterValueData:GetDataByGroupID_Difficulty(monstercfg.AdaptiveParam,1).hplmt UIUtils.SetLabel(self.group_ConstructionAtlas.txt_ConstructDurable, string.FormatByIdsId(Const_IDS.IDS_SiegeCity_InMBF_Building_Des_3, buildingHp)) self.skillIds = monstercfg.SkillIDData_Table for index, cell in ipairs(self.group_ConstructionAtlas.skills) do local skillId = self.skillIds[index] if skillId == nil then UIUtils.SetActive(cell.gameObject,false) else UIUtils.SetActive(cell.gameObject,true) self:RefreshSkillIconShow(cell, skillId.ID) end end end local SkillPath = ConstAssetPathConfig.SkillImagePath function UIChangAnSiegeConstruct:RefreshSkillIconShow(cell, skillId) local skillData = DataSheetManager.SkillData:GetDataByID(skillId) --不需要通过entity获取,因为下面访问的数据预期不可能被重写(非hero技能) if not string.isNilOrEmpty(skillData.Icon) then UIUtils.SetImageByAssetBundle(cell.sprite_Skill, string.format(SkillPath, skillData.Icon)) else UIUtils.SetAtlasImage(cell.sprite_Skill, "UI_Battle", "zd_icon_pg") end end function UIChangAnSiegeConstruct:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView() elseif comp == self.group_ConstructionAtlas.btn_ArrowLeft then if self.curSelectBuildingIndex == 0 then self.curSelectBuildingIndex = self.maxConstructionIndex else self.curSelectBuildingIndex = self.curSelectBuildingIndex - 1 end self.group_ConstructionAtlas.loop_ConstructionAtlas:SelectIndex(self.curSelectBuildingIndex, true) elseif comp == self.group_ConstructionAtlas.btn_ArrowRight then if self.curSelectBuildingIndex == self.maxConstructionIndex then self.curSelectBuildingIndex = 0 else self.curSelectBuildingIndex = self.curSelectBuildingIndex + 1 end self.group_ConstructionAtlas.loop_ConstructionAtlas:SelectIndex(self.curSelectBuildingIndex, true) elseif comp == self.group_Tips.btn_Upgrade then if not self.isDefendCountry and not BattleDataGetter.GetCityWarDefendBossIsDead() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SiegeCity_InMBF_Building_Tips_7"]) UIUtils.SetActive(self.group_Tips.gameObject, false) elseif self:HasBuildingDestored() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SiegeCity_InMBF_Building_Tips_5"]) UIUtils.SetActive(self.group_Tips.gameObject, false) elseif not self.buildPower then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SiegeCity_InMBF_Building_Tips_2"]) UIUtils.SetActive(self.group_Tips.gameObject, false) elseif not self.buildItemEnough then self:OpenConstructTips(self.curSelectBuildingId) CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS["IDS_SiegeCity_InMBF_Building_Tips_4"]), UTL.Item.GetItemDataSpliceByType(SiegeCityGoodsID).Name) else MDL.ChangAnSiege.SiegeCityBuildingUpgradeReq(self.curSelectBuildingId, self.curSelectBuildingPos) end elseif comp == self.group_Tips.btn_Close then UIUtils.SetActive(self.group_Tips.gameObject, false) elseif comp == self.group_Tips.close_event then UIUtils.SetActive(self.group_Tips.gameObject, false) elseif comp == self.group_Construct.img_ConstructIcon then self:CloseAllOperational() elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.SiegeCityBuild }) else if self:OnClickSkillBtn(comp) then return end if self.isDefendCountry then self:OnClickTowerBtn(comp) else self:OnClickTankBtn(comp) end end end function UIChangAnSiegeConstruct:OnClickSkillBtn(comp) for index, cell in ipairs(self.group_ConstructionAtlas.skills) do if comp == cell.btn_Skill then self.group_ConstructionAtlas.SkillTips:CloseAll() CTL.Tips.OpenSkillTips(self.skillIds[index].ID, self.group_ConstructionAtlas.SkillTips, CTL.Tips.SkillType.BuildingSkill) return true end end for index, cell in ipairs(self.group_Tips.skills) do if comp == cell.btn_Skill then self.group_Tips.SkillTips:CloseAll() CTL.Tips.OpenSkillTips(self.skillIds[index].ID, self.group_Tips.SkillTips, CTL.Tips.SkillType.BuildingSkill) return true end end return false end function UIChangAnSiegeConstruct:OnClickTowerBtn(comp) for index, strategicPoint in ipairs(self.group_Construct.group_StrategicPoints) do -- 点击炮塔加号或者炮塔 打开选项 if comp == strategicPoint.btn_StrategicPoints then if self.buildPower and self.isDefendCountry then if not self.towerCfgData[index] and self.towerNum >= self.towerLimit then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SiegeCity_InMBF_Building_Tips_1"]) else self:OpenTowerOperational(index, strategicPoint) UIUtils.SetActive(strategicPoint.img_StrategicPointsSelected, true) end end return end for i = 1, 3 do if comp == strategicPoint["group_SubordinateConstruction"..i].btn_Rect then local buildingId = 1 if i == 1 then buildingId = self.towerCfgData[index].SiegeCityBuildingNext[1] elseif i == 3 then buildingId = self.towerCfgData[index].SiegeCityBuildingNext[2] end self:OpenConstructTips(buildingId) self.curSelectBuildingPos = index UIUtils.SetActive(strategicPoint["group_SubordinateConstruction"..i].img_Selected, true) else UIUtils.SetActive(strategicPoint["group_SubordinateConstruction"..i].img_Selected, false) end end end end function UIChangAnSiegeConstruct:OnClickTankBtn(comp) for i, tank in ipairs(self.group_Construct.tank_Content) do if comp == tank.btn_Add then self:CloseAllOperational() if self.buildPower and not self.isDefendCountry then tank.state_Tank:SetState(1) return end end for i = 1, 3 do if comp == tank.group_chariot[i].btn_Rect then local buildingId = i + ChariotMinId - 1 self:OpenConstructTips(buildingId) self.curSelectBuildingPos = 1 UIUtils.SetActive(tank.group_chariot[i].img_Selected, true) else UIUtils.SetActive(tank.group_chariot[i].img_Selected, false) end end if comp == tank.img_ConstructIcon then self:CloseAllOperational() local cfg = CTL.ChangAnSiege.GetSiegeCityBuildCfgByMonsterID(self.tankEntityData[i]:GetCharacterID()) self:OpenConstructTips(cfg.SiegeCityBuildingID, true, true) return end end end function UIChangAnSiegeConstruct:HasBuildingDestored() if self.isDefendCountry and self.curSelectBuildingId > 1 then --当前选中的BuildingId至少是2级塔 return self.towerEntityData[self.curSelectBuildingPos].featureID == TowerFoundationFeatureId end return false end function UIChangAnSiegeConstruct:CloseAllOperational() if self.isDefendCountry then for i, v in ipairs(self.group_Construct.group_StrategicPoints) do UIUtils.SetActive(v.img_Operational, false) UIUtils.SetActive(v.img_StrategicPointsSelected, false) for i = 1, 3 do UIUtils.SetActive(v["group_SubordinateConstruction"..i].img_Selected, false) end end self.openingTowerUpdateIndex = 0 else for i, tank in ipairs(self.group_Construct.tank_Content) do UIUtils.SetActive(tank.img_ChariotLine, false) end end end function UIChangAnSiegeConstruct:OpenTowerOperational(index, strategicPoint) self:CloseAllOperational() if self.towerCfgData[index] then local cfg = self.towerCfgData[index] if #cfg.SiegeCityBuildingNext > 0 then UIUtils.SetActive(self.group_Construct.group_StrategicPoints[index].img_Operational, true) strategicPoint.state_StrategicPoints:SetState(1) local nextBuilding1 = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(cfg.SiegeCityBuildingNext[1]) if self:IsSiegeCityGoodsEnough(nextBuilding1.SiegeCityBuildingCost) then UIUtils.SetLabel(strategicPoint.group_SubordinateConstruction1.txt_Coin, UTL.Color.FormatGreenColor(nextBuilding1.SiegeCityBuildingCost)) else UIUtils.SetLabel(strategicPoint.group_SubordinateConstruction1.txt_Coin, UTL.Color.FormatRedColor(nextBuilding1.SiegeCityBuildingCost)) end local nextBuilding2 = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(cfg.SiegeCityBuildingNext[2]) if self:IsSiegeCityGoodsEnough(nextBuilding2.SiegeCityBuildingCost) then UIUtils.SetLabel(strategicPoint.group_SubordinateConstruction3.txt_Coin, UTL.Color.FormatGreenColor(nextBuilding2.SiegeCityBuildingCost)) else UIUtils.SetLabel(strategicPoint.group_SubordinateConstruction3.txt_Coin, UTL.Color.FormatRedColor(nextBuilding2.SiegeCityBuildingCost)) end self.openingTowerUpdateIndex = index else self:OpenConstructTips(cfg.SiegeCityBuildingID, true) end else --空地 UIUtils.SetActive(self.group_Construct.group_StrategicPoints[index].img_Operational, true) strategicPoint.state_StrategicPoints:SetState(0) local buildingCost = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(1).SiegeCityBuildingCost if self:IsSiegeCityGoodsEnough(buildingCost) then UIUtils.SetLabel(strategicPoint.group_SubordinateConstruction2.txt_Coin, UTL.Color.FormatGreenColor(buildingCost)) else UIUtils.SetLabel(strategicPoint.group_SubordinateConstruction2.txt_Coin, UTL.Color.FormatRedColor(buildingCost)) end end end function UIChangAnSiegeConstruct:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_CASLeftConstructTab then UIUtils.SetLabelText(cellTable.txt_UnselectedTabName, data) UIUtils.SetLabelText(cellTable.txt_SelectedTabName, data) elseif scrollRect == self.group_ConstructionAtlas.loop_ConstructionAtlas then UIUtils.SetImageByAssetBundle(cellTable.img_ConstructItem, data.SiegeCityBuildingIcon) UIUtils.SetImageByAssetBundle(cellTable.img_QualityFrame, data.SiegeCityBuildingIconBG) end end function UIChangAnSiegeConstruct:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_CASLeftConstructTab then self.curSelectTabIndex = index self:Refresh() elseif scrollRect == self.group_ConstructionAtlas.loop_ConstructionAtlas then self.curSelectBuildingIndex = index self:RefreshConstructionInfo(data) end end function UIChangAnSiegeConstruct:OpenConstructTips(buildingId, isMaxLevel, notShowMaxLevel) self.curSelectBuildingId = buildingId UIUtils.SetActive(self.group_Tips.gameObject, true) local info = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(buildingId) UIUtils.SetImageByAssetBundle(self.group_Tips.img_ConstructIcon, info.SiegeCityBuildingIcon) UIUtils.SetLabelText(self.group_Tips.txt_ConstructName, Const_IDS[info.SiegeCityBuildingName]) if buildingId == 1 or info.SiegeCityBuildingType == MDL.ChangAnSiege.SiegeCityBuildingType.WarCar then UIUtils.SetLabelText(self.group_Tips.lab_Upgrade, Const_IDS.IDS_SiegeCity_InMBF_Building_Button_1) UIUtils.SetLabelText(self.group_Tips.lab_Details, Const_IDS.IDS_SiegeCity_InMBF_Building_Button_1) else UIUtils.SetLabelText(self.group_Tips.lab_Upgrade, Const_IDS.IDS_SiegeCity_InMBF_Building_Button_2) UIUtils.SetLabelText(self.group_Tips.lab_Details, Const_IDS.IDS_SiegeCity_InMBF_Building_Button_2) end if isMaxLevel then self.group_Tips.state_Info:SetState(2) UIUtils.SetLabelText(self.group_Tips.txt_SkillInfo2, Const_IDS[info.SiegeCityBuildingDes]) UIUtils.SetLabelText(self.group_Tips.txt_max, Const_IDS.IDS_SiegeCity_InMBF_Building_Tips_6) UIUtils.SetActive(self.group_Tips.txt_max, not notShowMaxLevel) else self.buildItemEnough = self:IsSiegeCityGoodsEnough(info.SiegeCityBuildingCost) if self.buildItemEnough then UIUtils.SetLabel(self.group_Tips.txt_Coin, UTL.Color.FormatGreenColor(info.SiegeCityBuildingCost)) else UIUtils.SetLabel(self.group_Tips.txt_Coin, UTL.Color.FormatRedColor(info.SiegeCityBuildingCost)) end if #info.SiegeCityBuildingNext > 0 then self.group_Tips.state_Info:SetState(0) UIUtils.SetLabelText(self.group_Tips.txt_SkillInfo1, Const_IDS[info.SiegeCityBuildingDes]) local nextBuilding1 = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(info.SiegeCityBuildingNext[1]) UIUtils.SetLabelText(self.group_Tips.txt_Upgrade1, Const_IDS[nextBuilding1.SiegeCityBuildingName]) local nextBuilding2 = DataSheetManager.SiegeCityBuild:GetDataBySiegeCityBuildingID(info.SiegeCityBuildingNext[2]) UIUtils.SetLabelText(self.group_Tips.txt_Upgrade2, Const_IDS[nextBuilding2.SiegeCityBuildingName]) UIUtils.SetActive(self.group_Tips.group_Info3, true) else self.group_Tips.state_Info:SetState(1) UIUtils.SetLabelText(self.group_Tips.txt_SkillInfo2, Const_IDS[info.SiegeCityBuildingDes]) UIUtils.SetActive(self.group_Tips.group_Info3, false) end end local monstercfg = DataSheetManager.MonsterData:GetDataByID(info.SiegeCityNpcID) local buildingHp = DataSheetManager.MonsterValueData:GetDataByGroupID_Difficulty(monstercfg.AdaptiveParam,1).hplmt UIUtils.SetLabel(self.group_Tips.txt_ConstructDurable, string.FormatByIdsId(Const_IDS.IDS_SiegeCity_InMBF_Building_Des_3, buildingHp)) self.skillIds = monstercfg.SkillIDData_Table for index, cell in ipairs(self.group_Tips.skills) do local skillId = self.skillIds[index] if skillId == nil then UIUtils.SetActive(cell.gameObject,false) else UIUtils.SetActive(cell.gameObject,true) self:RefreshSkillIconShow(cell, skillId.ID) end end end function UIChangAnSiegeConstruct:IsSiegeCityGoodsEnough(needNum) local bagSiegeCityGoodsCount = UTL.Item.GetItemStockCount(SiegeCityGoodsID) return bagSiegeCityGoodsCount >= needNum end return UIChangAnSiegeConstruct