local UIGuildBossLoot = UIViewClass() local guild_boss_pb = require('Proto/guild_boss_pb') function UIGuildBossLoot:OnOpened(context) self.isOpen = true self.animationList = {} self.clickTime = {} self:RegistSystemEvent(EventID.UI_GuildBoss_RollRefresh,self.OnRollRefresh) self:RegistSystemEvent(EventID.UI_GuildBoss_Stagefresh, self.SetStage) self:SetLootCount(context.diceNum) for i,v in ipairs(context.rewardStatus) do self.scroll_GuildBossBattle:AddData(v, 0) end self:SetStage() end function UIGuildBossLoot:SetLootCount(count) local countStr if count == 0 then countStr = UTL.Color.FormatRedColor(count) else countStr = UTL.Color.FormatGreenColor(count) end self.txt_Touzi02.text = string.FormatByIdsId(Const_IDS.IDS_GuildBoss_DiceNum ,countStr) end function UIGuildBossLoot:SetStage() local curStateTimeInfo = MDL.GuildBoss.GetCurStateTimeInfo() if curStateTimeInfo.stageOrder >= MDL.GuildBoss.Stage.RollBefore then self.scroll_GuildBossBattle:RefreshCells() end end function UIGuildBossLoot:OnRollRefresh(msg,isSelf) local isUpdateAll = false if isSelf then local isExist = false for i,v in ipairs(self.context.rewardStatus[msg.index + 1].rollInfo) do if BattleDataGetter.GetAcID() == v.acid then if v.rollNum >= msg.num then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GuildBoss_RollPersonalNormal, msg.num)) else if not msg.isMax then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GuildBoss_RollPersonalRecord, msg.num)) end v.rollNum = msg.num end isExist = true end end if not isExist then local info = guild_boss_pb.RollRewardInfo() info.acid = BattleDataGetter.GetAcID() info.rollNum = msg.num info.name = BattleDataGetter.GetPlayerName() table.insert(self.context.rewardStatus[msg.index + 1].rollInfo, info) end self.scroll_GuildBossBattle:UpdateIndex(msg.index) self:SetLootCount(msg.diceNum) if self.context.diceNum > 0 and msg.diceNum == 0 then isUpdateAll = true end self.context.diceNum = msg.diceNum else local isExist = false for i,v in ipairs(self.context.rewardStatus[msg.index + 1].rollInfo) do if msg.acid == v.acid then if v.rollNum < msg.num then v.rollNum = msg.num end isExist = true end end if not isExist then local info = guild_boss_pb.RollRewardInfo() info.acid = msg.acid info.rollNum = msg.num info.name = msg.name table.insert(self.context.rewardStatus[msg.index + 1].rollInfo, info) end end if msg.isMax then self.context.rewardStatus[msg.index + 1].rollMaxNum = msg.num if not isSelf then self.context.rewardStatus[msg.index + 1].ownerAcid = msg.acid else self.context.rewardStatus[msg.index + 1].ownerAcid = BattleDataGetter.GetAcID() CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GuildBoss_RollGuildRecord, msg.num)) end end if isUpdateAll then self.scroll_GuildBossBattle:RefreshCells() else self.scroll_GuildBossBattle:UpdateIndex(msg.index) end end function UIGuildBossLoot:OnButtonClicked(comp) if comp == self.btn_Close then self.closeId = self:PlayUIAnimation("close", true) elseif comp == self.btn_Open then self.openId = self:PlayUIAnimation("open", true) end end function UIGuildBossLoot:OnUIAnimationStoped(id) if self.openId == id then self.btn_Open.gameObject:SetActive(false) else self.btn_Open.gameObject:SetActive(true) end end function UIGuildBossLoot:OnCellInit(scrollRect, index, cellTable, data) local curStateTimeInfo = MDL.GuildBoss.GetCurStateTimeInfo() if curStateTimeInfo.stageOrder == MDL.GuildBoss.Stage.RollBefore then self:SetGongShiCell(cellTable,data) elseif curStateTimeInfo.stageOrder == MDL.GuildBoss.Stage.Roll then self:SetRollCell(cellTable,data,index) else self:SetOverCell(cellTable,data) end UTL.Item.SetItemCell(cellTable.item, data.reward.rewards.ItemId, data.reward.rewards.ItemCount) if data.reward.poolType == MDL.GuildBoss.RewardTag.PuTong then cellTable.obj_State:SetState(0) elseif data.reward.poolType == MDL.GuildBoss.RewardTag.ZhenPin then cellTable.obj_State:SetState(1) elseif data.reward.poolType == MDL.GuildBoss.RewardTag.JiPin then cellTable.obj_State:SetState(2) end end function UIGuildBossLoot:SetGongShiCell(cellTable, data) cellTable.section_Btn_Touzi.gameObject:SetActive(false) cellTable.section_Gongshi.gameObject:SetActive(true) cellTable.section_Guishu.gameObject:SetActive(false) UIUtils.SetLabelText(cellTable.lab_Dianshu_Other,Const_IDS.IDS_GuildBoss_OthersPoints) cellTable.txt_Dianshu_Other.text = 0 cellTable.txt_Dianshu_Mine.text = 0 local curStateTimeInfo = MDL.GuildBoss.GetCurStateTimeInfo() local time = curStateTimeInfo.stageEndTimeStamp - UTL.Time.GetServerTimestamp() cellTable.txt_Gongshi:ResetAndBeginTimer(false, time, 0, 1) end function UIGuildBossLoot:SetRollCell(cellTable, data,index) cellTable.section_Btn_Touzi.gameObject:SetActive(true) cellTable.section_Gongshi.gameObject:SetActive(false) cellTable.section_Guishu.gameObject:SetActive(false) local selfIsRoll = false local otherNum = 0 local selfNum = 0 local otherRoll = nil for i,v in ipairs(data.rollInfo) do if BattleDataGetter.GetAcID() == v.acid then selfNum = v.rollNum selfIsRoll = true end end for i,v in ipairs(data.rollInfo) do if BattleDataGetter.GetAcID() ~= v.acid then if v.rollNum > otherNum then otherRoll = v otherNum = v.rollNum end end end if otherRoll then cellTable.txt_Dianshu_Other.text = otherRoll.rollNum cellTable.lab_Dianshu_Other.text = otherRoll.name else UIUtils.SetLabelText(cellTable.lab_Dianshu_Other,Const_IDS.IDS_GuildBoss_OthersPoints) end if selfNum == 0 and selfNum == otherNum then cellTable.txt_Dianshu_Other.text = UTL.Color.FormatWhiteColor(0) cellTable.txt_Dianshu_Mine.text = UTL.Color.FormatWhiteColor(0) elseif selfNum >= otherNum and data.ownerAcid == BattleDataGetter.GetAcID() then cellTable.txt_Dianshu_Other.text = UTL.Color.FormatWhiteColor(otherNum) cellTable.txt_Dianshu_Mine.text = UTL.Color.FormatTextByColor(UTL.Color.orange, selfNum) else cellTable.txt_Dianshu_Other.text = UTL.Color.FormatTextByColor(UTL.Color.orange, otherNum) cellTable.txt_Dianshu_Mine.text = UTL.Color.FormatWhiteColor(selfNum) end if selfIsRoll then cellTable.lab_Dianji.gameObject:SetActive(false) cellTable.lab_Zaiyici.gameObject:SetActive(true) UIUtils.SetLabelText(cellTable.lab_Zaiyici, Const_IDS.IDS_GuildBoss_ClickOnceMore) else cellTable.lab_Dianji.gameObject:SetActive(true) cellTable.lab_Zaiyici.gameObject:SetActive(false) UIUtils.SetLabelText(cellTable.lab_Dianji, Const_IDS.IDS_GuildBoss_Click) end local curStateTimeInfo = MDL.GuildBoss.GetCurStateTimeInfo() local time = curStateTimeInfo.stageEndTimeStamp - UTL.Time.GetServerTimestamp() if not cellTable.time_Image:IsTimerRunning() then local totalTime = DataSheetManager.GuildBossStage:GetDataByID_Order(1,MDL.GuildBoss.Stage.Roll).StageTriggerTime cellTable.time_Image:ResetAndBeginTimer(false,time,totalTime,0) end if data.rollMaxNum == 100 then self:SetOverCell(cellTable, data) else if self.context.diceNum > 0 then if self.animationList[index] then self:PlayUIAnimation(self.animationList[index]) else self.animationList[index] = self:PlayUIAnimation(ConstAssetPathConfig.Path26,cellTable.image_Touzi.transform) end else if self.animationList[index] then self:StopUIAnimation(self.animationList[index]) self.animationList[index] = nil end end end end function UIGuildBossLoot:SetOverCell(cellTable, data) cellTable.section_Btn_Touzi.gameObject:SetActive(false) cellTable.section_Gongshi.gameObject:SetActive(false) cellTable.section_Guishu.gameObject:SetActive(true) local selfIsMax = false for i,v in ipairs(data.rollInfo) do if v.rollNum == data.rollMaxNum then if data.ownerAcid == BattleDataGetter.GetAcID() then selfIsMax = true end end end if selfIsMax then cellTable.img_Guishu_Wode.gameObject:SetActive(true) cellTable.img_Guishu_Taren.gameObject:SetActive(false) cellTable.img_None.gameObject:SetActive(false) elseif #data.rollInfo == 0 then cellTable.img_Guishu_Wode.gameObject:SetActive(false) cellTable.img_Guishu_Taren.gameObject:SetActive(false) cellTable.img_None.gameObject:SetActive(true) else cellTable.img_Guishu_Wode.gameObject:SetActive(false) cellTable.img_Guishu_Taren.gameObject:SetActive(true) cellTable.img_None.gameObject:SetActive(false) end end function UIGuildBossLoot:OnCellClicked(scrollRect, index, cellTable, target, data) if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.reward.rewards.ItemId) elseif target == cellTable.btn_Touzi then if self.context.diceNum > 0 then if self.clickTime[index] == nil or self.clickTime[index] <= Time.realtimeSinceStartup then MDL.GuildBoss.GuildBossRewardRollReq(index) self.clickTime[index] = Time.realtimeSinceStartup + 1 if self.animationList[index] then self:PauseUIAnimation(self.animationList[index]) end cellTable.image_Touzi:PlayAnim() if self.animationList[index] then self:ResumeUIAnimation(self.animationList[index]) end end else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildBoss_NotEnoughToken) end elseif target == cellTable.btn_More then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildBossBattleRank, data) end end return UIGuildBossLoot