--世界Boss专用复活界面 local UIWorldBossRevive = UIViewClass() local ItemIconPath = ConstAssetPathConfig.ItemIconPath local SEEK_HELP_TIME = DataSheetManager.ConstData:GetDataByID("WorldBossSeekHelpCD").IntValue --第三个按钮需要判断货币 function UIWorldBossRevive:OnOpened(context) self.passTime = 0 self.Timer = context.time self.timeLeftFormat = context.timeLeftFormat --self.cdTimer:ResetAndBeginCustomTimer(false, context.time, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WorldBoss_Reborn_SafeRebornTip), 1) self.group_Btn02:ResetAndBeginCustomTimer(false, context.time, 0, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WorldBoss_Revive), 1) self.btnClick_1 = context.btnClick_1 self.btnClickEnsureDes_1 = context.btnClickEnsureDes_1 self.btnClick_2 = context.btnClick_2 if context.content then UTL.String.SetLabelContent(self.txt_Revive,context.content) else --处理特殊情况 self:RegistSystemEvent(EventID.UIBattle_Level_SetUpBoss, self.UpdateBossContent) end UTL.String.SetLabelContent(self.lab_03,context.descLabel_1) self.btn_03:SetText(context.btnLabel_1) UTL.String.SetLabelContent(self.lab_02,context.descLabel_2) --self.btn_02:SetText(context.btnLabel_2) self.btn_02:SetGray(true) UTL.String.SetLabelContent(self.lab_01,context.descLabel_3) self.btn_01:SetText(context.btnLabel_3) self.toggleFunc = context.toggleFunc self.toggle_Hide.isOn = context.toggleDefaultState local needCoin = context.costNum local coinType = context.costID local curCoin = MDL.Currency.GetSoftTokenCountById(coinType) local coinData = DataSheetManager.ItemData:GetDataByID(coinType) UIUtils.SetImageByAssetBundle(self.icon_Currency,string.format(ItemIconPath,coinData.Icon)) if curCoin >= needCoin then UIUtils.SetLabel(self.txt_Currency,UTL.Color.FormatGreenColor(needCoin)) self.btnClick_3 = function() context.btnClick_3() self:CloseView() end else UIUtils.SetLabel(self.txt_Currency,UTL.Color.FormatRedColor(needCoin)) self.btnClick_3 = function() CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_ClimbTower_NoMoney, UTL.Item.GetItemDataSpliceByType(coinType).Name)) end end self:StartRepeatFunc(self.OnUpdateFun, 1) CTL.Sound.PlayGameSound("SFX_die") --求助特效 self:HelpCDOver() if MDL.WorldBoss.GetIsAttacked() then self.effect_Help:PlayUIEffect() end end function UIWorldBossRevive:UpdateBossContent(active,monsterId) self:UnregistSystemEvent() local monsterData = DataSheetManager.MonsterData:GetDataByID(monsterId) if monsterData then if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.SyncWorldBoss) or LevelManager.CheckCurLevelType(LuaConst.LevelType.SyncWarZoneWorldBoss) then local content = string.FormatByIdsId(Const_IDS.IDS_WorldBoss_Reborn_Tip,UTL.Color.FormatRedColor(UIUtils.GetLocalizedTxt(Const_IDS[monsterData.MonsterNameIDS]))) UTL.String.SetLabelContent(self.txt_Revive,content) end end end function UIWorldBossRevive:OnUpdateFun(deltaTime, timeSinceUpdate) self.passTime = self.passTime + deltaTime if self.Timer and self.passTime >= self.Timer then self.Timer = nil UIUtils.SetActive(self.toggle_Hide.gameObject,false) self.btn_02:SetGray(false) if self.toggle_Hide.isOn then self:OnButtonClicked(self.btn_02) end end if self.helpTimer and timeSinceUpdate >= self.helpTimer then self.helpTimer = nil self:HelpCDOver() end end function UIWorldBossRevive:OnValueChanged(comp, state) if self.toggleFunc then self.toggleFunc(state) end end function UIWorldBossRevive:OnButtonClicked(comp) if comp == self.img_Click then --跳到商店 to do elseif comp == self.btn_01 then if self.btnClick_3 then self.btnClick_3() end elseif comp == self.btn_02 then if self.btnClick_2 then self.btnClick_2() end self:CloseView() elseif comp == self.btn_03 then if self.btnClickEnsureDes_1 then UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_ExitBarrier, Const_IDS.IDS_WorldBoss_Quit_Tip, function() if self.btnClick_1 then self.btnClick_1() end self:CloseView() end, nil) else if self.btnClick_1 then self.btnClick_1() end self:CloseView() end elseif comp == self.event_SeekHelp then self:OnSeekHelp() end end function UIWorldBossRevive:OnClosed() CTL.Sound.PlayGameSound("SFX_life") end --请求协助后,按钮变灰色,倒计时开始,按钮不可用 function UIWorldBossRevive:OnSeekHelp() local req = false if self.context.killer ~= "" then req = MDL.WorldBoss.WorldBossSeekHelp(false, MDL.WorldBoss.HelpType.Killed, self.context.killer) else local value = MDL.WorldBoss.GetIsAttacked() --是否被人攻击过 req = MDL.WorldBoss.WorldBossSeekHelp(false, value and MDL.WorldBoss.HelpType.Attacked or MDL.WorldBoss.HelpType.Normal, "") end if req then self:ResetRepeatFunc(self.OnUpdateFun) self.event_SeekHelp:SetGray(true, false) self.helpTimer = SEEK_HELP_TIME self.lab_HelpTimeCD:ResetAndBeginCustomTimer(false, self.helpTimer, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_TeamUI_Myteam_RecruitingTime"]), 1) self.effect_Help:StopUIEffect() end end -- 请求协助CD 结束 function UIWorldBossRevive:HelpCDOver() self.event_SeekHelp:SetGray(false, true) self.lab_HelpTimeCD:EndTimer() end return UIWorldBossRevive