local UIGVGFightTransferTips = UIViewClass() --[[ 攻城略地 进攻界面 context = { cityId, --选中城池Id targetAcid, --要调动的玩家Id } --]] local GVGFightCostRatioInFierceFighting = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GVGFightCostRatioInFierceFighting").FloatValue) -- 激战期消耗比例 local CityTypeIds = { "IDS_GVGFight_CityType1", --大型城池 "IDS_GVGFight_CityType2", --中型城池 "IDS_GVGFight_CityType3", --小型城池 "IDS_GVGFight_CityType4", --大营 } -------------------- function UIGVGFightTransferTips:OnCreated() self.cityUIList = {} -- 城池UICellIndex复用。防止频繁创建 self.cityDataList = {} -- 城池列表复用。防止频繁创建 end function UIGVGFightTransferTips:OnOpened(context) self:RegistSystemEvent(EventID.GVGFight_RefreshGVGFightState, self.RefreshCity) self:RegistSystemEvent(EventID.GVGFight_RefreshCityState, self.RefreshCity) self:RegistSystemEvent(EventID.UI_RefreshCurrency, self.RefreshCity) self:RegistSystemEvent(EventID.GVGFight_RefreshCityPlayerList, self.RefreshTransferTipState) self:RefreshCity() end function UIGVGFightTransferTips:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIGVGFightTransferTips:OnButtonClicked(comp) if comp == self.btn_Close then self:CloseView(false) end end function UIGVGFightTransferTips:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.Loop_SoulCrystalTips then if not data.CityID then UIUtils.SetLabel(cellTable.lab_Title, UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[CityTypeIds[data.CityType]]))) else local info = MDL.GVGFight.GetCityOuterInfo(data.CityID) UIUtils.SetLabel(cellTable.txt_CityName, UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS[data.CityName]))) if info and info.isHighYield then UIUtils.SetActive(cellTable.txt_HighYield, true) UIUtils.SetLabel(cellTable.txt_HighYield, UTL.Color.FormatTextByColor(data.CityNameColor, UIUtils.GetLocalizedTxt(Const_IDS.IDS_GVGFight_CityDoubleHarvest))) else UIUtils.SetActive(cellTable.txt_HighYield, false) end -- 设置调用消耗 UTL.Item.MoneyIcon(cellTable.img_Coin, data.CityStationCostItem) local isEnough, cityStationCostNum = self:GetCostState(data) if isEnough then UIUtils.SetLabel(cellTable.txt_Coin, cityStationCostNum) else UIUtils.SetLabel(cellTable.txt_Coin, UTL.Color.FormatRedColor(cityStationCostNum)) end end end end function UIGVGFightTransferTips:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.Loop_SoulCrystalTips then if target ~= cellTable.btn_Transfer then return end if not data.CityID then return end local guildInfo = MDL.Guild.GetMyGuildInfo() if guildInfo.jobTitle == MDL.Guild.JobEnum.JunshiElder or guildInfo.jobTitle == MDL.Guild.JobEnum.Leader then local isEnough = self:GetCostState(data) if isEnough then MDL.GVGFight.GVGTransferReq(data.CityID, self.context.targetAcid, self.context.cityId) else UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_Store_BuyButton, Const_IDS.IDS_GVGFight_StationTips1, function() for _, v in MDL.OperationActivity.StoreGoodsData:GetEnumerator() do if v.ItemID == MDL.GVGFight.ProvisionsItemId then UTL.ItemTips.OpenQuickPurchaseView(v.ID) return end end end) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_3336_InfoCode_GVGFight_TransferTips_1) self:OnButtonClicked(self.btn_Close) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGVGFightAttack) end end end -------------------- function UIGVGFightTransferTips:RefreshCity() -- 设置城池 local dataCount = 0 for i, v in DataSheetManager.GVGFightCity:GetEnumerator() do if MDL.GVGFight.IsEffectiveCity(v.CityID) and v.CityID ~= self.context.cityId then if dataCount == 0 or v.CityType ~= self.cityDataList[dataCount].CityType then dataCount = dataCount + 1 self.cityUIList[dataCount] = 0 self.cityDataList[dataCount] = {CityNameColor = v.CityNameColor, CityType = v.CityType} end dataCount = dataCount + 1 self.cityUIList[dataCount] = 1 self.cityDataList[dataCount] = v end end for i = dataCount + 1, #self.cityDataList do table.remove(self.cityUIList) table.remove(self.cityDataList) end self.Loop_SoulCrystalTips:ReloadAll(self.cityDataList, self.cityUIList) end function UIGVGFightTransferTips:RefreshTransferTipState() local attackInfo = MDL.GVGFight.GetInsideInfoByAcid(self.context.targetAcid) if not attackInfo then self:OnBackButtonPressed() end end function UIGVGFightTransferTips:GetCostState(cityData) local coinCount = UTL.Item.GetItemStockCount(cityData.CityStationCostItem) local cityStationCostNum = cityData.CityStationCostNum if MDL.GVGFight.GetCurGVGFightState() == MDL.GVGFight.GVGFightStage.Fierce then cityStationCostNum = math.floor(cityStationCostNum * GVGFightCostRatioInFierceFighting) end if coinCount < cityStationCostNum then return false, cityStationCostNum else return true, cityStationCostNum end end return UIGVGFightTransferTips