zhangqiang 2020-09-25 18:41:07 +08:00
parent f40b2050ad
commit 637d910b5c
6 changed files with 281 additions and 442 deletions

View File

@ -352,10 +352,10 @@ RectTransform:
m_Father: {fileID: 5019595422767200276}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 69.229996, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5790484993830166479
CanvasRenderer:
@ -969,10 +969,10 @@ RectTransform:
m_Father: {fileID: 5019595422767200276}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 157.69, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8013617887459184222
CanvasRenderer:
@ -1572,10 +1572,10 @@ RectTransform:
m_Father: {fileID: 5019595422767200276}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 201.92, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2893984615501566352
CanvasRenderer:
@ -1882,6 +1882,7 @@ GameObject:
- component: {fileID: 8003368882569556066}
- component: {fileID: 163819372599327465}
- component: {fileID: 1550140968972545037}
- component: {fileID: 7589459059305946437}
m_Layer: 5
m_Name: upZhen
m_TagString: Untagged
@ -1946,6 +1947,48 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!114 &7589459059305946437
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2544063271271464429}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1550140968972545037}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!1 &2563587693022891201
GameObject:
m_ObjectHideFlags: 0
@ -3939,7 +3982,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &5604523187353186988
RectTransform:
m_ObjectHideFlags: 0
@ -4567,7 +4610,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -4, y: -287}
m_AnchoredPosition: {x: 33, y: -287}
m_SizeDelta: {x: 992.3, y: 4}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8313533031453462454
@ -4961,10 +5004,10 @@ RectTransform:
m_Father: {fileID: 5019595422767200276}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 113.46, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7741467895996226497
CanvasRenderer:
@ -6262,10 +6305,10 @@ RectTransform:
m_Father: {fileID: 5019595422767200276}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 25, y: -25}
m_SizeDelta: {x: 50, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3611648452498569591
CanvasRenderer:

View File

@ -7599,7 +7599,6 @@ GameObject:
- component: {fileID: 6468222800179020355}
- component: {fileID: 4891086731986295050}
- component: {fileID: 4239125244405987035}
- component: {fileID: 7967436826178465454}
m_Layer: 5
m_Name: btnhelp
m_TagString: Untagged
@ -7705,25 +7704,6 @@ MonoBehaviour:
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!95 &7967436826178465454
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7819267290322053974}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 6ffe000b5a58aac48a9d130543849d76, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!1 &7822775559030778369
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,36 +1,21 @@
require("Base/BasePanel")
PokemonListPanel = Inherit(BasePanel)
local this = PokemonListPanel
local TabBox = require("Modules/Common/TabBox")
local _TabData={ [1] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[10421] },
--[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "宝器锻造" },
[2] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[10422] },
[3] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = Language[10423] },
}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
local curIndex = 1
this.contents = {
[1] = {view = require("Modules/Compound/view/PokemonListPanel_UpWar"), panelName = "PokemonListPanel_UpWar"},
[2] = {view = require("Modules/Compound/view/PokemonListPanel_List"), panelName = "PokemonListPanel_List"},
[3] = {view = require("Modules/Compound/view/PokemonListPanel_Fetter"), panelName = "PokemonListPanel_Fetter"},
[1] = {view = require("Modules/Pokemon/view/PokemonListPanel_UpWar"), panelName = "PokemonListPanel_UpWar"},
[2] = {view = require("Modules/Pokemon/view/PokemonListPanel_List"), panelName = "PokemonListPanel_List"},
[3] = {view = require("Modules/Pokemon/view/PokemonListPanel_Fetter"), panelName = "PokemonListPanel_Fetter"},
}
--初始化组件(用于子类重写)
function PokemonListPanel:InitComponent()
this.HelpBtn = Util.GetGameObject(self.gameObject,"helpBtn")
this.helpPosition=this.HelpBtn:GetComponent("RectTransform").localPosition
--子模块脚本
this.tabBox = Util.GetGameObject(self.gameObject, "TabBox")
this.upView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft})
this.btnBack = Util.GetGameObject(self.gameObject, "btnBack/btnBack")
this.btnBack = Util.GetGameObject(self.gameObject, "bg/btnBack")
--预设赋值
this.prefabs = {}
for i=1,#this.contents do
this.prefabs[i]=Util.GetGameObject(self.gameObject,this.contents[i].panelName)
this.contents[i].view:InitComponent(Util.GetGameObject(self.gameObject, "panle"))
this.prefabs[i]=Util.GetGameObject(self.gameObject,"layout/"..this.contents[i].panelName)
this.contents[i].view:InitComponent(Util.GetGameObject(self.gameObject, "layout"))
end
end
@ -44,27 +29,6 @@ function PokemonListPanel:BindEvent()
end
end
function PokemonListPanel.RefreshHelpBtn()
if curIndex==1 then
this.HelpBtn:SetActive(true)
Util.AddOnceClick(this.HelpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.EquipCompose,this.helpPosition.x,this.helpPosition.y)
end)
elseif curIndex==2 then
this.HelpBtn:SetActive(true)
Util.AddOnceClick(this.HelpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.TreasureCompose,this.helpPosition.x,this.helpPosition.y)
end)
elseif curIndex==3 then
this.HelpBtn:SetActive(true)
Util.AddOnceClick(this.HelpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.SoulPrintCommond,this.helpPosition.x,this.helpPosition.y)
end)
else
this.HelpBtn:SetActive(false)
end
end
--添加事件监听(用于子类重写)
function PokemonListPanel:AddListener()
for i = 1, #this.contents do
@ -85,14 +49,9 @@ function PokemonListPanel:OnOpen(_curIndex)
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PokemonListPanel:OnShow()
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
this.TabCtrl:Init(this.tabBox, _TabData, curIndex)
this.ShowSShowwitchView(curIndex)
end
function PokemonListPanel:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
for i = 1, #this.contents do
@ -100,32 +59,9 @@ function PokemonListPanel:OnSortingOrderChange()
end
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
Util.GetGameObject(tab,"Image"):GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status])
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
this.SetBottomBarIsActive(tab, index)
end
--特殊的开启条件
function this.SetBottomBarIsActive(tab, index)
local ConfigData = ConfigManager.GetConfig(ConfigName.SpecialConfig)
if index == 2 then
local string = ConfigData[40].Value
local num = string.split(string.split(string,"|")[1],"#")[2]
tab:SetActive(PlayerManager.level >= tonumber(num))
end
if index == 3 then
local string = ConfigData[89].Value
tab:SetActive(PlayerManager.level >= tonumber(string))
end
end
--切换视图
function this.SwitchView(index)
function this.ShowSShowwitchView(index)
--先执行上一面板关闭逻辑
local oldSelect
oldSelect, curIndex = curIndex, index
@ -136,22 +72,9 @@ function this.SwitchView(index)
for i = 1, #this.prefabs do
this.prefabs[i].gameObject:SetActive(i == index)--切换子模块预设显隐
end
--区分显示
if index==1 then
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
elseif index==2 then
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
elseif index==3 then
this.upView:OnOpen({showType = UpViewOpenType.ShowLeft, panelType = PanelType.Main})
end
this.RefreshHelpBtn()
--执行子模块初始化
this.contents[index].view:OnShow(this)
end
--刷新魂印合成的方法
function this.UpdatePokemonListPanel_SoulPrint(equipSign,index)
this.contents[curIndex].view.ShowTitleEquipData(nil,equipSign,index)
end
--界面关闭时调用(用于子类重写)
function PokemonListPanel:OnClose()

View File

@ -1,6 +1,8 @@
require("Base/BasePanel")
local PokemonMainPanel = Inherit(BasePanel)
local this = PokemonMainPanel
local PokemonList = {}
local live2dList = {}
--初始化组件(用于子类重写)
function PokemonMainPanel:InitComponent()
this.btnBack = Util.GetGameObject(self.transform, "btnBack")
@ -13,6 +15,11 @@ 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")
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
end
-- this.callCount = Util.GetGameObject(self.transform, "callMonsterBtn/Text"):GetComponent("Text")
@ -29,8 +36,23 @@ function PokemonMainPanel:BindEvent()
local pos = this.btnHelp.transform.localPosition
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.Adventure, pos.x, pos.y)
end)
Util.AddClick(this.btnBack, function()
this:ClosePanel()
Util.AddClick(this.btnShop, function()
-- UIManager.OpenPanel(UIName.HelpPopup)
end)
Util.AddClick(this.btnInfo, function()
-- UIManager.OpenPanel(UIName.HelpPopup)
end)
Util.AddClick(this.btnWarAddPro, function()
-- UIManager.OpenPanel(UIName.HelpPopup)
end)
Util.AddClick(this.btnOut, function()
-- UIManager.OpenPanel(UIName.HelpPopup)
end)
Util.AddClick(this.btnFetter, function()
-- UIManager.OpenPanel(UIName.HelpPopup)
end)
Util.AddClick(this.btnPokemonList, function()
-- UIManager.OpenPanel(UIName.HelpPopup)
end)
end
@ -52,18 +74,69 @@ end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PokemonMainPanel:OnShow()
this.ShowPokemonList()
end
function this.ShowPokemonList()
PokemonList = {}
for i = 1, #PokemonList do
this.ShowSinglePokemonList(PokemonList[i],PokemonList[i],i)
end
end
function this.ShowSinglePokemonList(go,singleData,liveIndex)
go:SetActive(true)
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 singleData.State == 1 then
upZhenInfo:SetActive(true)
Util.GetGameObject(go, "upZhenInfo/titleImage/nameText"):GetComponent("Text").text = "名字"
Util.GetGameObject(go, "upZhenInfo/lvImage/Text"):GetComponent("Text").text = "等级"
local curPokemonLive = Util.GetGameObject(go, "upZhenInfo/pokemonLive")
if live2dList and #live2dList > 0 then
if live2dList[liveIndex] then
poolManager:UnLoadLive(live2dList[liveIndex].name, live2dList[liveIndex].go, PoolManager.AssetType.GameObject)
live2dList[liveIndex] = nil
end
end
local LiveName = GetResourcePath(heroConfig.Live)
local live2d = poolManager:LoadLive(LiveName, curPokemonLive.transform,Vector3.one * heroConfig.Scale, Vector3.New(heroConfig.Position[1],heroConfig.Position[2],0))
live2dList[liveIndex] = {name=configData.Icon, go=live2d}
this.SetStarGrid(Util.GetGameObject(go, "upZhenInfo/starGrid"),2)
elseif singleData.State == 2 then
end
end
function this.SetStarGrid(go,starNum)
for i = 1, 5 do
if starNum <= i then
go.transform:GetChild(i - 1):SetActive(true)
else
go.transform:GetChild(i - 1):SetActive(false)
end
end
end
--界面关闭时调用(用于子类重写)
function PokemonMainPanel:OnClose()
poolManager:UnLoadLive(this.LiveName,this.LiveGO )
this.LiveName= nil
end
--界面销毁时调用(用于子类重写)
function PokemonMainPanel:OnDestroy()
if live2dList and #live2dList > 0 then
for i = 1, #live2dList do
poolManager:UnLoadLive(live2dList[i].name, live2dList[i].go, PoolManager.AssetType.GameObject)
live2dList[i] = nil
end
end
end
return PokemonMainPanel

View File

@ -1,13 +1,36 @@
----- 灵兽列表 和 合成 -----
----- 灵兽列表 和 合成 ----
local this = {}
local sortingOrder=0
local equipStarsConfig = ConfigManager.GetConfig(ConfigName.EquipStarsConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local TabBox = require("Modules/Common/TabBox")
local _TabData={ [1] = { default = "zbhc_sanji2", select = "zbhc_sanji1", name = "灵兽" },
[2] = { default = "zbhc_sanji2", select = "zbhc_sanji1", name = "碎片" },
}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
local _TabImagePos = { default = -3,
select = -10}
local curIndex = 0
local pokemonList = {}
local pokemonChipList = {}
function this:InitComponent(gameObject)
Util.GetGameObject(gameObject, "PokemonListPanel_List/name"):GetComponent("Text").text = "灵兽列表"
this.tabBox = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/TabBox")
this.equipPre = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/equipPre")
local v2 = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/scroll"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/scroll").transform,
this.equipPre, nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(15,15))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
end
function this:BindEvent()
-- Util.AddClick(this.subtractBtn, function()
-- this.CompoundNumChange(2)
-- end)
end
function this:AddListener()
@ -16,14 +39,94 @@ end
function this:RemoveListener()
end
function this:OnShow(...)
function this:OnShow(...)
curIndex = 1
sortingOrder =0
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
this.TabCtrl:Init(this.tabBox, _TabData,curIndex)
end
local sortingOrder = 0
function this:OnSortingOrderChange(_sortingOrder)
sortingOrder = _sortingOrder
end
function this.OnClickTabBtn(_curIndex)
curIndex = _curIndex
if curIndex == 1 then
pokemonList = {}
this.ScrollView:SetData(pokemonList, function (index, go)
this.SingleItemDataShow(go, pokemonList[index])
end)
elseif curIndex == 2 then
pokemonChipList = {}
this.ScrollView:SetData(pokemonChipList, function (index, go)
this.SingleItemDataShow(go, pokemonChipList[index])
end)
end
-- this.ScrollView:ForeachItemGO(function(index, go)
-- Timer.New(function()
-- go.gameObject:SetActive(true)
-- PlayUIAnim(go.gameObject)
-- end, 0.001 * (index - 1)):Start()
-- end)
end
function this.SingleItemDataShow(_go,_itemData,curEquipStarsConfig)
Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(GetQuantityImageByquality(curEquipStarsConfig.Quality))
Util.GetGameObject(_go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(itemConfig[_itemData.Id].ResourceID))
Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text=_itemData.Name
SetHeroStars(Util.GetGameObject(_go.transform, "star"), curEquipStarsConfig.Stars,1,nil,-15)
local choosed =Util.GetGameObject(_go.transform, "choosed")
choosed:SetActive(curSelectEquip.Id == _itemData .Id)
local redPoint = Util.GetGameObject(_go.transform,"redPoint")
redPoint:SetActive(bagPosEquips[curEquipStarsConfig.Id - 1] and bagPosEquips[curEquipStarsConfig.Id - 1] >= equipStarsConfig[curEquipStarsConfig.Id - 1].RankupCount)
if curSelectEquip.Id == _itemData .Id then
curSelectGO = _go
end
Util.AddOnceClick(Util.GetGameObject(_go.transform,"icon"), function()
if curSelectEquip.Id == _itemData .Id then
return
else
curSelectEquip = _itemData
choosed:SetActive(true)
if curSelectGO then
Util.GetGameObject(curSelectGO.transform, "choosed"):SetActive(false)
curSelectGO = _go
end
end
this.ShowTitleData(curEquipStarsConfig)
end)
Util.AddLongPressClick(Util.GetGameObject(_go.transform,"icon"), function()
UIManager.OpenPanel(UIName.HandBookEquipInfoPanel, _itemData.Id)
end, 0.5)
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
tabImage:GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status])
tabImage:GetComponent("Image"):SetNativeSize()
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
tabImage.transform.localPosition = Vector3.New( tabImage.transform.localPosition.x, _TabImagePos[status], 0);
end
--切换视图
function this.SwitchView(index)
this.OnClickTabBtn(index)
end
function this:OnClose()
needGoldNum=0
end
function this:OnDestroy()
needGoldNum=0
end
return this

View File

@ -1,345 +1,62 @@
----- 选择出战灵兽 -----
local this = {}
local sortingOrder=0
local equipStarsConfig = ConfigManager.GetConfig(ConfigName.EquipStarsConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local TabBox = require("Modules/Common/TabBox")
local _TabData={ [1] = { default = "zbhc_sanji2", select = "zbhc_sanji1", name = Language[10427] },
[2] = { default = "zbhc_sanji2", select = "zbhc_sanji1", name = Language[10428] },
[3] = { default = "zbhc_sanji2", select = "zbhc_sanji1", name = Language[10429] },
[4] = { default = "zbhc_sanji2", select = "zbhc_sanji1", name = Language[10430] },
--[5] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "戒指" },
--[6] = { default = "r_hero_xuanze_002", select = "r_hero_xuanze_001", name = "腰带" }
}
local _TabFontColor = { default = Color.New(130 / 255, 128 / 255, 120 / 255, 1),
select = Color.New(243 / 255, 235 / 255, 202 / 255, 1)}
local _TabImagePos = { default = -3,
select = -10}
local curIndex = 0
local compoundNum = 0
local compoundMaxNum = 0
--this.tabs = {}
local curNeedEquip = {}
local curSelectEquip = {}
local curSelectGO
local materidaIsCan = false
local bagPosEquips = {}
local needGoldNum = 0
local polemonList = {}
function this:InitComponent(gameObject)
this.tabBox = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/TabBox")
this.needGoldText = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/compoundBtn/needGoldText"):GetComponent("Text")
this.compoundBtn = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/compoundBtn")
this.autoCompoundBtn = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/autoCompoundBtn")
this.addBtn = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/addBtn")
this.subtractBtn = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/subtractBtn")
this.numText = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/numText"):GetComponent("Text")
this.progressText = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/progressText"):GetComponent("Text")
this.needEquip = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/needEquip")
this.compoundEquip = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/compoundEquip")
this.progressImage = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/titleGo/progress/Image"):GetComponent("Image")
--for i = 1, 6 do
-- this.tabs[i] = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/Tabs/Btn" .. i)
--end
this.equipPre = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/equipPre")
this.ScrollBar=Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/Scrollbar"):GetComponent("Scrollbar")
local v2 = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/scroll"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/scroll").transform,
this.equipPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(15,15))
Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/name"):GetComponent("Text").text = "选择出战灵兽"
this.ItemPre = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/ItemPre")
local v2 = Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/ScrollParentView"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "PokemonListPanel_UpWar/ScrollParentView").transform,
this.ItemPre, nil, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(15,15))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
end
function this:BindEvent()
Util.AddClick(this.compoundBtn, function()
PlaySoundWithoutClick("UI_wapapon_mixture_equip")
this.Compound(curIndex)
end)
--
Util.AddClick(this.autoCompoundBtn, function()
this.AutoCompound(curIndex)
end)
Util.AddClick(this.addBtn, function()
this.CompoundNumChange(1)
end)
Util.AddClick(this.subtractBtn, function()
this.CompoundNumChange(2)
end)
end
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold,this.ShowGoldNum0)
end
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,this.ShowGoldNum0)
end
function this.ShowGoldNum0()
if needGoldNum > BagManager.GetItemCountById(14) then
materidaIsCan = false
this.needGoldText.text = string.format("<color=#FF0011>%s</color>", needGoldNum)
else
materidaIsCan = true
this.needGoldText.text =string.format("<color=#FCF5D3FF>%s</color>", needGoldNum)
end
end
function this:OnShow(...)
curIndex = 1
sortingOrder =0
needGoldNum=0
this.TabCtrl = TabBox.New()
this.TabCtrl:SetTabAdapter(this.TabAdapter)
this.TabCtrl:SetChangeTabCallBack(this.SwitchView)
this.TabCtrl:Init(this.tabBox, _TabData,curIndex)
end
local sortingOrder = 0
function this:OnSortingOrderChange(_sortingOrder)
sortingOrder = _sortingOrder
end
function this.OnClickTabBtn(_curIndex)
curIndex = _curIndex
bagPosEquips = EquipManager.GetEquipCompoundDataByEquipPosition1(curIndex)
local equipDatas = EquipManager.GetAllSEquipsByPosition(curIndex)
if equipDatas and #equipDatas > 0 then
curSelectEquip = equipDatas[1]
end
this.ScrollView:SetData(equipDatas, function (index, go)
this.SingleItemDataShow(go, equipDatas[index],equipStarsConfig[equipDatas[index].Star])
end)
this.ShowTitleData(equipStarsConfig[curSelectEquip.Star])
this.ScrollView:ForeachItemGO(function(index, go)
Timer.New(function()
go.gameObject:SetActive(true)
PlayUIAnim(go.gameObject)
end, 0.001 * (index - 1)):Start()
function this:OnShow(...)
this.ScrollView:SetData(polemonList, function (index, go)
this.SingleItemDataShow(go, polemonList[index])
end)
-- this.ScrollView:ForeachItemGO(function(index, go)
-- Timer.New(function()
-- go.gameObject:SetActive(true)
-- PlayUIAnim(go.gameObject)
-- end, 0.001 * (index - 1)):Start()
-- end)
end
function this.ShowTitleData(curEquipStarsConfig)
this.ShowTitleEquipData(this.compoundEquip,curSelectEquip,curEquipStarsConfig)
--得到静态表中合成当前装备需要的装备
curNeedEquip = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipConfig,"Position",curSelectEquip.Position,"Star",curSelectEquip.Star - 1)
this.ShowTitleEquipData(this.needEquip,curNeedEquip,equipStarsConfig[curSelectEquip.Star - 1])--需要的材料
--得到背包中中合成当前装备需要的装备
local allCanCompoundEquips = EquipManager.GetBagCompoundEquipDatasByequipSData(curSelectEquip)
local num = 0
for i=1,#allCanCompoundEquips do
num=num+allCanCompoundEquips[i].num
end
this.progressText.text = num .. "/" .. equipStarsConfig[curSelectEquip.Star - 1].RankupCount
this.progressImage.fillAmount = num / equipStarsConfig[curSelectEquip.Star - 1].RankupCount
compoundNum = math.floor(num / equipStarsConfig[curSelectEquip.Star - 1].RankupCount)
compoundMaxNum = math.floor(num / equipStarsConfig[curSelectEquip.Star - 1].RankupCount)
this.ShowGoldNum(equipStarsConfig[curSelectEquip.Star - 1],compoundNum)
end
function this.ShowGoldNum(upEquipStarsConfig,compoundNum)
needGoldNum = compoundNum * upEquipStarsConfig.RankupResources[1][2]
if needGoldNum > BagManager.GetItemCountById(upEquipStarsConfig.RankupResources[1][1]) then
materidaIsCan = false
this.needGoldText.text = string.format("<color=#FF0011>%s</color>", needGoldNum)
else
materidaIsCan = true
this.needGoldText.text =string.format("<color=#FCF5D3FF>%s</color>", needGoldNum)
end
this.numText.text = compoundNum
Util.SetGray(this.addBtn,false)
Util.SetGray(this.subtractBtn,false)
this.addBtn:GetComponent("Button").enabled = true
this.subtractBtn:GetComponent("Button").enabled = true
if compoundNum >= compoundMaxNum then
Util.SetGray(this.addBtn,true)
this.addBtn:GetComponent("Button").enabled = false
end
if compoundNum <= 1 then
Util.SetGray(this.subtractBtn,true)
this.subtractBtn:GetComponent("Button").enabled = false
end
if compoundNum == 0 then
Util.SetGray(this.addBtn,true)
Util.SetGray(this.subtractBtn,true)
this.addBtn:GetComponent("Button").enabled = false
this.subtractBtn:GetComponent("Button").enabled = false
end
end
function this.ShowTitleEquipData(_go,_itemData,curEquipStarsConfig)
Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(GetQuantityImageByquality(curEquipStarsConfig.Quality))
Util.GetGameObject(_go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(itemConfig[_itemData.Id].ResourceID))
Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text = itemConfig[_itemData.Id].Name
--Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text=_itemData.Name
SetHeroStars(Util.GetGameObject(_go.transform, "star"), curEquipStarsConfig.Stars,1,nil,-15)
Util.AddClick(Util.GetGameObject(_go.transform,"icon"), function()
UIManager.OpenPanel(UIName.HandBookEquipInfoPanel, _itemData.Id)
end)
end
function this.SingleItemDataShow(_go,_itemData,curEquipStarsConfig)
function this.SingleItemDataShow(_go,_itemData)
Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(GetQuantityImageByquality(curEquipStarsConfig.Quality))
Util.GetGameObject(_go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(itemConfig[_itemData.Id].ResourceID))
Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text=_itemData.Name
SetHeroStars(Util.GetGameObject(_go.transform, "star"), curEquipStarsConfig.Stars,1,nil,-15)
local choosed =Util.GetGameObject(_go.transform, "choosed")
choosed:SetActive(curSelectEquip.Id == _itemData .Id)
local redPoint = Util.GetGameObject(_go.transform,"redPoint")
redPoint:SetActive(bagPosEquips[curEquipStarsConfig.Id - 1] and bagPosEquips[curEquipStarsConfig.Id - 1] >= equipStarsConfig[curEquipStarsConfig.Id - 1].RankupCount)
if curSelectEquip.Id == _itemData .Id then
curSelectGO = _go
end
Util.AddOnceClick(Util.GetGameObject(_go.transform,"icon"), function()
if curSelectEquip.Id == _itemData .Id then
return
else
curSelectEquip = _itemData
choosed:SetActive(true)
if curSelectGO then
Util.GetGameObject(curSelectGO.transform, "choosed"):SetActive(false)
curSelectGO = _go
end
end
this.ShowTitleData(curEquipStarsConfig)
local starGrid = Util.GetGameObject(_go, "star")
SetHeroStars(starGrid, heroData.star)
Util.AddOnceClick(Util.GetGameObject(_go.transform,"upZhen"), function()
end)
Util.AddLongPressClick(Util.GetGameObject(_go.transform,"icon"), function()
UIManager.OpenPanel(UIName.HandBookEquipInfoPanel, _itemData.Id)
end, 0.5)
end
--加减方法
function this.CompoundNumChange(type)
if type == 1 then--加
compoundNum = compoundNum + 1
else--减
compoundNum = compoundNum - 1
end
--LogError("compoundNum "..compoundNum)
this.ShowGoldNum(equipStarsConfig[curSelectEquip.Star],compoundNum)
end
function this.Compound()
--LogError(" `````````````````` "..curIndex.." "..curSelectEquip.Star.." "..compoundNum)
if compoundNum <= 0 then
PopupTipPanel.ShowTip(Language[10431])
return
end
if not materidaIsCan then
UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.Gold })
return
end
NetManager.ComplexEquipRequest(curIndex,curSelectEquip.Star,compoundNum,function(msg)
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
this.OnClickTabBtn(curIndex)
end)
end)
end
function this.AutoCompound(_position)
--进度剩余的的装备材料的数量
local curPosEquips = EquipManager.GetEquipCompoundDataByEquipPosition1(_position)
local bagPosEquips = EquipManager.GetEquipCompoundDataByEquipPosition1(_position)
--进度需要的消耗材料的数量
local shengGoldNum = 0
--进度剩余的的消耗材料的数量
local bagNums = {}
--已有的消耗材料数量
for i = 1, #curPosEquips do
if equipStarsConfig[i].RankupResources then
for j = 1, #equipStarsConfig[i].RankupResources do
bagNums[equipStarsConfig[i].RankupResources[j][1]] = BagManager.GetItemCountById(equipStarsConfig[i].RankupResources[j][1])
end
end
end
--一种装备一种装备的循环检测 金币能合成的数量 与 背包装备能合成的数量 取最小值 然后扣除临时消耗道具
--最后所有装备存在curPosEquips 与 之前背包 bagPosEquips 作比较 看合成了什么装备 删除了什么装备 和计算消耗材料
local isNoGold = false--是否缺金币
for i = 1, #curPosEquips do
local materialEndNum = -1
--合成的1个 下一个装备的需要的消耗材料的数量
local materialNums = {}
--当前已有的消耗材料能合成的下一个装备的数量最大数量
if equipStarsConfig[i].RankupResources then
for j = 1, #equipStarsConfig[i].RankupResources do
local itemId = equipStarsConfig[i].RankupResources[j][1]
materialNums[itemId] = equipStarsConfig[i].RankupResources[j][2]
local curItmeCompoundNums =math.floor( bagNums[itemId] / equipStarsConfig[i].RankupResources[j][2])
if materialEndNum == -1 then
materialEndNum = curItmeCompoundNums
elseif materialEndNum > curItmeCompoundNums then
materialEndNum = curItmeCompoundNums
end
end
end
if i < #curPosEquips or i == 1 then
--当前拥有的装备材料能合成的下一个装备的数量
local curQuEquipCompoundNum = math.floor(curPosEquips[i] / equipStarsConfig[i].RankupCount)
local endCompoundNum = materialEndNum > curQuEquipCompoundNum and curQuEquipCompoundNum or materialEndNum
if not isNoGold and materialEndNum < 1 and curQuEquipCompoundNum > 0 then
isNoGold = true
end
for itemId, num in pairs(materialNums) do
bagNums[itemId] = bagNums[itemId] - endCompoundNum * num
shengGoldNum = shengGoldNum + endCompoundNum * num
end
curPosEquips[i] = curPosEquips[i] - endCompoundNum * equipStarsConfig[i].RankupCount
if curPosEquips[i + 1] then
curPosEquips[i + 1] = curPosEquips[i + 1] + endCompoundNum
end
end
end
local curRewards = {}
for i = 1, #curPosEquips do
local str = ""
if curPosEquips[i] - bagPosEquips[i] > 0 then
str = Language[10432]..i.." "..curPosEquips[i] - bagPosEquips[i]
local singleEquipData = {}
singleEquipData.id = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipConfig,"Position",curIndex,"Star",i).Id
singleEquipData.num = curPosEquips[i] - bagPosEquips[i]
table.insert(curRewards,{singleEquipData.id,singleEquipData.num})
else
str = str .. Language[10433]..bagPosEquips[i] - curPosEquips[i]
end
end
if isNoGold and #curRewards <= 0 then
PopupTipPanel.ShowTip(Language[10431])
return
end
if shengGoldNum <= 0 then
PopupTipPanel.ShowTip(Language[10434])
return
end
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.EquipCompound,
shengGoldNum,curRewards,function ()
NetManager.ComplexEquipRequest(curIndex,0,0,function(msg)
this.OnClickTabBtn(curIndex)
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
end)
end)
end)
end
-- tab节点显示自定义
function this.TabAdapter(tab, index, status)
local tabLab = Util.GetGameObject(tab, "Text")
local tabImage = Util.GetGameObject(tab,"Image")
tabImage:GetComponent("Image").sprite = Util.LoadSprite(_TabData[index][status])
tabImage:GetComponent("Image"):SetNativeSize()
tabLab:GetComponent("Text").text = _TabData[index].name
tabLab:GetComponent("Text").color = _TabFontColor[status]
tabImage.transform.localPosition = Vector3.New( tabImage.transform.localPosition.x, _TabImagePos[status], 0);
end
--切换视图
function this.SwitchView(index)
this.OnClickTabBtn(index)
end
function this:OnClose()
needGoldNum=0
end
function this:OnDestroy()
needGoldNum=0
end
return this