local UISyncSoloRoll = UIViewClass() local IMAGE_ROLL = { [1] = ConstAssetPathConfig.Path25, [2] = ConstAssetPathConfig.AssetPath131, [3] = ConstAssetPathConfig.AssetPath132, [4] = ConstAssetPathConfig.AssetPath133, [5] = ConstAssetPathConfig.AssetPath134, [6] = ConstAssetPathConfig.AssetPath135, } local EFFECT_ROLL_WAITTING = ConstAssetPathConfig.EFFECT_ROLL_WAITTING function UISyncSoloRoll:OnCreated() self.isAllowRoll = true self.txt_BlueNum.text = nil self.txt_RedNum.text = nil UIUtils.SetActive(self.group_LeftSign, false) UIUtils.SetActive(self.group_RightSign, false) end function UISyncSoloRoll:OnOpened(context) self:RegistSystemEvent(EventID.UI_SyncSolo_NoticeBPInfo, self.OnBPInfoNotice) UIUtils.SetActive(self.group_titleText, true) self.bpInfo = MDL.FairPlay.GetBpRoomInfo(LuaConst.ActivityType.SyncSolo) self:UpdatePlayerData() UIUtils.SetActive(self.img_Icon, false) self.effect_Dice:PlayUIEffect(EFFECT_ROLL_WAITTING, -1) local rollCfgTime = DataSheetManager.FairMatchRule1V1:GetDataByID(LuaConst.ActivityType.SyncSolo).DiceTime if self.bpInfo.curStage == MDL.FairPlay.BanPickStageEnum.Begin then local rollTime = self.bpInfo.nextStageTime - self.bpInfo.serverTime rollTime = rollTime > rollCfgTime and rollCfgTime or rollTime self.group_CountDown:ResetAndBeginTimer(false, rollTime) end UIUtils.SetLabelText(self.txt_LeftSign, Const_IDS.IDS_FairPlay_IVITips2) UIUtils.SetActive(self.group_Remind, false) end function UISyncSoloRoll:UpdatePlayerData() self:SetPlayerInfo(self.group_InfoBlue, self.bpInfo.ownTeamPlayerInfo[1]) self:SetPlayerInfo(self.group_InfoRed, self.bpInfo.enemyTeamPlayerInfo[1]) end function UISyncSoloRoll:OnBPInfoNotice() self.bpInfo = MDL.FairPlay.GetBpRoomInfo(LuaConst.ActivityType.SyncSolo) local leftRollNum = self.bpInfo.ownTeamPlayerInfo[1].Dice local rightRollNum = self.bpInfo.enemyTeamPlayerInfo[1].Dice self.isAllowRoll = leftRollNum == 0 self:UpdateRollState(self.group_InfoBlue.txt_RollInfo, self.txt_BlueNum, leftRollNum) self:UpdateRollState(self.group_InfoRed.txt_RollInfo, self.txt_RedNum, rightRollNum) if leftRollNum > 0 then UIUtils.SetActive(self.img_Icon, true) UIUtils.SetImageByAssetBundle(self.img_Icon, IMAGE_ROLL[leftRollNum]) end local isAllRoll = leftRollNum > 0 and rightRollNum > 0 if isAllRoll then UIUtils.SetActive(self.group_LeftSign, true) UIUtils.SetActive(self.group_RightSign, true) if leftRollNum > rightRollNum then UIUtils.SetLabelText(self.txt_LeftSign, Const_IDS.IDS_FairTournament_FirstBan) UIUtils.SetLabelText(self.txt_RightSign, Const_IDS.IDS_FairTournament_SecondBan) else UIUtils.SetLabelText(self.txt_LeftSign, Const_IDS.IDS_FairTournament_SecondBan) UIUtils.SetLabelText(self.txt_RightSign, Const_IDS.IDS_FairTournament_FirstBan) end self.effect_Dice:StopUIEffect() end end function UISyncSoloRoll:UpdateRollState(txt_RollInfo, txt_RollNum, rollNum) if rollNum > 0 then txt_RollNum.text = rollNum UIUtils.SetLabelText(txt_RollInfo, Const_IDS.IDS_FairTournament_DiceUsed) else txt_RollNum.text = nil UIUtils.SetLabelText(txt_RollInfo, Const_IDS.IDS_FairTournament_WaitDice) end end function UISyncSoloRoll:SetPlayerInfo(comp, showInfo) if showInfo then CTL.Character.SetPortraitAndFrame(comp.UIHeroHead, showInfo.PortraitId, showInfo.FrameId) comp.txt_Name.text = showInfo.name UIUtils.SetLabel(comp.txt_Server, CTL.CrossServer.GetServerShowStr(showInfo.ShowServerId)) UIUtils.SetLabel(comp.txt_GuildName, showInfo.guildName) end end function UISyncSoloRoll:OnButtonClicked(comp) if comp == self.btn_Roll then if self.isAllowRoll == false then return end self.effect_Dice:StopUIEffect() MDL.FairPlay.BanPickHeroOptReq(LuaConst.ActivityType.SyncSolo, MDL.FairPlay.BanPickHeroOptType.Roll, self.bpInfo.ownTeamPlayerInfo[1].acid) self.isAllowRoll = false end end return UISyncSoloRoll