require("Base/BasePanel") local GodWeaponMainPanel = Inherit(BasePanel) local this = GodWeaponMainPanel local PokemonList = {} local PokemonGoList = {} local PokemonGoListRedPoin = {} local PokemonEffectList = {} local EffectConfig = { [5] = {name = "fx_linshousan_di", offset = Vector3.New(-4, -26, 0)}, [6] = {name = "fx_linshousan_zhong", offset = Vector3.New(-4, -26, 0)}, [7] = {name = "fx_linshousan_gao", offset = Vector3.New(-4, -26, 0)}, } local PokemonDataList = {} local live2dList = {} local dragViewListGo={}--dragView预设列表 local pokemonPosLocks = ConfigManager.GetConfigData(ConfigName.ShenBingSetting,1).BlockUnlockLevel local spiritAnimal = ConfigManager.GetConfig(ConfigName.SpiritAnimal) local canUpZhenPokemonList = {} local isClick = true local allProPre={} this.trigger = {} --初始化组件(用于子类重写) function GodWeaponMainPanel:InitComponent() this.spLoader = SpriteLoader.New() this.btnBack = Util.GetGameObject(self.transform, "btnBack") this.btnHelp = Util.GetGameObject(self.transform, "btnhelp") this.btnShop = Util.GetGameObject(self.transform, "btnEndRoot/btnShop/img") Util.GetGameObject(self.transform, "btnEndRoot/btnShop/Text"):GetComponent("Text").text="名刀商店" Util.GetGameObject(self.transform, "btnEndRoot/btnShop/redPoint"):SetActive(false) this.btnFen = Util.GetGameObject(self.transform, "btnEndRoot/btnFen/img") Util.GetGameObject(self.transform, "btnEndRoot/btnFen/Text"):GetComponent("Text").text="名刀分解" this.btnFenRed = Util.GetGameObject(self.transform, "btnEndRoot/btnFen/redPoint") this.btnFenRed:SetActive(false) this.btnHand = Util.GetGameObject(self.transform, "btnEndRoot/btnHand/img") Util.GetGameObject(self.transform, "btnEndRoot/btnHand/Text"):GetComponent("Text").text="名刀图鉴" this.btn_hand_red=Util.GetGameObject(self.transform, "btnEndRoot/btnHand/redPoint") this.btn_he = Util.GetGameObject(self.transform, "btnEndRoot/btnHe/img") Util.GetGameObject(self.transform, "btnEndRoot/btnHe/Text"):GetComponent("Text").text="名刀合成" this.btn_he_red=Util.GetGameObject(self.transform, "btnEndRoot/btnHe/redPoint") this.line = Util.GetGameObject(self.transform,"lineParent/line") this.line:SetActive(false) this.roleGrid=Util.GetGameObject(this.gameObject,"lineParent") for i = 1, 6 do PokemonList[i] = Util.GetGameObject(self.transform, "PokemonList/singlePokemon (".. i ..")/singlePokemon") PokemonGoList[i] = Util.GetGameObject(PokemonList[i], "pokemon".. i) PokemonGoListRedPoin[i] = Util.GetGameObject(PokemonGoList[i], "redPoint") Util.GetGameObject( PokemonGoList[i], "upZhenInfo/titleImage/sortText"):GetComponent("Text").text = i Util.GetGameObject( PokemonGoList[i], "addInfo/addInfo/sortText"):GetComponent("Text").text = i if not dragViewListGo[i] then dragViewListGo[i] = SubUIManager.Open(SubUIConfig.DragView, PokemonList[i].transform) end dragViewListGo[i].gameObject.name="DragView"..i dragViewListGo[i].gameObject:SetActive(false) dragViewListGo[i]:SetScrollMouse(false) this.trigger[i]=Util.GetEventTriggerListener(dragViewListGo[i].gameObject) this.trigger[i].onPointerDown= this.trigger[i].onPointerDown+this.OnPointerDown this.trigger[i].onPointerUp= this.trigger[i].onPointerUp+this.OnPointerUp this.trigger[i].onEndDrag= this.trigger[i].onEndDrag+this.OnEndDrag this.trigger[i].onDrag=this.trigger[i].onDrag+this.OnDrag dragViewListGo[i]:SetDragGO(PokemonGoList[i]) end this.gongTxt=Util.GetGameObject(this.gameObject,"prolist/gong/Text"):GetComponent("Text") this.huTxt=Util.GetGameObject(this.gameObject,"prolist/hu/Text"):GetComponent("Text") this.moTxt=Util.GetGameObject(this.gameObject,"prolist/mo/Text"):GetComponent("Text") this.hpTxt=Util.GetGameObject(this.gameObject,"prolist/hp/Text"):GetComponent("Text") this.root = Util.GetGameObject(this.gameObject,"root") table.insert(allProPre,this.gongTxt) table.insert(allProPre,this.huTxt) table.insert(allProPre,this.moTxt) table.insert(allProPre,this.hpTxt) this.powerValue=Util.GetGameObject(this.gameObject,"powerBtn/value"):GetComponent("Text") -- this.callCount = Util.GetGameObject(self.transform, "callMonsterBtn/Text"):GetComponent("Text") this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft }) end --绑定事件(用于子类重写) function GodWeaponMainPanel:BindEvent() Util.AddClick(this.btnBack, function() this:ClosePanel() end) Util.AddClick(this.btnHelp, function() local pos = this.btnHelp.transform.localPosition UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.GodWeapon, pos.x, pos.y) end) Util.AddClick(this.btnShop, function() JumpManager.GoJump(3007) end) Util.AddClick(this.btnFen, function() UIManager.OpenPanel(UIName.ResolvePanel,4) end) Util.AddClick(this.btnHand, function() UIManager.OpenPanel(UIName.TianShuMiJuan,5) end) Util.AddClick(this.btn_he, function() UIManager.OpenPanel(UIName.GodWeaponListPanel,2) end) end --添加事件监听(用于子类重写) function GodWeaponMainPanel:AddListener() Game.GlobalEvent:AddEvent(GameEvent.Pokemon.PokemonUpZhenRefresh, this.ShowPokemonList) end --移除事件监听(用于子类重写) function GodWeaponMainPanel:RemoveListener() Game.GlobalEvent:RemoveEvent(GameEvent.Pokemon.PokemonUpZhenRefresh, this.ShowPokemonList) end --界面打开时调用(用于子类重写) function GodWeaponMainPanel:OnOpen(...) -- 设置 this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.GodWeapon }) end --界面打开或者重新打开后,界面刷新时调用(用于子类重写) function GodWeaponMainPanel:OnShow() -- local index = 0 -- for key, value in pairs(allPro) do -- index = index + 1 -- local go= allProPre[index] -- if go then -- go.text=GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PropertyConfig,key).Info)..":"..value -- --Util.GetGameObject(go,"proName"):GetComponent("Text").text=GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PropertyConfig,key).Info) -- --Util.GetGameObject(go,"proValue"):GetComponent("Text").text= value -- end -- end this.ShowPokemonList() --PokemonManager.CheckRedPointStatusPokemonMainCityRed() end local nextOpenLockIndex = 0 function this.ShowPokemonList() local allPro=GodWeaponManager.GetPokemonFormationAddPro() local isHave=false if allPro and #allPro>0 then isHave=true end local attack=isHave and allPro[HeroProType.Attack] or 0 local hp= isHave and allPro[HeroProType.Hp] or 0 local PhysicalDefence=isHave and allPro[HeroProType.PhysicalDefence] or 0 local MagicDefence=isHave and allPro[HeroProType.MagicDefence] or 0 this.gongTxt.text="攻击:".. attack this.hpTxt.text="生命:"..hp this.huTxt.text="护甲:".. PhysicalDefence this.moTxt.text="魔抗:".. MagicDefence isClick = true this.line.transform:SetParent(this.roleGrid.transform) this.line.gameObject:SetActive(false) canUpZhenPokemonList = GodWeaponManager.GetCanUpZhenWeapons() nextOpenLockIndex = 0 PokemonDataList = GodWeaponManager.GetAllTeamWeapon() for i = 1, #PokemonList do this.ShowSinglePokemonList(PokemonList[i],PokemonDataList[i],i) end this.powerValue.text=FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL) end function this.SaveFormation() --保存编队 end local orginLayer = 0 function this:OnSortingOrderChange() for _, go in pairs(PokemonEffectList) do Util.AddParticleSortLayer(go, this.sortingOrder - orginLayer) end for _, cvs in pairs(PokemonList) do cvs:GetComponent("Canvas").sortingOrder = this.sortingOrder + 2 end this.btn_he_red:SetActive(GodWeaponManager.WeaponChipCompoundRedPoint()) this.btn_hand_red:SetActive(TianShuMiJuanManger.CheckRedPoint(5)) orginLayer = self.sortingOrder end function this.ShowSinglePokemonList(go,singleData,liveIndex) local goParent = go.transform.parent.gameObject goParent:SetActive(true) local bgQuan = Util.GetGameObject(goParent, "bg/Image (1)") local upZhenInfo = Util.GetGameObject(go, "upZhenInfo") local addInfo = Util.GetGameObject(go, "addInfo") local lockInfo = Util.GetGameObject(go, "lockInfo") upZhenInfo:SetActive(false) addInfo:SetActive(false) lockInfo:SetActive(false) if PokemonEffectList[liveIndex] then destroy(PokemonEffectList[liveIndex]) PokemonEffectList[liveIndex] = nil end local state = 1--1 未解锁 隐藏 2 即将解锁 3 已解锁 未上阵 4 已解锁 已上阵 if pokemonPosLocks[liveIndex] <= PlayerManager.level then state = 3 if singleData then LogError("singledata.id=="..singleData.id) state = 4 end else if nextOpenLockIndex <= 0 then nextOpenLockIndex = liveIndex state = 2 end end --bgQuan:SetActive(true) dragViewListGo[liveIndex].gameObject:SetActive(false) PokemonGoListRedPoin[liveIndex]:SetActive(false) LogError("weapon state====================================="..state) if state == 1 then --什么都不用做 go.transform.parent.gameObject:SetActive(false) elseif state == 2 then lockInfo:SetActive(true) if GetCurLanguage() == 0 then Util.GetGameObject(go, "lockInfo/lockInfo/lvImage/Text"):GetComponent("Text").text = pokemonPosLocks[liveIndex]..Language[10056] else Util.GetGameObject(go, "lockInfo/lockInfo/lvImage/Text"):GetComponent("Text").text = Language[10056]..pokemonPosLocks[liveIndex] end Util.AddOnceClick( Util.GetGameObject(go, "lockInfo/lockInfo/lockClick"), function() PopupTipPanel.ShowTip(pokemonPosLocks[liveIndex]..Language[10056]) end) elseif state == 3 then addInfo:SetActive(true) PokemonGoListRedPoin[liveIndex]:SetActive(#canUpZhenPokemonList > 0) Util.AddOnceClick( Util.GetGameObject(go, "addInfo/addInfo/addClick"..liveIndex), function() UIManager.OpenPanel(UIName.GodWeaponListPanel,1,nil,liveIndex) end) elseif state == 4 then bgQuan:SetActive(false) local curData = GodWeaponManager.GetSingleWeaponData(singleData.Did) dragViewListGo[liveIndex].gameObject:SetActive(true) local upLvRed = GodWeaponManager.CheckUpLvRedPoint(curData) local upStarRed = GodWeaponManager.CheckUpStarRedPoint(curData) -- LogPink("liveIndex "..liveIndex.." upLvRed "..tostring(upLvRed).." upStarRed "..tostring(upStarRed)) PokemonGoListRedPoin[liveIndex]:SetActive(upLvRed or upStarRed) upZhenInfo:SetActive(true) local spiritAnimalConfig = ConfigManager.GetConfigData(ConfigName.ShenBing,curData.id) local parent = Util.GetGameObject(go, "upZhenInfo/titleImage") local starGrid=Util.GetGameObject(go, "upZhenInfo/starGrid/starGrid(Clone)") --starGrid.transform.posit=Vector2.New(-30,-30) --local starSize = Vector2.New(65,65) --SetHeroStars(this.spLoader,starGrid,curData.star,1,starSize) local starSize = Vector2.New(65,65) LogError("curData.star===="..curData.star) PokemonManager.SetHeroStars(this.spLoader, starGrid, curData.star,1,starSize) local nameText = Util.GetGameObject(parent, "nameText"):GetComponent("Text") nameText.text = GetStringByEquipQua(spiritAnimalConfig.Quality, GetLanguageStrById(spiritAnimalConfig.Name)) local liveImg=Util.GetGameObject(go, "upZhenInfo/pokemonLive"):GetComponent("Image") -- 特效显示配置 local config = EffectConfig[spiritAnimalConfig.Quality] if config then PokemonEffectList[liveIndex] = poolManager:LoadAsset(config.name, PoolManager.AssetType.GameObject) PokemonEffectList[liveIndex].transform.parent = PokemonList[liveIndex].transform PokemonEffectList[liveIndex].transform.localPosition = config.offset PokemonEffectList[liveIndex].transform.localScale = Vector3.one -- 层级设置 Util.AddParticleSortLayer(PokemonEffectList[liveIndex], orginLayer) end SetTextVerTial(nameText,Vector3.New(55.3,-1.58,0)) if GetCurLanguage() == 0 then Util.GetGameObject(go, "upZhenInfo/lvImage/Text"):GetComponent("Text").text = curData.lv..Language[10065] else Util.GetGameObject(go, "upZhenInfo/lvImage/Text"):GetComponent("Text").text = Language[10065] .. curData.lv end Util.GetGameObject(go, "upZhenInfo/lvImage/Text"):GetComponent("Text").text = curData.lv.."级" --local curPokemonLive = Util.GetGameObject(go, "upZhenInfo/pokemonLive") liveImg.sprite=this.spLoader:LoadSprite(GetResourcePath(spiritAnimalConfig.Icon)) for key, value in pairs(live2dList) do if key == liveIndex then -- LogPink("live2dList[liveIndex].name "..live2dList[key].name) poolManager:UnLoadLive(live2dList[key].name, live2dList[key].go, PoolManager.AssetType.GameObject) live2dList[key] = nil end end -- local LiveName = curData.live -- local live2d = poolManager:LoadLive(LiveName, curPokemonLive.transform,Vector3.one *curData.scale * 0.4, Vector3.New(spiritAnimal[curData.id].littleScalePosition[1],spiritAnimal[curData.id].littleScalePosition[2],0))--curData.scale -- live2dList[liveIndex] = {name=curData.live, go=live2d} -- local SkeletonGraphic = live2d:GetComponent("SkeletonGraphic") -- local idle = function() SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) end -- SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle -- local starSize = Vector2.New(65,65) --英雄长按 local heroClick=Util.GetGameObject(PokemonList[liveIndex],"DragView"..liveIndex) Util.AddOnceClick(heroClick, function() if isClick then UIManager.OpenPanel(UIName.GodWeaponInfoPanel,curData) end end) end end --拖拽 function this.OnPointerDown(Pointgo,data)--按下 local _j=tonumber(string.sub(Pointgo.transform.name,-1)) local pokemonObj=Util.GetTransform(Pointgo.transform.parent,"pokemon".._j) pokemonObj:DOScale(Vector3.one * 1.2, 0.15) pokemonObj.transform:SetParent(this.root.transform) pokemonObj:GetComponent("Image").raycastTarget = false end function this.OnPointerUp(Pointgo,data)--抬起 local _j=tonumber(string.sub(Pointgo.transform.name,-1)) Util.Peer(Pointgo.transform,"Pos").transform:SetAsFirstSibling() local pokemonObj=Util.GetTransform(this.gameObject,"pokemon".._j) pokemonObj:DOScale(Vector3.one * 1, 0.15) pokemonObj.transform:SetParent(PokemonList[_j].transform) pokemonObj.transform:SetSiblingIndex(1)--SetAsFirstSibling() pokemonObj:GetComponent("Image").raycastTarget = false end function this.OnEndDrag(Pointgo,data)--结束拖动 isClick = true local _j=tonumber(string.sub(Pointgo.transform.name,-1)) local pokemonObj=Util.GetGameObject(this.gameObject,"pokemon".._j) if data.pointerEnter==nil then--防止拖到屏幕外 LogError("拖到屏幕外·········") pokemonObj.transform:DOAnchorPos(Vector3.one,0) pokemonObj.transform:SetParent(PokemonList[_j].transform) pokemonObj.transform:SetSiblingIndex(1) return end -- Log("被拖动名。。。"..Pointgo.transform.name.." ".." 进入的UI名。。。"..data.pointerEnter.gameObject.name.."") local _i=tonumber(string.sub(data.pointerEnter.gameObject.name,-1)) local nameIn=data.pointerEnter.gameObject.name --进入的UI名 local _num=string.sub(nameIn,5,-1) local itemName="item".._num local pokemonObj=Util.GetGameObject(this.gameObject,"pokemon".._j) pokemonObj:GetComponent("Image").raycastTarget = true pokemonObj.transform:DOScale(Vector3.one * 1, 0.15) pokemonObj.transform:DOAnchorPos(Vector3.one,0) pokemonObj.transform:SetParent(PokemonList[_j].transform) pokemonObj.transform:SetSiblingIndex(1) if _i==nil then _i=tonumber(string.sub(Pointgo.transform.name,-1)) end if nameIn=="DragView".._i then --有人 NetManager.RequestMagicSoldierExchange(PokemonDataList[_j].Did,PokemonDataList[_i].Did,function() GodWeaponManager.ChangeWeaponPos(PokemonDataList[_j].Did,PokemonDataList[_i].Did) this.ShowPokemonList() end) elseif nameIn=="addClick".._i then NetManager.RequestMagicSoldierLocation(PokemonDataList[_j].Did,_i,function() GodWeaponManager.SetWeaponUpZhen(PokemonDataList[_j].Did,_i) this.ShowPokemonList() end) end this.line.gameObject:SetActive(false) end function this.OnDrag(Pointgo,data)--拖动中 isClick = false if data.pointerEnter==nil then--拖到屏幕外 this.line.transform:SetParent(this.roleGrid.transform) this.line.gameObject:SetActive(false) return end local _i=tonumber(string.sub(data.pointerEnter.gameObject.name,-1)) if _i==nil then _i=0 end local nameIn=data.pointerEnter.gameObject.name --进入的UI名 -- LogPink("进入的UI名nameIn "..nameIn) this.line:SetActive(nameIn=="DragView".._i or nameIn=="singlePokemon (".._i..")" or nameIn=="addClick".._i) if nameIn=="DragView".._i then this.line.transform:SetParent(PokemonList[_i].transform) this.line:GetComponent("RectTransform").localPosition = Vector3.New(0,45,0) this.line:GetComponent("RectTransform").localScale = Vector3.New(1,1,1) elseif nameIn=="singlePokemon (".._i..")" then this.line.transform:SetParent(PokemonList[_i].transform) this.line:GetComponent("RectTransform").localPosition = Vector3.New(0,45,0) this.line:GetComponent("RectTransform").localScale = Vector3.New(1,1,1) elseif nameIn=="addClick".._i then this.line.transform:SetParent(PokemonList[_i].transform) this.line:GetComponent("RectTransform").localPosition = Vector3.New(0,45,0) this.line:GetComponent("RectTransform").localScale = Vector3.New(1,1,1) else this.line.transform:SetParent(this.roleGrid.transform) this.line.gameObject:SetActive(false) end this.line.transform:SetAsFirstSibling() -- if panelType == FORMATION_TYPE.EXPEDITION or panelType == FORMATION_TYPE.CARBON then -- this.line.transform:DOAnchorPos(Vector3.New(0,15,0),0) -- else -- this.line.transform:DOAnchorPos(Vector3.New(0,30,0),0) -- end end --界面关闭时调用(用于子类重写) function GodWeaponMainPanel:OnClose() CheckRedPointStatus(RedPointType.GodWeapon) end --界面销毁时调用(用于子类重写) function GodWeaponMainPanel:OnDestroy() this.spLoader:Destroy() --ClearRedPointObject(RedPointType.Pokemon_Recruit, this.btnInfoRed) ClearRedPointObject(RedPointType.Weapon_Fetter, this.btnFetterRed) --ClearRedPointObject(RedPointType.Pokemon_ChipCompound, this.btnPokemonListRed) SubUIManager.Close(this.UpView) dragViewListGo={} for key, value in pairs(live2dList) do poolManager:UnLoadLive(live2dList[key].name, live2dList[key].go, PoolManager.AssetType.GameObject) live2dList[key] = nil end -- 清空引用 PokemonEffectList = {} end return GodWeaponMainPanel