require("Base/BasePanel") FormationCenterUpPanel = Inherit(BasePanel) local this = FormationCenterUpPanel local investigateConfig = ConfigManager.GetConfig(ConfigName.InvestigateConfig) local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig) local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig) local titleImage = { [1] = {"X1_shiyanshi_biaoti", GetPictureFont("X1_shiyanshi_shengxingchenggong")},--升星成功 [2] = {"X1_bt_qimingxing_bg_shibai", GetPictureFont("X1_bt_qimingxing_bg_08")},--升星失败 [3] = {"X1_shiyanshi_biaoti", GetPictureFont("X1_bt_qimingxing_bg_09")},--改造成功 } local openType local curLv local lastLv local proList = {} --初始化组件(用于子类重写) function FormationCenterUpPanel:InitComponent() this.btnBack = Util.GetGameObject(self.gameObject, "btnBack") this.titleBg = Util.GetGameObject(self.gameObject, "ScrollView/bg/title/Image"):GetComponent("Image") this.title = Util.GetGameObject(self.gameObject, "ScrollView/bg/title/title"):GetComponent("Image") this.star = Util.GetGameObject(self.gameObject, "ScrollView/star") this.Item = Util.GetGameObject(self.gameObject, "ScrollView/Item") this.proContent = Util.GetGameObject(self.gameObject, "ScrollView/proContent") this.proItem = Util.GetGameObject(self.gameObject, "ScrollView/proPrefab") this.everyday = Util.GetGameObject(self.gameObject, "ScrollView/everyday") --升星失败 this.fail = Util.GetGameObject(self.gameObject, "ScrollView/fail") this.failLeft = Util.GetGameObject(self.gameObject, "ScrollView/fail/left") this.failRight = Util.GetGameObject(self.gameObject, "ScrollView/fail/right") this.failPro = Util.GetGameObject(self.gameObject, "ScrollView/fail/left/grid/proPrefab") end --绑定事件(用于子类重写) function FormationCenterUpPanel:BindEvent() Util.AddClick(this.btnBack,function () self:ClosePanel() end) end --添加事件监听(用于子类重写) function FormationCenterUpPanel:AddListener() end --移除事件监听(用于子类重写) function FormationCenterUpPanel:RemoveListener() end --界面打开时调用(用于子类重写) function FormationCenterUpPanel:OnOpen(type, lv) openType = type curLv = FormationCenterManager.GetInvestigateLevel() lastLv = lv this.titleBg.sprite = Util.LoadSprite(titleImage[openType][1]) this.title.sprite = Util.LoadSprite(titleImage[openType][2]) end function FormationCenterUpPanel:OnShow() this.fail:SetActive(openType == 2) this.Item:SetActive(openType == 3) this.star:SetActive(openType == 1) this.proContent:SetActive(openType == 1 or openType == 3) this.everyday:SetActive(openType == 1) for i = 1, #proList do proList[i]:SetActive(false) end if openType == 1 then SetHeroStars(this.star, investigateConfig[curLv].StarShow, 2) this.SetPro(this.proItem, this.proContent, investigateConfig[curLv]) this.SetReward(this.everyday, investigateConfig[curLv]) elseif openType == 2 then this.SetFailPro(this.failLeft, lastLv) this.SetFailPro(this.failRight, curLv) elseif openType == 3 then this.SetPro(this.proItem, this.proContent, investigateConfig[curLv]) this.SetRemake() end end --界面关闭时调用(用于子类重写) function FormationCenterUpPanel:OnClose() end --界面销毁时调用(用于子类重写) function FormationCenterUpPanel:OnDestroy() proList = {} end function this.SetFailPro(go, lv) local icon = Util.GetGameObject(go, "icon"):GetComponent("Image") local name = Util.GetGameObject(go, "name"):GetComponent("Text") local grid = Util.GetGameObject(go, "grid") local reward = Util.GetGameObject(go, "reward") icon.sprite = Util.LoadSprite(GetResourcePath(investigateConfig[lv].ArtResourcesId)) name.text = GetLanguageStrById(investigateConfig[lv].Name) this.SetPro(this.failPro, grid, investigateConfig[lv]) this.SetReward(reward, investigateConfig[lv]) end function this.SetPro(pre, parent, data) if not proList[parent] then proList[parent] = {} end for i = 1, #proList[parent] do proList[parent][i]:SetActive(false) end for i = 1, #data.PropertyAdd do if not proList[parent][i] then proList[parent][i] = newObjToParent(pre, parent.transform) end local go = proList[parent][i] local name = Util.GetGameObject(go,"name"):GetComponent("Text") local value = Util.GetGameObject(go,"value"):GetComponent("Text") name.text = GetLanguageStrById(propertyConfig[data.PropertyAdd[i][1]].Info) value.text = "+"..GetPropertyFormatStr(propertyConfig[data.PropertyAdd[i][1]].Style, data.PropertyAdd[i][2]) go:GetComponent("Image").sprite = Util.LoadSprite(propertyConfig[data.PropertyAdd[i][1]].Icon) go:SetActive(true) end end function this.SetReward(go, data) local itemConfig = itemConfig[data.DailyReward[1][1]] Util.GetGameObject(go, "frame"):GetComponent("Image").sprite = Util.LoadSprite(GetQuantityImageByquality(itemConfig.Quantity)) Util.GetGameObject(go, "frame/icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(itemConfig.ResourceID)) Util.GetGameObject(go, "frame/value"):GetComponent("Text").text = data.DailyReward[1][2] end function this.SetRemake() local icon = Util.GetGameObject(this.Item, "icon"):GetComponent("Image") local name = Util.GetGameObject(this.Item, "name"):GetComponent("Text") icon.sprite = Util.LoadSprite(GetResourcePath(investigateConfig[curLv].ArtResourcesIconId)) name.text = GetLanguageStrById(investigateConfig[curLv].DescType).." "..GetLanguageStrById(investigateConfig[curLv].DescTypeNum) end return FormationCenterUpPanel