灵兽培养部分初始脚本

zhangqiang 2020-09-25 14:48:10 +08:00
parent 3bf0fbc623
commit f40b2050ad
15 changed files with 10275 additions and 4280 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 39cb8eb34216f894db49624585bc678c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 66890f7567c5f7b4a892fb2dea2d3914
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,171 @@
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"},
}
--初始化组件(用于子类重写)
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.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"))
end
end
--绑定事件(用于子类重写)
function PokemonListPanel:BindEvent()
Util.AddClick(this.btnBack, function()
self:ClosePanel()
end)
for i = 1, #this.contents do
this.contents[i].view: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
this.contents[i].view:AddListener()
end
end
--移除事件监听(用于子类重写)
function PokemonListPanel:RemoveListener()
for i = 1, #this.contents do
this.contents[i].view:RemoveListener()
end
end
--界面打开时调用(用于子类重写)
function PokemonListPanel:OnOpen(_curIndex)
curIndex = _curIndex and _curIndex or 1
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)
end
function PokemonListPanel:OnSortingOrderChange()
this.sortingOrder = self.sortingOrder
for i = 1, #this.contents do
this.contents[i].view:OnSortingOrderChange(self.sortingOrder)
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)
--先执行上一面板关闭逻辑
local oldSelect
oldSelect, curIndex = curIndex, index
for i = 1, #this.contents do
if oldSelect~=0 then this.contents[oldSelect].view:OnClose() break end
end
--切换预设显隐
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()
for i = 1, #this.contents do
this.contents[i].view:OnClose()
end
end
--界面销毁时调用(用于子类重写)
function PokemonListPanel:OnDestroy()
SubUIManager.Close(this.upView)
for i = 1, #this.contents do
this.contents[i].view:OnDestroy()
end
end
return PokemonListPanel

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 97ed7eaf935c2c8438046b84bc64c69a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,69 @@
require("Base/BasePanel")
local PokemonMainPanel = Inherit(BasePanel)
local this = PokemonMainPanel
--初始化组件(用于子类重写)
function PokemonMainPanel:InitComponent()
this.btnBack = Util.GetGameObject(self.transform, "btnBack")
this.btnHelp = Util.GetGameObject(self.transform, "helpBtn")
this.btnShop = Util.GetGameObject(self.transform, "btnEndRoot/btnShop")
this.btnInfo = Util.GetGameObject(self.transform, "btnEndRoot/btnInfo")
this.btnWarAddPro = Util.GetGameObject(self.transform, "btnEndRoot/btnWarAddPro")
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.callCount = Util.GetGameObject(self.transform, "callMonsterBtn/Text"):GetComponent("Text")
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
end
--绑定事件(用于子类重写)
function PokemonMainPanel: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.Adventure, pos.x, pos.y)
end)
Util.AddClick(this.btnBack, function()
this:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function PokemonMainPanel:AddListener()
-- Game.GlobalEvent:AddEvent(GameEvent.Adventure.CallAlianInvasionTime, this.CallAlianInvasionTimeCountDown)
end
--移除事件监听(用于子类重写)
function PokemonMainPanel:RemoveListener()
-- Game.GlobalEvent:RemoveEvent(GameEvent.Adventure.CallAlianInvasionTime, this.CallAlianInvasionTimeCountDown)
end
--界面打开时调用(用于子类重写)
function PokemonMainPanel:OnOpen(...)
-- 设置
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.AdventureTimes })
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function PokemonMainPanel:OnShow()
end
--界面关闭时调用(用于子类重写)
function PokemonMainPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function PokemonMainPanel:OnDestroy()
end
return PokemonMainPanel

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dc715e7b08d6ecb46bdeafea411e4356
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 038a38eed54b0b6479a6be81c0e4a468
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,373 @@
----- 灵兽羁绊 -----
local this = {}
local sortingOrder=0
local jewelConfig = ConfigManager.GetConfig(ConfigName.JewelConfig)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local TabBox = require("Modules/Common/TabBox")
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 tabs={}
function this:InitComponent(gameObject)
this.tabBox = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/TabBox")
this.needGoldText = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/compoundBtn/needGoldText"):GetComponent("Text")
this.compoundBtn = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/compoundBtn")
this.autoCompoundBtn = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/autoCompoundBtn")
this.addBtn = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/addBtn")
this.subtractBtn = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/subtractBtn")
this.numText = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/numText"):GetComponent("Text")
this.progressText = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/progressText"):GetComponent("Text")
this.needEquip = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/needEquip")
this.compoundEquip = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/compoundEquip")
this.progressImage = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/titleGo/progress/Image"):GetComponent("Image")
for i = 1, 5 do
tabs[i] = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/Tabs/grid/Btn" .. i)
end
this.selectBtn=Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/selectBtn")
this.equipPre = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/equipPre")
this.ScrollBar=Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/Scrollbar"):GetComponent("Scrollbar")
local v2 = Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/scroll"):GetComponent("RectTransform").rect
this.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(gameObject, "PokemonListPanel_Fetter/scroll").transform,
this.equipPre, this.ScrollBar, Vector2.New(-v2.x*2, -v2.y*2), 1, 5, Vector2.New(20,15))
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
end
function this:BindEvent()
Util.AddClick(this.compoundBtn, function()
PlaySoundWithoutClick("UI_wapapon_mixture_amulet")
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()
end
function this:RemoveListener()
end
local sortingOrder = 0
function this:OnSortingOrderChange(_sortingOrder)
sortingOrder = _sortingOrder
end
function this:OnShow(...)
curIndex = 1
sortingOrder =0
for i = 1,#tabs do
local index=i
Util.GetGameObject(tabs[i], "Image"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(index))
Util.AddClick(tabs[i], function()
this.TreasureBtnClick(tabs[i],index)
end)
end
this.TreasureBtnClick(tabs[1],1)
end
--宝物类型按钮点击事件
function this.TreasureBtnClick(_btn,_curIndex)
curIndex = _curIndex
this.SetBtnSelect(_btn)
this.ShowCurrPosTreasures()
end
--显示当前阵营的宝物
function this.ShowCurrPosTreasures()
local equipDatas = EquipTreasureManager.GetAllTabletTreasuresByRace(curIndex)
if equipDatas and #equipDatas > 0 then
curSelectEquip = equipDatas[1]
end
this.ShowTitleData(curSelectEquip)
this.ScrollView:SetData(equipDatas, function (index, go)
this.SingleItemDataShow(go, equipDatas[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.SetBtnSelect(_parObj)
this.selectBtn.transform:SetParent(_parObj.transform)
this.selectBtn.transform.localScale = Vector3.one
this.selectBtn.transform.localPosition=Vector3.zero
end
function this.ShowTitleData(_data)
local allCanCompoundEquips = EquipTreasureManager.GetBagCompoundEquipDatasByequipSData(_data)
this.ShowTitleEquipData(this.compoundEquip,curSelectEquip,curSelectEquip.frame,curSelectEquip.Id)
this.ShowTitleEquipData(this.needEquip,curSelectEquip,curSelectEquip.lowFrame,curSelectEquip.lowId)--需要的材料
this.progressText.text = #allCanCompoundEquips .. "/" .. curSelectEquip.quaUpCount
this.progressImage.fillAmount = #allCanCompoundEquips/curSelectEquip.quaUpCount
compoundNum = math.floor(#allCanCompoundEquips/curSelectEquip.quaUpCount)
compoundMaxNum = math.floor(#allCanCompoundEquips/curSelectEquip.quaUpCount)
local costCoin = jewelConfig[curSelectEquip.Id-1].RankupResources
this.ShowGoldNum(costCoin,compoundNum)
end
--显示金币数量
function this.ShowGoldNum(_costData,_num)
local needGoldNum = _costData[1][2]*_num
local id=_costData[1][1]
if needGoldNum > BagManager.GetItemCountById(id) 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,_frame,_id)
Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(_frame)
Util.GetGameObject(_go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(_itemData.icon)
Util.GetGameObject(_go.transform,"proImg"):GetComponent("Image").sprite=Util.LoadSprite(GetProStrImageByProNum(itemConfig[_itemData.Id].PropertyName))
Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text=_itemData.name
Util.GetGameObject(_go.transform, "star").gameObject:SetActive(false)
Util.AddClick(Util.GetGameObject(_go.transform,"icon"), function()
--UIManager.OpenPanel(UIName.HandBookEquipInfoPanel, _itemData.Id)
UIManager.OpenPanel(UIName.RewardTalismanSingleShowPopup, 0,nil,_id, 0, 0,nil)
end)
end
--宝物列表宝物数据显示
function this.SingleItemDataShow(_go,_itemData)
Util.GetGameObject(_go.transform,"frame"):GetComponent("Image").sprite=Util.LoadSprite(_itemData.frame)
Util.GetGameObject(_go.transform,"icon"):GetComponent("Image").sprite=Util.LoadSprite(_itemData.icon)
Util.GetGameObject(_go,"proImg"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(itemConfig[_itemData.Id].PropertyName))
Util.GetGameObject(_go.transform,"name"):GetComponent("Text").text=_itemData.name
SetHeroStars(Util.GetGameObject(_go.transform, "star"), 0)
local choosed =Util.GetGameObject(_go.transform, "choosed")
choosed.gameObject:SetActive(curSelectEquip.Id == _itemData.Id)
local redPoint = Util.GetGameObject(_go.transform,"redPoint")
local haveCount=LengthOfTable(EquipTreasureManager.GetBagCompoundEquipDatasByequipSData(_itemData))
redPoint:SetActive( haveCount>= _itemData.quaUpCount)
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(_itemData)
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)
local costCoin = jewelConfig[curSelectEquip.Id-1].RankupResources
this.ShowGoldNum(costCoin,compoundNum)
end
function this.Compound()
--LogError(" `````````````````` "..curIndex.." "..curSelectEquip.Star.." "..compoundNum)
if compoundNum <= 0 then
PopupTipPanel.ShowTip(Language[10431])
return
end
if not materidaIsCan then
PopupTipPanel.ShowTip(Language[12193])
-- UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.Gold })
return
end
NetManager.ComplexTreasureRequest(curSelectEquip.equipType,curIndex,curSelectEquip.quantity,compoundNum,function(msg)
for i = 1, #msg.equipIds do
EquipTreasureManager.RemoveTreasureByIdDyn(msg.equipIds[i])
end
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
this.ShowCurrPosTreasures()
end)
end)
end
--一种装备一种装备的循环检测 金币能合成的数量 与 背包装备能合成的数量 取最小值 然后扣除临时消耗道具
--最后所有装备存在curPosEquips 与 之前背包 bagPosEquips 作比较 看合成了什么装备 删除了什么装备 和计算消耗材料
function this.AutoCompound(_position)
local goldIsEnough = true
--表数据
local curPosEquips = EquipTreasureManager.GetAllTabletTreasuresByRaceAndType(_position)--,curSelectEquip.equipType)
--实际数据
local curPosEquipsData = EquipTreasureManager.GeEquipTreasureDatas(_position)
local totalGoldNum = 0
--jwelConfig.RankupResourcess对应所有背包数据
local bagNums = {}
--循环宝物的表消耗道具,得出对应的背包数据
for i = 1, #curPosEquips do
local equipData = curPosEquips[i]
for j = 1, #equipData.costCoin do
if not bagNums[equipData.costCoin[j][1]] then
bagNums[equipData.costCoin[j][1]] = BagManager.GetItemCountById(equipData.costCoin[j][1])
end
end
end
-- --LogGreen(LengthOfTable(bagNums))
-- for n,m in pairs(bagNums) do
-- --LogGreen("bagNums id:"..n.." num:"..m)
-- end
--循环宝物的表数据,得到可以合成的宝物数量
for i = 1, #curPosEquips do
local equipData = curPosEquips[i]
--从表消耗道具得出可以合成的数量
local materialEndNum = -1
--循环宝物的表消耗数据,得出对应的消耗数据
for j = 1, #equipData.costCoin do
--可以合成的宝物数量
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelConfig,"Location",equipData.equipType,"Level",equipData.quantity-1,"Race",_position)
local curItmeCompoundNums = math.floor(bagNums[config.RankupResources[j][1]] / config.RankupResources[j][2])
if materialEndNum == -1 then
materialEndNum = curItmeCompoundNums
elseif materialEndNum > curItmeCompoundNums then
materialEndNum = curItmeCompoundNums
end
end
--LogGreen("materialEndNum:"..materialEndNum)
if materialEndNum > 0 then
--可消耗宝物的数量 (没有强化,没有精炼,没有装备,同样的位置,品级-1
local materialHaveNum= curPosEquipsData[equipData.equipType][equipData.quantity-1]
--LogGreen("equipData.quantity-1:".. equipData.quantity - 1 .."num:".. materialHaveNum)
--可以合成的
local nextCompoundNum = math.floor(materialHaveNum / equipData.quaUpCount)
--LogGreen("可以合成:".. nextCompoundNum .."个品质为"..equipData.quantity.."的宝器")
--消耗物品可以合成的和材料合成的作比较,取最小值
local endCompoundNum = materialEndNum > nextCompoundNum and nextCompoundNum or materialEndNum
--LogGreen("结合材料可以合成:".. endCompoundNum .."个品质为"..equipData.quantity.."的宝器")
--如果当前品质宝物可以合成就把当前品质的id及合成的数量储存判断下一个品质加上当前合成的是否能多合成
if endCompoundNum > 0 then
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelConfig,"Location",equipData.equipType,"Level",equipData.quantity-1,"Race",_position)
if not config then
LogRed("Location:".. equipData.equipType .." Level".. equipData.quantity-1 .." Race".. _position)
else
for j = 1, #config.RankupResources do
bagNums[config.RankupResources[j][1]] =
bagNums[config.RankupResources[j][1]] - endCompoundNum * config.RankupResources[j][2]
totalGoldNum = totalGoldNum + endCompoundNum * config.RankupResources[j][2]
--LogGreen("合成:".. endCompoundNum .."个品质为"..equipData.quantity.."的宝器需要消耗"..config.RankupResources[j][1].." "..endCompoundNum * config.RankupResources[j][2])
--LogGreen("bagNums[config.RankupResources[j][1]]:"..bagNums[config.RankupResources[j][1]])
end
--消耗之后剩余的数量
--LogGreen("消耗curPosEquipsData[equipData.equipType][equipData.quantity - 1]之前:"..curPosEquipsData[equipData.equipType][equipData.quantity - 1])
curPosEquipsData[equipData.equipType][equipData.quantity - 1] = materialHaveNum - (endCompoundNum * equipData.quaUpCount)
--LogGreen("合成:".. endCompoundNum .."个品质为"..equipData.quantity.."的宝器需要消耗".. equipData.quantity - 1 .." "..endCompoundNum * equipData.quaUpCount)
--LogGreen("消耗curPosEquipsData[equipData.equipType][equipData.quantity - 1]之后:"..curPosEquipsData[equipData.equipType][equipData.quantity - 1])
--LogGreen("合成curPosEquipsData[equipData.equipType][equipData.quantity]之前:"..curPosEquipsData[equipData.equipType][equipData.quantity])
curPosEquipsData[equipData.equipType][equipData.quantity] = curPosEquipsData[equipData.equipType][equipData.quantity] + endCompoundNum
--LogGreen("合成curPosEquipsData[equipData.equipType][equipData.quantity]之后:"..curPosEquipsData[equipData.equipType][equipData.quantity])
end
end
else
goldIsEnough = false
end
end
local origiData = EquipTreasureManager.GeEquipTreasureDatas(_position)
local endReward={}
for i, v in pairs(curPosEquipsData) do
for n, m in pairs(v) do
--LogGreen("m:"..m.." origiData[i][n]:"..origiData[i][n])
if m > origiData[i][n] then
local config = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelConfig,"Location",i,"Level",n,"Race",_position)
local num = m - origiData[i][n]
--LogGreen("config.id:"..config.Id.." num:"..m - origiData[i][n])
table.insert(endReward,{config.Id,num})
end
end
end
if not goldIsEnough and LengthOfTable(endReward) < 1 then
PopupTipPanel.ShowTip("金币不足,无法合成")
return
elseif LengthOfTable(endReward) < 1 then
PopupTipPanel.ShowTip(Language[12258])
return
end
--BagManager.GetItemCountById(14) -
--LogGreen("totalGoldNum:"..totalGoldNum)
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.TreasureCompound,totalGoldNum,endReward,function ()
NetManager.ComplexTreasureRequest(curSelectEquip.equipType,curIndex,0,0, function(msg)
for i = 1, #msg.equipIds do
EquipTreasureManager.RemoveTreasureByIdDyn(msg.equipIds[i])
end
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
this.ShowCurrPosTreasures()
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()
end
function this:OnDestroy()
end
return this

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fa3e19033732d584ba073ab1fa2afd77
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,29 @@
----- 灵兽列表 和 合成 -----
local this = {}
local sortingOrder=0
function this:InitComponent(gameObject)
end
function this:BindEvent()
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(...)
end
function this:OnClose()
end
function this:OnDestroy()
end
return this

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 39ce1fd5125121344997d2b8790595f3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,345 @@
----- 选择出战灵兽 -----
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
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))
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()
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)
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
--加减方法
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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 115c814417a4e3548be63fdb82843d01
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: