local UITeamFairChampionshipRoll = 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 UITeamFairChampionshipRoll: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) self.leftShowInfo = nil self.rightShowInfo = nil end function UITeamFairChampionshipRoll:OnOpened(context) self:RegistSystemEvent(EventID.UI_TeamFairChampionship_NoticeBPHeroInfo, self.OnBPStateRefresh) self:UpdatePlayerData() self:UpdateRollTime() end function UITeamFairChampionshipRoll:UpdatePlayerData() local curBattleMatchGroup = MDL.TeamFairChampionship.GetCurBattleMatchGroup() if curBattleMatchGroup.teamInfos[1].teamId == self.context.leftAcid then self.leftShowInfo = curBattleMatchGroup.teamInfos[1] self.rightShowInfo = curBattleMatchGroup.teamInfos[2] else self.leftShowInfo = curBattleMatchGroup.teamInfos[2] self.rightShowInfo = curBattleMatchGroup.teamInfos[1] end self:SetMatchTeamInfo(self.group_InfoBlue, self.leftShowInfo) self:SetMatchTeamInfo(self.group_InfoRed, self.rightShowInfo) end function UITeamFairChampionshipRoll:SetMatchTeamInfo(comp, teamInfo) UIUtils.SetLabel(comp.txt_TeamName, teamInfo.teamName) end function UITeamFairChampionshipRoll:UpdateRollTime() local rollLeftTime = self.context.stateData.fightTimeList.diceTime-UTL.Time.GetServerTimestamp() if rollLeftTime>0 then self.group_CountDown:ResetAndBeginTimer(false, rollLeftTime) else self.group_CountDown:EndTimer() end end function UITeamFairChampionshipRoll:OnBPStateRefresh(bpInfo) local leftRollNum = 0 local rightRollNum = 0 for i, v in ipairs(bpInfo) do if v.TeamId == self.context.leftAcid then leftRollNum = v.Dice else 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 UITeamFairChampionshipRoll: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 UITeamFairChampionshipRoll:OnButtonClicked(comp) if comp == self.btn_Roll then if self.isAllowRoll == false then return end if not MDL.SpecialTeam.IsSelfLeader() then return false end UIUtils.SetActive(self.img_Icon, false) self.effect_Dice:PlayUIEffect(EFFECT_ROLL_WAITTING, -1) MDL.TeamFairChampionship.C2GTeamFairBP(true) --只能掷一次骰子 self.isAllowRoll = false end end return UITeamFairChampionshipRoll