Merge branch '0功能/灵兽系统' of http://60.1.1.230/gaoxin/JL_Client into 0功能/灵兽系统

wangzhenxing 2020-10-17 14:11:47 +09:00
commit 711986c6a9
4 changed files with 8384 additions and 6457 deletions

View File

@ -2,11 +2,12 @@
local PokemonMainPanel = Inherit(BasePanel)
local this = PokemonMainPanel
local PokemonList = {}
local PokemonGoList = {}
local PokemonDataList = {}
local live2dList = {}
local pokemonPosLocks = {
80,80,90,90,100,100
}
local dragViewListGo={}--dragView预设列表
local pokemonPosLocks = ConfigManager.GetConfigData(ConfigName.WorkShopSetting,1).BlockUnlockLevel
--初始化组件(用于子类重写)
function PokemonMainPanel:InitComponent()
this.btnBack = Util.GetGameObject(self.transform, "btnBack")
@ -17,10 +18,26 @@ function PokemonMainPanel:InitComponent()
this.btnOut = Util.GetGameObject(self.transform, "btnEndRoot/btnOut")
this.btnFetter = Util.GetGameObject(self.transform, "btnEndRoot/btnFetter")
this.btnPokemonList = Util.GetGameObject(self.transform, "btnEndRoot/btnPokemonList")
this.line=Util.GetGameObject(this.gameObject,"lineParent/Line")
this.roleGrid=Util.GetGameObject(this.gameObject,"lineParent")
for i = 1, 6 do
PokemonList[i] = Util.GetGameObject(self.transform, "PokemonList/singlePokemon (".. i ..")")
Util.GetGameObject( PokemonList[i], "upZhenInfo/titleImage/sortText"):GetComponent("Text").text = i
Util.GetGameObject( PokemonList[i], "addInfo/sortText"):GetComponent("Text").text = i
PokemonGoList[i] = Util.GetGameObject(PokemonList, "pokemon".. i)
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
@ -84,12 +101,16 @@ local nextOpenLockIndex = 0
function this.ShowPokemonList()
nextOpenLockIndex = 0
PokemonDataList = {{},{},{},{},{},{}}
LogPink("#PokemonList "..#PokemonDataList)
for i = 1, #PokemonList do
this.ShowSinglePokemonList(PokemonList[i],PokemonDataList[i],i)
for i = 1, #PokemonGoList do
this.ShowSinglePokemonList(PokemonGoList[i],PokemonDataList[i],i)
end
end
function this.SaveFormation()
--保存编队
end
function this.ShowSinglePokemonList(go,singleData,liveIndex)
go:SetActive(true)
local upZhenInfo = Util.GetGameObject(go, "upZhenInfo")
@ -111,21 +132,24 @@ function this.ShowSinglePokemonList(go,singleData,liveIndex)
state = 2
end
end
dragViewListGo[liveIndex].gameObject:SetActive(false)
if state == 1 then
--什么都不用做
go:SetActive(false)
elseif state == 2 then
lockInfo:SetActive(true)
Util.GetGameObject(go, "lockInfo/lvImage/Text"):GetComponent("Text").text = pokemonPosLocks[liveIndex].."级解锁"
Util.AddOnceClick( Util.GetGameObject(go, "lockInfo/lockClick"), function()
Util.GetGameObject(go, "lockInfo/lockInfo/lvImage/Text"):GetComponent("Text").text = pokemonPosLocks[liveIndex].."级解锁"
Util.AddOnceClick( Util.GetGameObject(go, "lockInfo/lockInfo/lockClick"), function()
PopupTipPanel.ShowTip(pokemonPosLocks[liveIndex].."级解锁")
end)
elseif state == 3 then
addInfo:SetActive(true)
Util.AddOnceClick( Util.GetGameObject(go, "addInfo/addClick"), function()
Util.AddOnceClick( Util.GetGameObject(go, "addInfo/addInfo/addClick"), function()
UIManager.OpenPanel(UIName.PokemonListPanel,Pokemon_Popup_Type.PokemonListPanel_UpWar)
end)
elseif state == 4 then
dragViewListGo[liveIndex].gameObject:SetActive(true)
upZhenInfo:SetActive(true)
Util.GetGameObject(go, "upZhenInfo/titleImage/nameText"):GetComponent("Text").text = "名字"
Util.GetGameObject(go, "upZhenInfo/lvImage/Text"):GetComponent("Text").text = "等级"
@ -147,6 +171,131 @@ function this.ShowSinglePokemonList(go,singleData,liveIndex)
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)--结束拖动
local _j=tonumber(string.sub(Pointgo.transform.name,-1))
local pokemonObj=Util.GetGameObject(this.gameObject,"pokemon".._j)
if data.pointerEnter==nil then--防止拖到屏幕外
pokemonObj.transform:DOAnchorPos(Vector3.one,0)
pokemonObj.transform:SetParent(PokemonList[_j].transform)
pokemonObj.transform:SetSiblingIndex(1)
return
end
-- Log("<color=blue>被拖动名。。。</color><color=red>"..Pointgo.transform.name.."</color> ".." <color=blue>进入的UI名。。。</color><color=red>"..data.pointerEnter.gameObject.name.."</color>")
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 --有人
-- Log("有人")
local curData
local tarData
for i, v in ipairs(PokemonDataList ) do
if _j==v.position then
curData=v.pokemonId
end
if _i==v.position then
tarData=v.pokemonId
end
end
for i, v in ipairs(PokemonDataList) do
if _j==v.position then
PokemonDataList[i].pokemonId=tarData
end
if _i==v.position then
PokemonDataList[i].pokemonId=curData
end
end
elseif nameIn=="singlePokemon (".._i..")" then --没人
-- Log("没人")
local did
for i, v in ipairs(PokemonDataList) do
if _j==v.position then
did=v.pokemonId
table.remove(PokemonDataList,i)
end
end
table.insert(PokemonDataList, {pokemonId = did, position=_i})
elseif nameIn=="addInfo" or nameIn=="lockInfo" then--无效操作
-- if not this.opView.NoUpOrDownFormation then
-- this.order=this.order-1
-- for i, v in ipairs(this.choosedList) do
-- if _j==v.position then
-- table.remove(this.choosedList,i)
-- dragViewListGo[_j].gameObject:SetActive(false)
-- break
-- end
-- end
-- else
-- PopupTipPanel.ShowTip(Language[12206])
-- end
end
this.line.gameObject:SetActive(false)
this.ShowPokemonList()
end
function this.OnDrag(Pointgo,data)--拖动中
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名
this.line:SetActive(nameIn=="DragView".._i or nameIn=="singlePokemon (".._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)
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 PokemonMainPanel:OnClose()
poolManager:UnLoadLive(this.LiveName,this.LiveGO )
@ -155,6 +304,8 @@ end
--界面销毁时调用(用于子类重写)
function PokemonMainPanel:OnDestroy()
SubUIManager.Close(this.UpView)
dragViewListGo={}
if live2dList and #live2dList > 0 then
for i = 1, #live2dList do
poolManager:UnLoadLive(live2dList[i].name, live2dList[i].go, PoolManager.AssetType.GameObject)

View File

@ -1,14 +1,19 @@
PokemonManager = {}
local this = PokemonManager
local spiritAnimal = ConfigManager.GetConfig(ConfigName.SpiritAnimal)
local spiritAnimalBook = ConfigManager.GetConfig(ConfigName.SpiritAnimalBook)
local pokemons = {}--灵兽数据
local pokemonFetter = {}--灵兽羁绊
local pokemonFormatipn = {}--灵兽编队
function this.Initialize()
end
---------------------------------------------
--初始化灵兽数据
---------------------------------------------
function this.InitPokemonsData(_msgPokemonList)
--Log("初始化灵兽数据" .. #_msgPokemonList)
pokemons = {}
for i = 1, #_msgPokemonList do
this.UpdatePokemonDatas(_msgPokemonList[i])
end
@ -54,8 +59,16 @@ function this.RemoveSinglePokemonData(_did)
pokemons[_did] = nil
end
end
--前端刷新单个灵兽数据
function this.UpdateSinglePokemonData(_did,_lv,_star)
if not _did then return end
if pokemons[_did] then
pokemons[_did].lv = _lv
pokemons[_did].star = _star
end
end
--获取当前所有可吞卡灵兽数据
function this.RemoveSinglePokemonData(_id)
function this.GetNoUpLvPokemonData(_id)
local curAllPokemonList = {}
for key, value in pairs(pokemons) do
if value.isZhen == false and value.star <= 0 and value.lv <= 1 then
@ -64,10 +77,49 @@ function this.RemoveSinglePokemonData(_id)
end
return curAllPokemonList
end
--获取单个灵兽属性 (灵兽属性/编队人数 灵兽属性会平分给上阵的所有神将)
function this.GetSinglePokemonAddProData(_did)
if not pokemons[_did] then return end
local addAllProVal = {}
local curPokeonData = pokemons[_did]
local curPokemonConFig = ConfigManager.GetConfigData(ConfigName.SpiritAnimal,curPokeonData.id)
local curPokemonLvConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.SpiritAnimalLevel,"Quality",curPokemonConFig.Quality,"Level",curPokeonData.lv)
local curPokemonStarConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.SpiritAnimalStar,"Quality",curPokemonConFig.Quality,"Star",curPokeonData.star)
--基础
addAllProVal[HeroProType.Hp] = curPokemonConFig.Hp
addAllProVal[HeroProType.Attack] = curPokemonConFig.Attack
addAllProVal[HeroProType.PhysicalDefence] = curPokemonConFig.PhysicalDefence
addAllProVal[HeroProType.MagicDefence] = curPokemonConFig.MagicDefence
--升级
for i = 1, #curPokemonLvConFig.CharacterLevelPara do
local curPro = curPokemonLvConFig.CharacterLevelPara[i]
if curPro[2] > 0 then
if addAllProVal[curPro[1]] then
addAllProVal[curPro[1]]=addAllProVal[curPro[1]]+curPro[2]
else
addAllProVal[curPro[1]]=curPro[2]
end
end
end
--升星 属性=(基础属性+等级属性)*1+星级倍率)
local StarPara = curPokemonStarConFig.StarPara/10000
local addEndAllProVal = {}
for key, value in pairs(addAllProVal) do
addEndAllProVal[key] = value * (1 + StarPara)
end
return addEndAllProVal
end
--灵兽羁绊
---------------------------------------------
--灵兽羁绊 (羁绊属性直接就是团队属性)
---------------------------------------------
function this.InitPokemonsFetterData(_msgPokemonFetterList)
--Log("灵兽羁绊" .. #_msgPokemonFetterList)
pokemonFetter = {}
for i = 1, #_msgPokemonFetterList do
this.UpdatePokemonFetterDatas(_msgPokemonFetterList[i])
end
@ -113,6 +165,7 @@ function this.GetPokemonRefreshFetter(_sid)
end
end
end
--获取所有的灵兽种类
function this.GetCurPokemonSidList()
local curPokemonSidList = {}
for key, value in pairs(pokemons) do
@ -120,4 +173,50 @@ function this.GetCurPokemonSidList()
end
return curPokemonSidList
end
--获取所有灵兽羁绊总和属性 (羁绊属性直接加在团队属性上)
function this.GetAllPokemonFetterAddPros()
local addAllProVal = {}
for key, value in pairs(pokemonFetter) do
local curspiritAnimalBook = spiritAnimalBook[key]
if curspiritAnimalBook and #curspiritAnimalBook.ActivePara > 0 then
for i = 1, #curspiritAnimalBook.ActivePara do
local curPro = curspiritAnimalBook.ActivePara[i]
if curPro[2] > 0 then
if addAllProVal[curPro[1]] then
addAllProVal[curPro[1]]=addAllProVal[curPro[1]]+curPro[2]
else
addAllProVal[curPro[1]]=curPro[2]
end
end
end
end
end
return addAllProVal
end
---------------------------------------------
--灵兽编队
---------------------------------------------
--刷新本地灵兽编队数据
function this.UpdatePokemonFormationDatas(_msgPokemonFormationList)
pokemonFormatipn = {}
for i = 1, #_msgPokemonFormationList do
local teamInfo = {}
teamInfo.pokemonDid = _msgPokemonFormationList[i].pokemonDid
teamInfo.position = _msgPokemonFormationList[i].position
table.insert(pokemonFormatipn, teamInfo)
end
end
function this.GetPokemonFormationAddPro()
local allPro = {}
for key, value in pairs(pokemonFormatipn) do
if pokemons[key] then
local curPokemonAddPro = this.GetNoUpLvPokemonData(key)
HeroManager.DoubleTableCompound(allPro, curPokemonAddPro)
end
end
return allPro
end
return this

View File

@ -112,7 +112,7 @@ function this.OnShowData()
SubUIManager.Open(SubUIConfig.ItemView, itemParent.transform):OnOpen(false, upStarMaterialsData[i], 0.97)
local curMaterialBagNum = 0
if i == 1 then--需要的灵兽
curMaterialBagNum = PokemonManager.RemoveSinglePokemonData(curPokemonData.id)
curMaterialBagNum = PokemonManager.GetNoUpLvPokemonData(curPokemonData.id)
elseif i == 2 then--需要的材料
curMaterialBagNum = BagManager.GetItemCountById(upStarMaterialsData[i][1])
end