require("Base/BasePanel") local ATMMyGuessHistoryPopup = Inherit(BasePanel) local this = ATMMyGuessHistoryPopup local _PlayerHeadList = {} local resultIcon = { [-1] = {resPath = "r_gonghui_zhan"}, [0] = {resPath = "UI_effect_JJC_JieSuan_ShiBai_png_zh"}, [1] = {resPath = "UI_effect_JJC_JieSuan_ShengLi_png_zh"}, } local stateConfig = { [0] = {name = Language[10118], color = UIColor.GRAY}, [1] = {name = Language[10127], color = UIColor.WRITE}, [2] = {name = Language[10108], color = UIColor.GREEN}, [3] = {name = Language[10107], color = UIColor.RED}, } local GUESS_COIN = ArenaTopMatchManager.GetGuessCoinID() --初始化组件(用于子类重写) function ATMMyGuessHistoryPopup:InitComponent() this.spLoader = SpriteLoader.New() this.btnBack = Util.GetGameObject(self.transform, "btnBack") this.title = Util.GetGameObject(self.transform, "Title"):GetComponent("Text") this.commonPanel = Util.GetGameObject(self.transform, "content/Common") this.rankPanel = Util.GetGameObject(self.transform, "content/Rank") this.emptyPanel = Util.GetGameObject(self.transform, "content/Empty") this.emptyText = Util.GetGameObject(self.transform, "content/Empty/Image/Text"):GetComponent("Text") this.scrollRoot = Util.GetGameObject(self.transform, "content/Common/scrollpos") this.recordPre = Util.GetGameObject(this.scrollRoot, "guess") local rootWidth = this.scrollRoot.transform.rect.width local rootHeight = this.scrollRoot.transform.rect.height this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scrollRoot.transform, this.recordPre, nil, Vector2.New(rootWidth, rootHeight), 1, 1, Vector2.New(0,0)) this.ScrollView.moveTween.Strength = 2 end --绑定事件(用于子类重写) function ATMMyGuessHistoryPopup:BindEvent() Util.AddClick(this.btnBack, function () self:ClosePanel() end) end --添加事件监听(用于子类重写) function ATMMyGuessHistoryPopup:AddListener() end --移除事件监听(用于子类重写) function ATMMyGuessHistoryPopup:RemoveListener() end --界面打开时调用(用于子类重写) function ATMMyGuessHistoryPopup:OnOpen(...) -- 请求数据 local dataList = ArenaTopMatchManager.GetBetHistory() if #dataList == 0 then this.emptyPanel:SetActive(true) this.commonPanel:SetActive(false) this.emptyText.text = Language[10128] else this.emptyPanel:SetActive(false) this.commonPanel:SetActive(true) -- 设置数据 this.ScrollView:SetData(dataList, function (index, go) this.RefreshData(go, dataList[index]) end) end this.title.text = Language[10129] this.rankPanel:SetActive(false) end function this.RefreshData(go, itemData) --- 基础信息 local head = {} head[1] = Util.GetGameObject(go, "head_1") head[2] = Util.GetGameObject(go, "head_2") local blueName = Util.GetGameObject(go, "name_1"):GetComponent("Text") local redName = Util.GetGameObject(go, "name_2"):GetComponent("Text") local zhan = Util.GetGameObject(go, "zhan") local bai = Util.GetGameObject(go, "bai") Util.GetGameObject(go, "bai/Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_effect_JJC_JieSuan_ShiBai_png_zh")--UI_effect_jiesuan_bai01_zh") local shengOrBaiParent1 = Util.GetGameObject(go, "shengOrBaiParent1") local shengOrBaiParent2 = Util.GetGameObject(go, "shengOrBaiParent2") local sheng = Util.GetGameObject(go, "sheng") Util.GetGameObject(go, "sheng/Image"):GetComponent("Image").sprite = this.spLoader:LoadSprite("UI_effect_jiesuan_shengli02_zh") local state = Util.GetGameObject(go, "state"):GetComponent("Text") local betNum = Util.GetGameObject(go, "betNum"):GetComponent("Text") local getNum = Util.GetGameObject(go, "getNum"):GetComponent("Text") local match = Util.GetGameObject(go, "match"):GetComponent("Text") local battleInfo = itemData.enemyPairInfo local personInfo = { [1] = battleInfo.blueEnemy.personInfo, [2] = battleInfo.redEnemy.personInfo, } blueName.text = personInfo[1].name redName.text = personInfo[2].name match.text = ArenaTopMatchManager.GetTurnNameByRoundTimes(battleInfo.roundTimes) LogPink("battleInfo.roundTimes "..battleInfo.roundTimes.." "..ArenaTopMatchManager.GetTurnNameByRoundTimes(battleInfo.roundTimes)) zhan:SetActive(true)--battleInfo.fightResult == -1 bai:SetActive(battleInfo.fightResult ~= -1)--battleInfo.fightResult == 0 sheng:SetActive(battleInfo.fightResult ~= -1)--battleInfo.fightResult == 1 local betResult = tonumber(itemData.betResult) local personInfo1uid = tonumber(personInfo[1].uid) local personInfo2uid = tonumber(personInfo[2].uid) -- LogBlue("battleInfo.fightResult "..battleInfo.fightResult.." itemData.betResult "..itemData.betResult) -- LogBlue("personInfo1uid "..personInfo1uid.." personInfo2uid "..personInfo2uid.." itemData.myWinCoins "..itemData.myWinCoins) if betResult > 1 and betResult ==personInfo1uid then if itemData.myWinCoins > 0 then sheng.transform:SetParent(shengOrBaiParent1.transform) bai.transform:SetParent(shengOrBaiParent2.transform) else sheng.transform:SetParent(shengOrBaiParent2.transform) bai.transform:SetParent(shengOrBaiParent1.transform) end elseif betResult > 1 and betResult == personInfo2uid then if itemData.myWinCoins > 0 then sheng.transform:SetParent(shengOrBaiParent2.transform) bai.transform:SetParent(shengOrBaiParent1.transform) else sheng.transform:SetParent(shengOrBaiParent1.transform) bai.transform:SetParent(shengOrBaiParent2.transform) end end sheng.transform.localPosition = Vector3.zero bai.transform.localPosition = Vector3.zero local index = betResult if betResult > 1 then if itemData.myWinCoins > 0 then index = 2 else index = 3 end end --LogGreen("index "..index) local config = stateConfig[index] state.text = config.name state.color = config.color -- 竞猜币 betNum.text = itemData.myBetCoins getNum.text = (index == 1 or index == 0) and Language[10122] or itemData.myWinCoins -- 头像 if not _PlayerHeadList[go] then _PlayerHeadList[go] = {} end for i = 1, 2 do if not _PlayerHeadList[go][i] then _PlayerHeadList[go][i] = SubUIManager.Open(SubUIConfig.PlayerHeadView, head[i].transform) end _PlayerHeadList[go][i]:Reset() _PlayerHeadList[go][i]:SetScale(Vector3.one * 0.7) _PlayerHeadList[go][i]:SetHead(personInfo[i].head) _PlayerHeadList[go][i]:SetFrame(personInfo[i].headFrame) _PlayerHeadList[go][i]:SetLayer(this.sortingOrder) _PlayerHeadList[go][i]:SetEffectScale(0.8) end -- 给回放按钮添加事件 local replay = Util.GetGameObject(go, "btn1") replay:SetActive(itemData.enemyPairInfo.fightResult ~= -1) Util.AddOnceClick(replay, function() ArenaTopMatchManager.RequestRecordFightData(itemData.enemyPairInfo.fightResult, itemData.enemyPairInfo.id, personInfo[1].name.."|"..personInfo[2].name, function() this:ClosePanel() --构建显示结果数据 local arg = {} arg.panelType = 1 arg.result = itemData.enemyPairInfo.fightResult arg.blue = {} arg.blue.uid = personInfo[1].uid arg.blue.name = personInfo[1].name arg.blue.head = personInfo[1].head arg.blue.frame = personInfo[1].headFrame arg.red = {} arg.red.uid = personInfo[2].uid arg.red.name = personInfo[2].name arg.red.head = personInfo[2].head arg.red.frame = personInfo[2].headFrame UIManager.OpenPanel(UIName.ArenaResultPopup, arg) end) end) end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function ATMMyGuessHistoryPopup:OnShow() end --界面关闭时调用(用于子类重写) function ATMMyGuessHistoryPopup:OnClose() end --界面销毁时调用(用于子类重写) function ATMMyGuessHistoryPopup:OnDestroy() this.spLoader:Destroy() for _, headList in pairs(_PlayerHeadList) do for _, playerHead in ipairs(headList) do playerHead:Recycle() end end _PlayerHeadList = {} this.ScrollView = nil end return ATMMyGuessHistoryPopup