local UIFairSoloTournamentRoll = 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 UIFairSoloTournamentRoll: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 UIFairSoloTournamentRoll:OnOpened(context) self:RegistSystemEvent(EventID.UI_FairSoloTournament_NoticeBPInfo, self.OnBPInfoNotice) self:RegistSystemEvent(EventID.UI_FairSoloTournament_RefreshPlayerInfo, self.UpdatePlayerData) MDL.FairSoloTournament.C2GFairTournamentBP(context.groupId, false) if MDL.FairSoloTournament.GetPlayerShowInfo(self.context.leftAcid) == nil or MDL.FairSoloTournament.GetPlayerShowInfo(self.context.rightAcid) == nil then MDL.FairSoloTournament.TryFairTournamentGetAllPlayerInfoReq(true) else self:UpdatePlayerData() end local matchTimeCfg = DataSheetManager.FairMatchTime:GetDataByID(MDL.FairSoloTournament.GetCurMatchTimeID()) if context.rollTime > matchTimeCfg.DiceShowTime then local rollTime = context.rollTime - matchTimeCfg.DiceShowTime self.group_CountDown:ResetAndBeginTimer(false, rollTime) else self.group_CountDown:EndTimer() end UIUtils.SetLabelText(self.txt_LeftSign, Const_IDS.IDS_FairTournament_ClickDice) UIUtils.SetActive(self.group_titleText, false) UIUtils.SetActive(self.group_Remind, true) end function UIFairSoloTournamentRoll:UpdatePlayerData() local leftInfo = MDL.FairSoloTournament.GetPlayerShowInfo(self.context.leftAcid) self:SetPlayerInfo(self.group_InfoBlue, leftInfo) local rightInfo = MDL.FairSoloTournament.GetPlayerShowInfo(self.context.rightAcid) self:SetPlayerInfo(self.group_InfoRed, rightInfo) end function UIFairSoloTournamentRoll:OnBPInfoNotice(bpInfo) local leftRollNum = 0 local rightRollNum = 0 for i, v in ipairs(bpInfo) do if v.Acid == self.context.leftAcid then leftRollNum = v.Dice elseif v.Acid == self.context.rightAcid then rightRollNum = v.Dice end end 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) local isAllRoll = leftRollNum > 0 and rightRollNum > 0 if isAllRoll then UIUtils.SetActive(self.group_LeftSign, true) UIUtils.SetActive(self.group_RightSign, true) --两个都roll了才能决定先后手 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() UIUtils.SetActive(self.img_Icon, true) UIUtils.SetImageByAssetBundle(self.img_Icon, IMAGE_ROLL[leftRollNum]) end end function UIFairSoloTournamentRoll: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 UIFairSoloTournamentRoll: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 UIFairSoloTournamentRoll:OnButtonClicked(comp) if comp == self.btn_Roll then if self.isAllowRoll == false then return end UIUtils.SetActive(self.img_Icon, false) self.effect_Dice:PlayUIEffect(EFFECT_ROLL_WAITTING, -1) MDL.FairSoloTournament.C2GFairTournamentBP(self.context.groupId, true) --只能掷一次骰子 self.isAllowRoll = false end end return UIFairSoloTournamentRoll