local PracticeImprint = quick_class("PracticeImprint", BasePanel) local orginLayer local curImprintData={} function PracticeImprint:InitComponent() self.backBtn = Util.GetGameObject(self.gameObject, "backBtn") self.Scroll = Util.GetGameObject(self.gameObject, "Scroll") self.ImprintPre = Util.GetGameObject(self.gameObject, "ImprintPre") self.ImprintInfo = Util.GetGameObject(self.gameObject, "ImprintInfo") self.ImprintInfoBack = Util.GetGameObject(self.ImprintInfo, "close") self.leftInfo = Util.GetGameObject(self.ImprintInfo, "Content/Layout/Left") self.leftTitle = Util.GetGameObject(self.leftInfo, "Title/Text"):GetComponent("Text") self.leftDetail = Util.GetGameObject(self.leftInfo, "TextArena/Text"):GetComponent("Text") self.rightInfo = Util.GetGameObject(self.ImprintInfo, "Content/Layout/Right") self.tightTitle = Util.GetGameObject(self.rightInfo, "Title/Text"):GetComponent("Text") self.Add = Util.GetGameObject(self.rightInfo, "AddBtn") self.Hero = Util.GetGameObject(self.rightInfo, "Hero") self.itemPre = Util.GetGameObject(self.Hero, "itemPre") self.MaskBtn = Util.GetGameObject(self.rightInfo, "mask") self.doBtn = Util.GetGameObject(self.ImprintInfo, "Content/Btn") self.doBtnText = Util.GetGameObject(self.doBtn, "Text"):GetComponent("Text") local rootHight = self.Scroll.transform.rect.height local width = self.Scroll.transform.rect.width self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.Scroll.transform, self.ImprintPre, nil,Vector2.New(width, rootHight), 1, 1,Vector2.New(15, 0)) self.ScrollView.moveTween.MomentumAmount = 1 self.ScrollView.moveTween.Strength = 2 end function PracticeImprint:BindEvent() Util.AddClick(self.backBtn, function() self:ClosePanel() end) Util.AddClick(self.ImprintInfoBack, function() self.ImprintInfo:SetActive(false) end) end function PracticeImprint:AddListener() end function PracticeImprint:RemoveListener() end --待功能扩展(试图打开某个状态) function PracticeImprint:OnOpen() end function PracticeImprint:OnSortingOrderChange() end function PracticeImprint:OnShow() self:Refresh(true,false) end function PracticeImprint:Refresh(isTop,isAni,func) self.allImprintData = PracticeManager.GetAllImprintData() self.ImprintInfo:SetActive(false) self.ScrollView:SetData(self.allImprintData, function(index, go) self:SetPre(index,go,self.allImprintData[index]) end,isTop,isAni) if func then func() end end --设置每一期的三个神印 function PracticeImprint:SetPre(index,_go,_data) local title = Util.GetGameObject(_go, "title/Text"):GetComponent("Text") title.text = string.format("%s期",_data.RealmName) for i = 1, 3 do local Imprint = Util.GetGameObject(_go, "Content/Imprint"..i) self:SetSingleImprint(Imprint,_data.TeamSkill[i]) end end --设置单个神印信息 function PracticeImprint:SetSingleImprint(_go,_imprintId) local serverData,configData = PracticeManager.GetSingleImprintData(_imprintId)--获取神印信息 local maskBtn = Util.GetGameObject(_go, "mask") local stateImg = Util.GetGameObject(_go, "state"):GetComponent("Image") local heroImg = Util.GetGameObject(_go, "hero"):GetComponent("Image") local icon = Util.GetGameObject(_go, "icon"):GetComponent("Image") if not serverData then--未解锁 stateImg.gameObject:SetActive(true) stateImg.sprite = Util.LoadSprite("r_Dungeon_lockon") heroImg.gameObject:SetActive(false) else--已解锁 -- LogGreen(" _imprintId:"..tostring(_imprintId).." serverData.state:"..tostring(serverData.state)) if serverData.state == 0 then--未使用 stateImg.gameObject:SetActive(false) -- heroImg.gameObject:SetActive(false) elseif serverData.state == 1 then--已使用 stateImg.gameObject:SetActive(true) stateImg.sprite = Util.LoadSprite("t_tianshumijuan_yijihuo_zh") end heroImg.gameObject:SetActive(serverData.subId ~= nil and serverData.subId ~= "" and serverData.subId ~= "nil") if serverData.subId ~= nil and serverData.subId ~= "" and serverData.subId ~= "nil" then -- LogRed("serverData.subId:"..tostring(serverData.subId)) -- LogGreen(HeroManager.GetSingleHeroData(tostring(serverData.subId)).id) heroImg.sprite = Util.LoadSprite(GetSpriteNameByItemId(HeroManager.GetSingleHeroData(tostring(serverData.subId)).id)) end end icon.sprite = Util.LoadSprite(GetResourcePath(configData.Icon)) Util.AddOnceClick(maskBtn,function () self.ImprintInfo:SetActive(true) self:ShowSingleImprintInfoLayout(serverData,configData) end) end --设置下方神印信息界面 function PracticeImprint:ShowSingleImprintInfoLayout(_serverData,_configData) --title显示 if _configData.Type == 0 then self.leftTitle.text = string.format("通用神印·%s",_configData.Name) elseif _configData.Type == 1 then self.leftTitle.text = string.format("附身神印·%s",_configData.Name) end --右侧部分状态和按钮显示 if not _serverData then self.rightInfo:SetActive(false) self.doBtnText.text = string.format("%s解锁",_configData.Unlock) else if _configData.Type == 0 then self.rightInfo:SetActive(false) elseif _configData.Type == 1 then self.rightInfo:SetActive(true) end if _serverData.state == 0 then self.doBtnText.text = "选择神印" elseif _serverData.state == 1 then self.doBtnText.text = "取消神印" end end --详情 self.leftDetail.text = _configData.Desc --神印确认/取消按钮 Util.AddOnceClick(self.doBtn,function () if _serverData ~= nil then local old,new,sub = 0,0,"" old = PracticeManager.BigLevelImprintList[_configData.UnlockId] new = _configData.Id if _configData.Type == 0 then sub = "" elseif _configData.Type == 1 then sub = _serverData.subId--self.curHeroId if _serverData.subId == "" or _serverData.subId == "nil" or not _serverData.subId then PopupTipPanel.ShowTip("请先选择附身神将!") return end end NetManager.PracticeImprintRequest(old,new,tostring(sub),function () self:Refresh(true,true,function () self.ImprintInfo:SetActive(true) self:ShowSingleImprintInfoLayout(PracticeManager.GetSingleImprintData(new)) end) end) end end) --英雄图标 local heroData local frame = Util.GetGameObject(self.itemPre, "frame"):GetComponent("Image") local icon = Util.GetGameObject(self.itemPre, "icon"):GetComponent("Image") local lv = Util.GetGameObject(self.itemPre, "lv/Text"):GetComponent("Text") local proIcon = Util.GetGameObject(self.itemPre, "proIcon"):GetComponent("Image") local starGrid = Util.GetGameObject(self.itemPre, "star") local starPre = Util.GetGameObject(self.itemPre, "starPre") --如果神印已开启且是附身神印 if _serverData and _configData.Type == 1 then self.Add:SetActive(true) self.Hero:SetActive(false) if _serverData.subId ~= nil and _serverData.subId ~= "" and _serverData.subId ~= "nil" then self.Add:SetActive(false) self.Hero:SetActive(true) --英雄图标 heroData = HeroManager.GetSingleHeroData(tostring(_serverData.subId)) frame.sprite = Util.LoadSprite(GetHeroQuantityImageByquality(heroData.heroConfig.Quality,heroData.star)) icon.sprite = Util.LoadSprite(heroData.icon) lv.text = heroData.lv proIcon.sprite = Util.LoadSprite(GetProStrImageByProNum(heroData.heroConfig.PropertyName)) SetHeroStars(starGrid, heroData.star) end Util.AddOnceClick(self.MaskBtn,function() UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.XiuXingSelectHero,_configData,function (_heroData) NetManager.PracticeImprintRequest(_configData.Id,_configData.Id,tostring(_heroData.dynamicId),function () frame.sprite = Util.LoadSprite(GetHeroQuantityImageByquality(_heroData.heroConfig.Quality,_heroData.star)) icon.sprite = Util.LoadSprite(_heroData.icon) lv.text = _heroData.lv proIcon.sprite = Util.LoadSprite(GetProStrImageByProNum(_heroData.heroConfig.PropertyName)) SetHeroStars(starGrid, _heroData.star) --刷新 self:Refresh(true,true,function () self.ImprintInfo:SetActive(true) self:ShowSingleImprintInfoLayout(PracticeManager.GetSingleImprintData(_configData.Id)) end) end) end) end) end --神将选择 end function PracticeImprint:OnClose() end function PracticeImprint:OnDestroy() end return PracticeImprint