require("Base/BasePanel") RewardGemSingleShowPopup = Inherit(BasePanel) local this = RewardGemSingleShowPopup local JumpConfig = ConfigManager.GetConfig(ConfigName.JumpConfig) local RechargeCommodityConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig) local gemConfig = ConfigManager.GetConfig(ConfigName.GemConfigNew) local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) local itemSid local itemData local itemConfigData local func local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) --初始化组件(用于子类重写) function RewardGemSingleShowPopup:InitComponent() this.spLoader = SpriteLoader.New() this.BtnBack = Util.GetGameObject(self.transform, "bg/btnBack") this.mask = Util.GetGameObject(self.transform, "mask") this.topBar = Util.GetGameObject(self.transform, "bg/topBar") self.topBarBg = Util.GetGameObject(self.transform, "bg/topBar/bg2") self.topBarBgColor = Util.GetGameObject(self.transform, "bg/topBar/bg1"):GetComponent("Image") this.itemPos = Util.GetGameObject(self.transform, "bg/topBar/armor/itemPos") this.itemView = SubUIManager.Open(SubUIConfig.ItemView, this.itemPos.transform) this.armorType = Util.GetGameObject(self.transform, "bg/topBar/armor/info/armorType"):GetComponent("Text") this.armorLanTuNum = Util.GetGameObject(self.transform, "bg/topBar/armor/info/armorLanTuNum"):GetComponent("Text") this.effectbaijin = Util.GetGameObject(self.topBar, "fx_zhuangbeijiemian") this.info = Util.GetGameObject(self.transform, "bg/topBar/armor/info") this.itemName = Util.GetGameObject(this.info, "name"):GetComponent("Text") this.armorTitle = Util.GetGameObject(this.info, "armorTitle"):GetComponent("Text") this.armorDesc = Util.GetGameObject(this.info, "armorDesc"):GetComponent("Text") this.equipQuaText = Util.GetGameObject(self.transform, "bg/topBar/armor/equipQuaText"):GetComponent("Text") this.armorInfo = Util.GetGameObject(self.transform, "bg/topBar/armorInfo") this.armorInfoText = Util.GetGameObject(self.transform, "bg/topBar/armorInfo"):GetComponent("Text") this.howGet = Util.GetGameObject(self.transform, "bg/midBar/layout1") this.scroll = Util.GetGameObject(self.transform, "bg/midBar/scroll") this.equipProGrid = Util.GetGameObject(self.transform, "bg/midBar/scroll/grid") this.equipProGridCom = Util.GetGameObject(self.transform, "bg/midBar/scroll/grid"):GetComponent( "VerticalLayoutGroup") this.bottomBar = Util.GetGameObject(self.transform, "bg/bottomBar") this.btnSure = Util.GetGameObject(self.transform, "bg/bottomBar/btnSure") this.btnJump = Util.GetGameObject(self.transform, "bg/bottomBar/btnJump") this.jumpRed = Util.GetGameObject(this.btnJump, "RedPoint") this.btnClose = Util.GetGameObject(self.transform, "bg/bottomBar/btnClose") this.closeRed = Util.GetGameObject(this.btnClose, "RedPoint") this.btnUse = Util.GetGameObject(self.transform, "bg/bottomBar/btnUse") this.proGrid = Util.GetGameObject(self.transform, "bg/midBar/GemPro/grid") this.proPre = Util.GetGameObject(this.proGrid, "proName") this.proPre:SetActive(false) this.proList = {} end --绑定事件(用于子类重写) function RewardGemSingleShowPopup:BindEvent() Util.AddClick(this.BtnBack, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout2 = false self:ClosePanel() end) Util.AddClick(this.mask, function() PlaySoundWithoutClick(SoundConfig.Sound_UICancel) PlayerManager.RewardItemSingleShowPopupIsRoleUpStarLayout2 = false self:ClosePanel() end) Util.AddClick(this.btnUse, function() --使用跳转 JumpManager.GoJump(40056) self:ClosePanel() end) Util.AddClick(this.btnClose, function() --替换,穿戴 self:ClosePanel() UIManager.OpenPanel(UIName.GeneralBigPopup, GENERAL_POPUP_TYPE.SelectGem, this.gemType, this.position) end) Util.AddClick(this.btnSure, function() --卸下命石 NetManager.LifeGridChangeRequest(2, this.gemType, this.position, itemSid, function() Game.GlobalEvent:DispatchEvent(GameEvent.Gem.RefreshPanel) self:ClosePanel() end) end) Util.AddClick(this.btnJump, function() --合成 if this.openType == 2 then --命格界面中 UIManager.OpenPanel(UIName.GeneralBigPopup, GENERAL_POPUP_TYPE.GemCompound, itemSid, this.position) self:ClosePanel() elseif this.openType == 1 then --背包中 local num = BagManager.GetTotalItemNum(itemSid) if num / gemConfig[itemSid].UpgradeNum >= 2 then UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.GemMoreCom, itemSid, num) self:ClosePanel() else UIManager.OpenPanel(UIName.GeneralBigPopup, GENERAL_POPUP_TYPE.GemCompound, itemSid, nil) self:ClosePanel() end end end) end --添加事件监听(用于子类重写) function RewardGemSingleShowPopup:AddListener() end --移除事件监听(用于子类重写) function RewardGemSingleShowPopup:RemoveListener() end function RewardGemSingleShowPopup:OnSortingOrderChange() Util.SetParticleSortLayer(this.effectbaijin, self.sortingOrder + 1) end --界面打开时调用(用于子类重写) function RewardGemSingleShowPopup:OnOpen(...) local data = { ... } itemData = data[1] --itemConfigData = ConfigManager.GetConfigData(ConfigName.ItemConfig, itemSid) this.openType = data[2] if data[3] then func = data[3] end if data[4] then this.gemType = data[4] end if data[5] then this.position = data[5] end end function RewardGemSingleShowPopup:OnShow() Log("itemSid:" .. tostring(itemSid)) this.itemName.text = GetLanguageStrById(itemData.config.Name) -- GetStringByEquipQua(itemData.config.Quality, GetLanguageStrById(itemData.config.Name)) --LogError(GetStringByEquipQua(itemConfigData.Quantity, GetLanguageStrById(itemConfigData.Name))) --this.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_"..itemData.itemConfig.Quality) --this.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_4") self.topBarBg:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_" .. itemData.itemConfig .Quality) if itemData.itemConfig.Quality == 1 then self.topBarBgColor.color = Color.New(0.81, 0.81, 0.81, 1) elseif itemData.itemConfig.Quality == 2 then self.topBarBgColor.color = Color.New(0.24, 0.34, 0.21, 1) elseif itemData.itemConfig.Quality == 3 then self.topBarBgColor.color = Color.New(0.22, 0.42, 0.63, 1) elseif itemData.itemConfig.Quality == 4 then self.topBarBgColor.color = Color.New(0.29, 0.14, 0.26, 1) elseif itemData.itemConfig.Quality == 5 then self.topBarBgColor.color = Color.New(0.26, 0.14, 0.06, 1) elseif itemData.itemConfig.Quality == 6 then self.topBarBgColor.color = Color.New(0.25, 0.02, 0.02, 1) elseif itemData.itemConfig.Quality == 7 then self.topBarBgColor.color = Color.New(0.32, 0.32, 0.32, 1) elseif itemData.itemConfig.Quality == 8 then self.topBarBgColor.color = Color.New(0.32, 0.32, 0.32, 1) end this.howGet:SetActive(false) this.scroll:SetActive(false) this.btnClose:SetActive(false) this.btnSure:SetActive(false) this.btnJump:SetActive(false) this.bottomBar:SetActive(false) this.btnUse:SetActive(false) if this.openType == 1 then --背包中打开 this.howGet:SetActive(true) this.scroll:SetActive(true) this.btnJump:SetActive(false) this.bottomBar:SetActive(true) this.btnUse:SetActive(true) elseif this.openType == 2 then --装备命石时打开 this.btnClose:SetActive(true) this.btnSure:SetActive(true) this.btnJump:SetActive(true) this.bottomBar:SetActive(true) if gemConfig[itemSid].Level == 10 then --十级命石不显示合成 this.btnJump:SetActive(false) end elseif this.openType == 3 then --itemview打开 this.howGet:SetActive(true) this.scroll:SetActive(true) this.bottomBar:SetActive(false) end --装备命石时检测红点 this.RedPointCheck() local creatJumpData = function(jumpDataList) local jumpSortData = {} if jumpDataList and #jumpDataList > 0 then for i = 1, #jumpDataList do --为关卡跳转做的排序数据 local jumpData = {} jumpData.id = jumpDataList[i] jumpData.data = JumpConfig[jumpDataList[i]] table.insert(jumpSortData, jumpData) end end return jumpSortData end if this.jumpViewList and #this.jumpViewList > 0 then for i = 1, #this.jumpViewList do SubUIManager.Close(this.jumpViewList[i]) end end this.jumpViewList = {} this.equipQuaText.gameObject:SetActive(true) this.equipQuaText.text = GetQuaStringByEquipQua(itemData.config.Quality) this.armorInfo.gameObject:SetActive(true) this.armorTitle.gameObject:SetActive(false) this.armorDesc.gameObject:SetActive(false) this.armorType.gameObject:SetActive(true) this.armorLanTuNum.text = "" --Language[12192] .. BagManager.GetItemCountById(itemSid) this.armorLanTuNum.gameObject:SetActive(this.openType ~= 2) this.armorType.text = "" --this.getType()--道具类型显示 this.armorInfoText.text = "" --string.gsub(GetLanguageStrById(itemConfigData.ItemDescribe), "\\n", "") this.effectbaijin:SetActive(itemData.config.Quality == 7) Util.SetParticleSortLayer(this.effectbaijin, self.sortingOrder + 1) --显示跳转 local jumpDataList = {} --itemConfigData.Jump local jumpSortData = creatJumpData(jumpDataList) for i = 1, #jumpSortData do -- type 大于 10000为活动 直接显示按钮,如果小于1000 为功能 开启才显示 if jumpSortData[i].id > 0 and (JumpConfig[jumpSortData[i].id].Type >= 10000 or ActTimeCtrlManager.SingleFuncState(JumpConfig[jumpSortData[i].id].Type)) then local tempView = SubUIManager.Open(SubUIConfig.JumpView, this.equipProGrid.transform, jumpSortData[i].id, true, self) if tempView then table.insert(this.jumpViewList, tempView) end end end this.scroll:GetComponent("RectTransform").sizeDelta = Vector2.New(912.8, 600) this.equipProGridCom.spacing = 130 if jumpDataList and #jumpDataList then this.equipProGrid:GetComponent("RectTransform").sizeDelta = Vector2.New(807.7, this.equipProGridCom.spacing * (#jumpDataList)) end this.itemView:OnOpen(true, itemData, 1.1, false, false, false, self.sortingOrder) --设置命石属性 this.SetGemProperty() end function this.RedPointCheck() this.jumpRed:SetActive(false) this.closeRed:SetActive(false) if this.openType == 2 then local numInBag = BagManager.GetTotalItemNum(itemSid) local redPointData = GemManager.GetGemsFromBagByType(gemConfig[itemSid].Type) for key, value in pairs(redPointData) do --红点检测更换 if value.id > itemSid then this.closeRed:SetActive(true) break end end for key, value in pairs(redPointData) do --红点检测合成 if numInBag + 1 >= gemConfig[itemSid].UpgradeNum and gemConfig[itemSid].NextGem > 0 then this.jumpRed:SetActive(true) break end end end end function this.SetGemProperty() local data = itemData.pro for key, value in pairs(this.proList) do value:SetActive(false) end for i = 1, #data do local go = this.proList[i] if not go then go = newObjToParent(this.proPre, this.proGrid) this.proList[i] = go end go:SetActive(true) local str = "" local add = "" if data[i][2] == itemData.config.MaxProperty then add = string.format(" %s", "(Max)") else add = string.format(" %s", "(" .. string.format("%.2f", data[i][2] / itemData.config.MaxProperty * 100) .. "%)") end if PropertyConfig[data[i][1]].Style == 1 then str = string.format("%s+%s", GetLanguageStrById(PropertyConfig[data[i][1]].Info), data[i][2]) elseif PropertyConfig[data[i][1]].Style == 2 then LogError("data[i][2]==============" .. data[i][2]) str = string.format("%s+%s", GetLanguageStrById(PropertyConfig[data[i][1]].Info), data[i][2] / 100) .. "%" end go:GetComponent("Text").text = str .. add end end --获取道具种类 function this.getType() local type = itemConfig[itemSid].ItemBaseType if type == 1 then return Language[11172] .. Language[10256] elseif type == 2 then return Language[11172] .. Language[10228] elseif type == 4 then return Language[11172] .. Language[12193] elseif type == 5 then return Language[11172] .. Language[12194] elseif type == 6 then return Language[11172] .. Language[10452] elseif type == 7 then return Language[11172] .. Language[12195] end end --界面关闭时调用(用于子类重写) function RewardGemSingleShowPopup:OnClose() if this.jumpViewList and #this.jumpViewList > 0 then for i = 1, #this.jumpViewList do SubUIManager.Close(this.jumpViewList[i]) end end this.jumpViewList = {} end --界面销毁时调用(用于子类重写) function RewardGemSingleShowPopup:OnDestroy() SubUIManager.Close(this.itemView) if this.jumpViewList and #this.jumpViewList > 0 then for i = 1, #this.jumpViewList do SubUIManager.Close(this.jumpViewList[i]) end end this.jumpViewList = {} this.proList = {} this.gemType = nil this.position = nil this.spLoader:Destroy() end function this.WarPowerChange(oldPowerNum, type) -- 设置脏数据 HeroPropManager.SetFuncPropDirty(Func_Prop_Type.PlayerExtra) -- Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnBagShowWarPowerChange, oldPowerNum, type) local newPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) if oldPowerNum ~= newPowerNum then UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2, { oldValue = oldPowerNum, newValue = newPowerNum }) end end return RewardGemSingleShowPopup