Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
local CraftingCtrl = class("CraftingCtrl", BaseCtrl)
|
||||
CraftingCtrl._mapNodeConfig = {
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
rtToggle = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
togItem = {},
|
||||
bgRing = {},
|
||||
goMatProduction = {
|
||||
sNodeName = "---MatProduction---",
|
||||
sCtrlName = "Game.UI.Crafting.MatCraftingCtrl"
|
||||
},
|
||||
goPresentsProduction = {
|
||||
sNodeName = "---PresentsProduction---"
|
||||
},
|
||||
animRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
}
|
||||
}
|
||||
CraftingCtrl._mapEventConfig = {
|
||||
JumpToProduction = "OnEvent_JumpToProduction",
|
||||
PlayCraftingAnim = "OnEvent_PlayCraftingAnim",
|
||||
SetCraftingEmpty = "OnEvent_SetCraftingEmpty"
|
||||
}
|
||||
function CraftingCtrl:InitTog()
|
||||
self.tbAllProduction = PlayerData.Crafting:GetProductionPageList()
|
||||
local index = 1
|
||||
local addTogItem = function(nTog, nType)
|
||||
local togObj = instantiate(self._mapNode.togItem, self._mapNode.rtToggle)
|
||||
local togCtrl = self:BindCtrlByNode(togObj, "Game.UI.TemplateEx.TemplateToggleCtrl")
|
||||
local btn = togObj.transform:GetComponent("UIButton")
|
||||
local func_Handler = ui_handler(self, self.OnBtnClick_Tog, togObj, index)
|
||||
btn.onClick:AddListener(func_Handler)
|
||||
togCtrl.gameObject:SetActive(true)
|
||||
table.insert(self.tbTogCtrl, {
|
||||
ctrl = togCtrl,
|
||||
nTog = nTog,
|
||||
nType = nType
|
||||
})
|
||||
return togCtrl
|
||||
end
|
||||
for _, v in ipairs(self.tbAllProduction) do
|
||||
local togItemCtrl = addTogItem(AllEnum.CraftingToggle.Material, v.nType)
|
||||
local tbCfg = ConfigTable.GetData("ProductionType", v.nType)
|
||||
togItemCtrl:SetText(tbCfg.TypeName)
|
||||
togItemCtrl:SetDefault(false)
|
||||
index = index + 1
|
||||
end
|
||||
if 0 == self.nSelectTogIndex then
|
||||
self.nSelectTogIndex = 1
|
||||
end
|
||||
self.tbTogCtrl[self.nSelectTogIndex].ctrl:SetDefault(true)
|
||||
self._mapNode.goMatProduction.gameObject:SetActive(false)
|
||||
if nil ~= self.tbTogCtrl[self.nSelectTogIndex].nType then
|
||||
self:RefreshMtCrafting(self.tbTogCtrl[self.nSelectTogIndex].nType)
|
||||
else
|
||||
printError("神器合成功能已移除")
|
||||
end
|
||||
end
|
||||
function CraftingCtrl:RefreshMtCrafting(nType, bReset)
|
||||
self._mapNode.goMatProduction.gameObject:SetActive(true)
|
||||
local tbProductionList
|
||||
for _, v in ipairs(self.tbAllProduction) do
|
||||
if v.nType == nType then
|
||||
tbProductionList = v.tbList
|
||||
end
|
||||
end
|
||||
if nil ~= tbProductionList then
|
||||
if bReset then
|
||||
self._mapNode.goMatProduction:ResetSelectProduction()
|
||||
end
|
||||
self._mapNode.goMatProduction:RefreshProductionList(tbProductionList)
|
||||
end
|
||||
end
|
||||
function CraftingCtrl:SelectTog(nIndex)
|
||||
if nIndex == self.nSelectTogIndex then
|
||||
return
|
||||
end
|
||||
self.tbTogCtrl[nIndex].ctrl:SetTrigger(true)
|
||||
self.tbTogCtrl[self.nSelectTogIndex].ctrl:SetTrigger(false)
|
||||
local lastTogType = self.tbTogCtrl[self.nSelectTogIndex].nTog
|
||||
local curTogType = self.tbTogCtrl[nIndex].nTog
|
||||
local bReset = true
|
||||
self.nSelectTogIndex = nIndex
|
||||
self._mapNode.goMatProduction.gameObject:SetActive(false)
|
||||
self._mapNode.goPresentsProduction.gameObject:SetActive(false)
|
||||
if nil ~= self.tbTogCtrl[self.nSelectTogIndex].nType then
|
||||
self:RefreshMtCrafting(self.tbTogCtrl[self.nSelectTogIndex].nType, bReset)
|
||||
if bReset then
|
||||
self._mapNode.animRoot:Play("CraftingPanel_switch_mat")
|
||||
else
|
||||
end
|
||||
end
|
||||
end
|
||||
function CraftingCtrl:FadeIn()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
self._mapNode.animRoot:Play("CraftingPanel_in")
|
||||
end
|
||||
function CraftingCtrl:Awake()
|
||||
self.tbTogCtrl = {}
|
||||
self.nSelectTogIndex = 0
|
||||
self._mapNode.togItem.gameObject:SetActive(false)
|
||||
self._mapNode.goPresentsProduction.gameObject:SetActive(false)
|
||||
end
|
||||
function CraftingCtrl:OnEnable()
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self:InitTog()
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function CraftingCtrl:OnDisable()
|
||||
for _, v in ipairs(self.tbTogCtrl) do
|
||||
destroy(v.ctrl.gameObject)
|
||||
self:UnbindCtrlByNode(v.ctrl)
|
||||
end
|
||||
self.tbTogCtrl = {}
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.CraftingTip)
|
||||
end
|
||||
function CraftingCtrl:OnDestroy()
|
||||
end
|
||||
function CraftingCtrl:OnBtnClick_Tog(btn, nIndex)
|
||||
self:SelectTog(nIndex)
|
||||
end
|
||||
function CraftingCtrl:OnEvent_JumpToProduction(nProductionId)
|
||||
local nTogIndex = 0
|
||||
for k, v in ipairs(self.tbAllProduction) do
|
||||
for _, data in ipairs(v.tbList) do
|
||||
if data.Id == nProductionId then
|
||||
nTogIndex = k
|
||||
self._mapNode.goMatProduction:RefreshProductionList(v.tbList, data.Id)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if 0 == nTogIndex then
|
||||
printError("神器合成功能已移除")
|
||||
end
|
||||
if 0 ~= nTogIndex then
|
||||
self:SelectTog(nTogIndex)
|
||||
end
|
||||
end
|
||||
function CraftingCtrl:OnEvent_PlayCraftingAnim(callback)
|
||||
self._mapNode.animRoot:Play("CraftingPanel_make", 0, 0)
|
||||
CS.WwiseAudioManager.Instance:PostEvent("ui_craft_effect")
|
||||
local nAnimLength = 0.5
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLength)
|
||||
if nil ~= callback then
|
||||
self:AddTimer(1, nAnimLength, callback, true, true, true)
|
||||
end
|
||||
end
|
||||
function CraftingCtrl:OnEvent_SetCraftingEmpty(bEmpty)
|
||||
self._mapNode.bgRing:SetActive(not bEmpty)
|
||||
end
|
||||
return CraftingCtrl
|
||||
@@ -0,0 +1,16 @@
|
||||
local CraftingPanel = class("CraftingPanel", BasePanel)
|
||||
CraftingPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Crafting/CraftingPanel.prefab",
|
||||
sCtrlName = "Game.UI.Crafting.CraftingCtrl"
|
||||
}
|
||||
}
|
||||
function CraftingPanel:Awake()
|
||||
end
|
||||
function CraftingPanel:OnEnable()
|
||||
end
|
||||
function CraftingPanel:OnDisable()
|
||||
end
|
||||
function CraftingPanel:OnDestroy()
|
||||
end
|
||||
return CraftingPanel
|
||||
@@ -0,0 +1,100 @@
|
||||
local CraftingTipCtrl = class("CraftingTipCtrl", BaseCtrl)
|
||||
CraftingTipCtrl._mapNodeConfig = {
|
||||
imgBlurredBg = {},
|
||||
goWindow = {},
|
||||
animWindow = {sNodeName = "goWindow", sComponentName = "Animator"},
|
||||
txtTitle = {
|
||||
sNodeName = "txtWindowTitle",
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "UITitle_Crafting"
|
||||
},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
btnBg = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
safeAreaRoot = {
|
||||
sNodeName = "----SafeAreaRoot----"
|
||||
},
|
||||
animRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
bgRing = {},
|
||||
goMatProduction = {
|
||||
sNodeName = "---MatProduction---",
|
||||
sCtrlName = "Game.UI.Crafting.MatCraftingCtrl"
|
||||
}
|
||||
}
|
||||
CraftingTipCtrl._mapEventConfig = {
|
||||
CloseCraftingTipPanel = "Close",
|
||||
PlayCraftingAnim = "OnEvent_PlayCraftingAnim",
|
||||
[EventId.JumpToSuccess] = "OnEvent_JumpTo",
|
||||
SetCraftingEmpty = "OnEvent_SetCraftingEmpty"
|
||||
}
|
||||
function CraftingTipCtrl:RefreshContent()
|
||||
local tbCfg = ConfigTable.GetData("Production", self.nProductionId)
|
||||
local nGroupId = tbCfg.Group
|
||||
local tbProductionList = PlayerData.Crafting:GetProductionListByGroup(nGroupId)
|
||||
if nil ~= tbProductionList then
|
||||
self._mapNode.goMatProduction:RefreshProductionList(tbProductionList, self.nProductionId)
|
||||
end
|
||||
end
|
||||
function CraftingTipCtrl:Close(callback)
|
||||
self.closeCallback = callback
|
||||
self._mapNode.animWindow:Play("t_window_04_t_out")
|
||||
self._mapNode.imgBlurredBg:SetActive(false)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
self:AddTimer(1, 0.3, "OnCloseAnimFinish", true, true, true)
|
||||
end
|
||||
function CraftingTipCtrl:OnCloseAnimFinish()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.CraftingTip)
|
||||
if nil ~= self.closeCallback then
|
||||
self.closeCallback()
|
||||
end
|
||||
end
|
||||
function CraftingTipCtrl:Awake()
|
||||
local tbParams = self:GetPanelParam()
|
||||
if type(tbParams) == "table" then
|
||||
self.nProductionId = tbParams[1]
|
||||
end
|
||||
end
|
||||
function CraftingTipCtrl:OnEnable()
|
||||
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
|
||||
self._mapNode.imgBlurredBg.gameObject:SetActive(true)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
|
||||
self._mapNode.animWindow:Play("t_window_04_t_in")
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self:RefreshContent()
|
||||
end
|
||||
function CraftingTipCtrl:OnDisable()
|
||||
end
|
||||
function CraftingTipCtrl:OnDestroy()
|
||||
end
|
||||
function CraftingTipCtrl:OnBtnClick_Close()
|
||||
self:Close()
|
||||
end
|
||||
function CraftingTipCtrl:OnEvent_PlayCraftingAnim(callback)
|
||||
self._mapNode.animRoot:Play("CraftingPanel_make", 0, 0)
|
||||
CS.WwiseAudioManager.Instance:PostEvent("ui_craft_effect")
|
||||
local nAnimLength = 0.5
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLength)
|
||||
if nil ~= callback then
|
||||
self:AddTimer(1, nAnimLength, callback, true, true, true)
|
||||
end
|
||||
end
|
||||
function CraftingTipCtrl:OnEvent_JumpTo(nType)
|
||||
if nType ~= GameEnum.jumpType.Crafting then
|
||||
self:Close()
|
||||
end
|
||||
end
|
||||
function CraftingTipCtrl:OnEvent_SetCraftingEmpty(bEmpty)
|
||||
self._mapNode.bgRing:SetActive(not bEmpty)
|
||||
end
|
||||
return CraftingTipCtrl
|
||||
@@ -0,0 +1,17 @@
|
||||
local CraftingTipPanel = class("CraftingTipPanel", BasePanel)
|
||||
CraftingTipPanel._bIsMainPanel = false
|
||||
CraftingTipPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Crafting/CraftingTipPanel.prefab",
|
||||
sCtrlName = "Game.UI.Crafting.CraftingTipCtrl"
|
||||
}
|
||||
}
|
||||
function CraftingTipPanel:Awake()
|
||||
end
|
||||
function CraftingTipPanel:OnEnable()
|
||||
end
|
||||
function CraftingTipPanel:OnDisable()
|
||||
end
|
||||
function CraftingTipPanel:OnDestroy()
|
||||
end
|
||||
return CraftingTipPanel
|
||||
@@ -0,0 +1,317 @@
|
||||
local MatCraftingCtrl = class("MatCraftingCtrl", BaseCtrl)
|
||||
MatCraftingCtrl._mapNodeConfig = {
|
||||
sv = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
trSv = {sNodeName = "sv", sComponentName = "Transform"},
|
||||
goCraftingContent = {},
|
||||
btnCraftingItem = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CraftingItem"
|
||||
},
|
||||
imgItemIcon = {sComponentName = "Image"},
|
||||
txtItemCount = {sComponentName = "TMP_Text"},
|
||||
txtCrafting = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Crafting_Count_Text"
|
||||
},
|
||||
txtCraftingCount = {sComponentName = "TMP_Text"},
|
||||
txtMaterial = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Crafting_Material_Title"
|
||||
},
|
||||
goMaterialList = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
btnMaterial = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_MaterialItem",
|
||||
nCount = 4
|
||||
},
|
||||
goMaterialItem = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateMatCtrl",
|
||||
nCount = 4
|
||||
},
|
||||
btnReduceCount = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Reduce"
|
||||
},
|
||||
btnAddCount = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Add"
|
||||
},
|
||||
btnReduceGray = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_ReduceGray"
|
||||
},
|
||||
btnAddGray = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_AddGray"
|
||||
},
|
||||
imgCountSlider = {
|
||||
sComponentName = "Slider",
|
||||
callback = "OnSliderValueChange"
|
||||
},
|
||||
btnCrafting = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Crafting"
|
||||
},
|
||||
txtBtnCrafting = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Crafting_Btn_Text"
|
||||
},
|
||||
goEmpty = {},
|
||||
txtEmpty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Crafting_Empty"
|
||||
}
|
||||
}
|
||||
MatCraftingCtrl._mapEventConfig = {
|
||||
CraftingSuccess = "OnRefreshCraftingItem"
|
||||
}
|
||||
function MatCraftingCtrl:RefreshProductionList(tbList, nSelectPId)
|
||||
self.tbProduction = tbList
|
||||
for insId, objCtrl in pairs(self.tbProductionCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbProductionCtrl[insId] = nil
|
||||
end
|
||||
self.nWorldClass = PlayerData.Base:GetWorldClass()
|
||||
if nil ~= nSelectPId then
|
||||
self.nSelectPId = nSelectPId
|
||||
end
|
||||
local nSelectIndex
|
||||
if nil ~= self.nSelectPId then
|
||||
for k, v in ipairs(self.tbProduction) do
|
||||
if v.Id == self.nSelectPId then
|
||||
nSelectIndex = k
|
||||
end
|
||||
end
|
||||
end
|
||||
self._mapNode.sv:Init(#self.tbProduction, self, self.OnRefreshGrid, self.OnGridBtnClick)
|
||||
if nil ~= nSelectIndex then
|
||||
self._mapNode.sv:SetScrollGridPos(nSelectIndex - 1, 0.1, 1)
|
||||
end
|
||||
self:OnSelectMtProduction(self.nSelectPId)
|
||||
self:RefreshCraftingCount()
|
||||
NovaAPI.SetSliderValue(self._mapNode.imgCountSlider, self.nCraftingCount)
|
||||
end
|
||||
function MatCraftingCtrl:OnRefreshGrid(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local data = self.tbProduction[nIndex]
|
||||
if data == nil then
|
||||
goGrid:SetActive(false)
|
||||
return
|
||||
end
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
if not self.tbProductionCtrl[nInstanceId] then
|
||||
self.tbProductionCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.Crafting.MatProductionItemCtrl")
|
||||
end
|
||||
goGrid.gameObject:SetActive(true)
|
||||
data.Unlock = data.UnlockWorldLevel <= self.nWorldClass
|
||||
self.tbProductionCtrl[nInstanceId]:SetData(data)
|
||||
if self.nSelectPId == 0 and data.Unlock then
|
||||
self.nSelectPId = data.Id
|
||||
end
|
||||
if self.nSelectPId == data.Id then
|
||||
self.nSelectIndex = nIndex
|
||||
self.tbProductionCtrl[nInstanceId]:SetSelect(true)
|
||||
end
|
||||
end
|
||||
function MatCraftingCtrl:OnGridBtnClick(goGrid, gridIndex)
|
||||
local nIndex = gridIndex + 1
|
||||
local data = self.tbProduction[nIndex]
|
||||
if not data.Unlock then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Crafting_Lock_Tip"))
|
||||
return
|
||||
end
|
||||
if self.nSelectPId == data.Id then
|
||||
return
|
||||
end
|
||||
local nInstanceId = goGrid:GetInstanceID()
|
||||
local goSelect = self._mapNode.trSv:Find("Viewport/Content/" .. self.nSelectIndex - 1)
|
||||
if goSelect then
|
||||
self.tbProductionCtrl[goSelect.gameObject:GetInstanceID()]:SetSelect(false)
|
||||
end
|
||||
self.tbProductionCtrl[nInstanceId]:SetSelect(true)
|
||||
self.nSelectIndex = nIndex
|
||||
self.nSelectPId = data.Id
|
||||
self:OnSelectMtProduction(self.nSelectPId)
|
||||
end
|
||||
function MatCraftingCtrl:RefreshCraftingCount()
|
||||
local bEmpty = self.nSelectPId == nil or self.nSelectPId == 0
|
||||
self._mapNode.goEmpty:SetActive(bEmpty)
|
||||
self._mapNode.goCraftingContent:SetActive(not bEmpty)
|
||||
EventManager.Hit("SetCraftingEmpty", bEmpty)
|
||||
if bEmpty then
|
||||
return
|
||||
end
|
||||
local tbCfgData = PlayerData.Crafting:GetProductionById(self.nSelectPId)
|
||||
if tbCfgData == nil then
|
||||
return
|
||||
end
|
||||
self._mapNode.goEmpty:SetActive(false)
|
||||
self._mapNode.goCraftingContent:SetActive(true)
|
||||
for k, v in ipairs(tbCfgData.MaterialList) do
|
||||
self._mapNode.btnMaterial[k].interactable = nil ~= self._mapNode.goMaterialItem[k]
|
||||
if nil ~= self._mapNode.goMaterialItem[k] then
|
||||
self._mapNode.goMaterialItem[k]:SetMat(v.nItemId, self.nCraftingCount * v.nCount)
|
||||
end
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCraftingCount, self.nCraftingCount)
|
||||
self._mapNode.btnAddCount.gameObject:SetActive(self.nCraftingCount < self.nMaxCraftingCount)
|
||||
self._mapNode.btnAddGray.gameObject:SetActive(self.nCraftingCount >= self.nMaxCraftingCount)
|
||||
self._mapNode.btnReduceCount.gameObject:SetActive(self.nCraftingCount > 1)
|
||||
self._mapNode.btnReduceGray.gameObject:SetActive(self.nCraftingCount <= 1)
|
||||
end
|
||||
function MatCraftingCtrl:ResetSelectProduction()
|
||||
self.nSelectPId = 0
|
||||
end
|
||||
function MatCraftingCtrl:Awake()
|
||||
self.nSelectPId = 0
|
||||
self.nMaxCraftingCount = 0
|
||||
self.nMaxCraftingCountCfg = ConfigTable.GetConfigNumber("MaterialCraftingLimit")
|
||||
self.nCraftingCount = 1
|
||||
self.tbProductionCtrl = {}
|
||||
end
|
||||
function MatCraftingCtrl:OnEnable()
|
||||
end
|
||||
function MatCraftingCtrl:OnDisable()
|
||||
for insId, objCtrl in pairs(self.tbProductionCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbProductionCtrl[insId] = nil
|
||||
end
|
||||
self.tbProductionCtrl = {}
|
||||
end
|
||||
function MatCraftingCtrl:OnDestroy()
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_CraftingItem(btn)
|
||||
local mapData = {
|
||||
nTid = self.nProductionId,
|
||||
bShowDepot = true,
|
||||
bShowJumpto = true
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ItemTips, btn.transform, mapData)
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_MaterialItem(btn, index)
|
||||
local tbCfgData = PlayerData.Crafting:GetProductionById(self.nSelectPId)
|
||||
if nil ~= tbCfgData.MaterialList[index] then
|
||||
local mapData = {
|
||||
nTid = tbCfgData.MaterialList[index].nItemId,
|
||||
bShowDepot = true,
|
||||
bShowJumpto = true
|
||||
}
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.ItemTips, btn.transform, mapData)
|
||||
end
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_Reduce(btn)
|
||||
if self.nCraftingCount <= 1 then
|
||||
return
|
||||
end
|
||||
if btn.Operate_Type == 0 then
|
||||
self.nCraftingCount = self.nCraftingCount - 1
|
||||
elseif btn.Operate_Type == 3 then
|
||||
local nAdd = 2 ^ btn.CurrentGear
|
||||
self.nCraftingCount = math.floor(self.nCraftingCount - nAdd)
|
||||
end
|
||||
if self.nCraftingCount < 1 then
|
||||
self.nCraftingCount = 1
|
||||
end
|
||||
self:RefreshCraftingCount()
|
||||
NovaAPI.SetSliderValue(self._mapNode.imgCountSlider, self.nCraftingCount)
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_Add(btn)
|
||||
if self.nCraftingCount >= self.nMaxCraftingCount then
|
||||
return
|
||||
end
|
||||
if btn.Operate_Type == 0 then
|
||||
self.nCraftingCount = self.nCraftingCount + 1
|
||||
elseif btn.Operate_Type == 3 then
|
||||
local nAdd = 2 ^ btn.CurrentGear
|
||||
self.nCraftingCount = math.floor(self.nCraftingCount + nAdd)
|
||||
end
|
||||
self.nCraftingCount = self.nCraftingCount > self.nMaxCraftingCount and self.nMaxCraftingCount or self.nCraftingCount
|
||||
self:RefreshCraftingCount()
|
||||
NovaAPI.SetSliderValue(self._mapNode.imgCountSlider, self.nCraftingCount)
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_ReduceGray()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Crafting_Count_Min"))
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_AddGray()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Crafting_Count_Max"))
|
||||
end
|
||||
function MatCraftingCtrl:OnSliderValueChange(_, value)
|
||||
self.nCraftingCount = math.ceil(value)
|
||||
self:RefreshCraftingCount()
|
||||
end
|
||||
function MatCraftingCtrl:OnBtnClick_Crafting()
|
||||
if self.nCraftingCount == 0 then
|
||||
return
|
||||
end
|
||||
local bEnough = true
|
||||
local tbCfgData = PlayerData.Crafting:GetProductionById(self.nSelectPId)
|
||||
for k, v in ipairs(tbCfgData.MaterialList) do
|
||||
local hasCount = PlayerData.Item:GetItemCountByID(v.nItemId)
|
||||
if hasCount < self.nCraftingCount * v.nCount then
|
||||
bEnough = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if not bEnough then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Crafting_Material_Not_Enough"))
|
||||
return
|
||||
end
|
||||
local sucFunc = function()
|
||||
EventManager.Hit("CraftingSuccess")
|
||||
end
|
||||
EventManager.Hit("PlayCraftingAnim", function()
|
||||
PlayerData.Crafting:SendMaterialCrafting(self.nSelectPId, self.nCraftingCount, sucFunc)
|
||||
end)
|
||||
end
|
||||
function MatCraftingCtrl:OnSelectMtProduction(nId)
|
||||
self.nSelectPId = nId
|
||||
self.nMaxCraftingCount = -1
|
||||
self.nCraftingCount = 1
|
||||
local tbCfgData = PlayerData.Crafting:GetProductionById(self.nSelectPId)
|
||||
if nil ~= tbCfgData then
|
||||
self.nProductionId = tbCfgData.ShowProductionId == 0 and tbCfgData.ProductionId or tbCfgData.ShowProductionId
|
||||
local nCount = tbCfgData.ShowProductionId == 0 and tbCfgData.ProductionPerBatch or tbCfgData.ShowProductionPerBatch
|
||||
local itemCfg = ConfigTable.GetData_Item(self.nProductionId)
|
||||
self:SetPngSprite(self._mapNode.imgItemIcon, itemCfg.Icon)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemCount, orderedFormat(ConfigTable.GetUIText("Crafting_Item_Count"), nCount))
|
||||
for k, v in ipairs(self._mapNode.btnMaterial) do
|
||||
local tbMaterialInfo = tbCfgData.MaterialList[k]
|
||||
local itemCtrl = self._mapNode.goMaterialItem[k]
|
||||
v.interactable = nil ~= tbMaterialInfo
|
||||
if nil ~= tbMaterialInfo then
|
||||
v.gameObject:SetActive(true)
|
||||
itemCtrl:SetMat(tbMaterialInfo.nItemId, nil)
|
||||
local hasCount = PlayerData.Item:GetItemCountByID(tbMaterialInfo.nItemId)
|
||||
local nCount = math.floor(hasCount / tbMaterialInfo.nCount)
|
||||
if -1 == self.nMaxCraftingCount then
|
||||
self.nMaxCraftingCount = nCount
|
||||
end
|
||||
self.nMaxCraftingCount = nCount < self.nMaxCraftingCount and nCount or self.nMaxCraftingCount
|
||||
else
|
||||
itemCtrl:SetMat(0)
|
||||
end
|
||||
end
|
||||
self.nMaxCraftingCount = self.nMaxCraftingCount > self.nMaxCraftingCountCfg and self.nMaxCraftingCountCfg or self.nMaxCraftingCount
|
||||
NovaAPI.SetSliderMaxValue(self._mapNode.imgCountSlider, self.nMaxCraftingCount <= 0 and 1 or self.nMaxCraftingCount)
|
||||
NovaAPI.SetSliderMinValue(self._mapNode.imgCountSlider, 1)
|
||||
if self.nMaxCraftingCount <= 1 then
|
||||
NovaAPI.SetSliderValue(self._mapNode.imgCountSlider, 1)
|
||||
NovaAPI.SetSliderInteractable(self._mapNode.imgCountSlider, false)
|
||||
else
|
||||
NovaAPI.SetSliderInteractable(self._mapNode.imgCountSlider, true)
|
||||
end
|
||||
end
|
||||
self:RefreshCraftingCount()
|
||||
NovaAPI.SetSliderValue(self._mapNode.imgCountSlider, self.nCraftingCount)
|
||||
end
|
||||
function MatCraftingCtrl:OnRefreshCraftingItem()
|
||||
for _, v in pairs(self.tbProductionCtrl) do
|
||||
v:RefreshCraftingItem()
|
||||
end
|
||||
self:OnSelectMtProduction(self.nSelectPId)
|
||||
end
|
||||
return MatCraftingCtrl
|
||||
@@ -0,0 +1,46 @@
|
||||
local MatProductionItemCtrl = class("MatProductionItemCtrl", BaseCtrl)
|
||||
MatProductionItemCtrl._mapNodeConfig = {
|
||||
anAudioUI = {sNodeName = "btnGrid", sComponentName = "AkAudioUI"},
|
||||
goItem = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
txtHave = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Crafting_Material_QTY"
|
||||
},
|
||||
txtHaveCount = {sComponentName = "TMP_Text"},
|
||||
txtProductionName = {sComponentName = "TMP_Text"},
|
||||
goLock = {},
|
||||
imgSelect = {},
|
||||
txtLock = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
MatProductionItemCtrl._mapEventConfig = {}
|
||||
function MatProductionItemCtrl:SetData(tbProduction)
|
||||
self.nId = tbProduction.Id
|
||||
self.bUnlock = tbProduction.Unlock
|
||||
self._mapNode.goLock.gameObject:SetActive(not self.bUnlock)
|
||||
if not self.bUnlock then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLock, tbProduction.UnlockTip)
|
||||
end
|
||||
self.nItemId = tbProduction.ShowProductionId == 0 and tbProduction.ProductionId or tbProduction.ShowProductionId
|
||||
local nCount = tbProduction.ShowProductionId == 0 and tbProduction.ProductionPerBatch or tbProduction.ShowProductionPerBatch
|
||||
if nCount <= 1 then
|
||||
nCount = nil
|
||||
end
|
||||
self._mapNode.goItem:SetItem(self.nItemId, nil, nCount)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProductionName, tbProduction.Name)
|
||||
local hasCount = PlayerData.Item:GetItemCountByID(self.nItemId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHaveCount, hasCount)
|
||||
self:SetSelect(false)
|
||||
local sAudioEvent = self.bUnlock and "ui_common_slide" or "ui_systerm_locked"
|
||||
self._mapNode.anAudioUI:SetAkAudioWiseEventName(sAudioEvent)
|
||||
end
|
||||
function MatProductionItemCtrl:RefreshCraftingItem()
|
||||
local hasCount = PlayerData.Item:GetItemCountByID(self.nItemId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHaveCount, hasCount)
|
||||
end
|
||||
function MatProductionItemCtrl:SetSelect(bSelect)
|
||||
self.bSelect = bSelect
|
||||
self._mapNode.imgSelect.gameObject:SetActive(self.bSelect)
|
||||
end
|
||||
return MatProductionItemCtrl
|
||||
@@ -0,0 +1,42 @@
|
||||
local PreProductionItemCtrl = class("PreProductionItemCtrl", BaseCtrl)
|
||||
PreProductionItemCtrl._mapNodeConfig = {
|
||||
anAudioUI = {sNodeName = "btnGrid", sComponentName = "AkAudioUI"},
|
||||
goItem = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
txtProductionName = {sComponentName = "TMP_Text"},
|
||||
txtHave = {sComponentName = "TMP_Text"},
|
||||
txtHaveCount = {sComponentName = "TMP_Text"},
|
||||
goLock = {},
|
||||
imgSelect = {},
|
||||
txtLock = {sComponentName = "TMP_Text"}
|
||||
}
|
||||
PreProductionItemCtrl._mapEventConfig = {}
|
||||
function PreProductionItemCtrl:SetData(tbProduction)
|
||||
self.nId = tbProduction.Id
|
||||
self.bUnlock = tbProduction.Unlock
|
||||
self._mapNode.goLock.gameObject:SetActive(not self.bUnlock)
|
||||
if not self.bUnlock then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLock, tbProduction.UnlockTip)
|
||||
end
|
||||
local nItemId = tbProduction.ShowProductionId == 0 and tbProduction.ProductionId or tbProduction.ShowProductionId
|
||||
local nCount = tbProduction.ShowProductionId == 0 and tbProduction.ProductionPerBatch or tbProduction.ShowProductionPerBatch
|
||||
if nCount <= 1 then
|
||||
nCount = nil
|
||||
end
|
||||
self._mapNode.goItem:SetItem(nItemId, nil, nCount)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProductionName, tbProduction.Name)
|
||||
local hasCount = PlayerData.Item:GetItemCountByID(nItemId)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHaveCount, hasCount)
|
||||
self:SetSelect(false)
|
||||
local sAudioEvent = self.bUnlock and "ui_common_slide" or "ui_systerm_locked"
|
||||
self._mapNode.anAudioUI:SetAkAudioWiseEventName(sAudioEvent)
|
||||
end
|
||||
function PreProductionItemCtrl:SetSelect(bSelect)
|
||||
self.bSelect = bSelect
|
||||
self._mapNode.imgSelect.gameObject:SetActive(self.bSelect)
|
||||
end
|
||||
function PreProductionItemCtrl:OnSelectItem(nId)
|
||||
self:SetSelect(nId == self.nId)
|
||||
end
|
||||
return PreProductionItemCtrl
|
||||
Reference in New Issue
Block a user