Update - 1.13.0.124

EN: 1.13.0.124
CN: 1.13.0.124
JP: 1.13.0.128
KR: 1.13.0.130
This commit is contained in:
SL1900
2026-07-21 12:30:00 +09:00
parent a12087abad
commit 8c4bd41668
1334 changed files with 873026 additions and 95164 deletions
@@ -0,0 +1,254 @@
local IceCreamLevelDetailCtrl = class("IceCreamLevelDetailCtrl", BaseCtrl)
IceCreamLevelDetailCtrl._mapNodeConfig = {
btn_ClosePanel = {
sComponentName = "UIButton",
callback = "OnBtn_ClosePanel"
},
btn_tag = {
nCount = 2,
sNodeName = "btn_tag",
sComponentName = "UIButton",
callback = "OnBtn_SwitchTag"
},
txt_UnSelect = {sComponentName = "TMP_Text"},
txt_Select = {sComponentName = "TMP_Text"},
txt_LevelName = {sComponentName = "TMP_Text"},
txt_detailDesc = {sComponentName = "TMP_Text"},
obj_MaxScore = {},
txt_ScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_MaxScore"
},
txt_MaxScore = {sComponentName = "TMP_Text"},
obj_Target = {},
txt_TitleTarget = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_LevelTarget"
},
obj_Task = {nCount = 2, sNodeName = "obj_Task"},
txtTask = {nCount = 2, sComponentName = "TMP_Text"},
txt_Reward = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_LevelAward"
},
item = {
nCount = 4,
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
},
btn_item = {
nCount = 4,
sComponentName = "UIButton",
callback = "OnBtnClick_RewardItem"
},
LevelState = {},
btn_Go = {
sComponentName = "UIButton",
callback = "OnBtnClick_Go"
},
txtBtnGo = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_Open"
},
btn_Next = {
sComponentName = "UIButton",
callback = "OnBtnClick_Next"
},
txtBtnNext = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_NextIsland"
},
levelLockRoot = {},
UnlockTime = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_LevelLockPreTip"
}
}
IceCreamLevelDetailCtrl._mapEventConfig = {}
function IceCreamLevelDetailCtrl:Awake()
end
function IceCreamLevelDetailCtrl:FadeIn()
end
function IceCreamLevelDetailCtrl:FadeOut()
end
function IceCreamLevelDetailCtrl:OnEnable()
self.tbGamepadUINode = self:GetGamepadUINode()
end
function IceCreamLevelDetailCtrl:Open(nActId, nIndex)
self.gameObject:SetActive(true)
self.LevelType = nIndex
self.nActId = nActId
self.IceCreamActData = PlayerData.Activity:GetActivityDataById(nActId)
if self.IceCreamActData == nil then
printError("没有冰淇淋活动数据")
self.gameObject:SetActive(false)
return
end
self:InitPanel()
end
function IceCreamLevelDetailCtrl:InitPanel()
self.tbLevels = self.IceCreamActData:GetLevelsByType(self.LevelType)
if not self.tbLevels then
printError("没有对应的关卡类型")
return
end
for i = 1, 2 do
local levelId = self.tbLevels[i]
if levelId ~= nil then
self._mapNode.btn_tag[i].gameObject:SetActive(true)
self:RegisterNewRedNode(self._mapNode.btn_tag[i].gameObject.transform, self.nActId, self.LevelType, levelId)
else
self._mapNode.btn_tag[i].gameObject:SetActive(false)
end
end
self:SetCurTag()
self:RefreshPanel()
end
function IceCreamLevelDetailCtrl:SetCurTag()
if self.tbLevels ~= nil and #self.tbLevels == 2 then
local bCompleteLevel_1 = self.IceCreamActData:GetLevelData(self.tbLevels[1]).bFirstComplete
local bCompleteLevel_2 = self.IceCreamActData:GetLevelData(self.tbLevels[2]).bFirstComplete
if bCompleteLevel_1 ~= bCompleteLevel_2 then
self.nCurTag = 2
elseif bCompleteLevel_1 == bCompleteLevel_2 and bCompleteLevel_2 then
self.nCurTag = 2
else
self.nCurTag = 1
end
else
self.nCurTag = 1
end
end
function IceCreamLevelDetailCtrl:RefreshPanel()
self.curLevelId = self.tbLevels[self.nCurTag]
self.CurrentMapData = self.IceCreamActData:GetLevelMapData(self.curLevelId)
self:RefreshTagState()
self:RefreshData()
self:RefreshReward()
self:RefreshButton()
self:RefreshLevelRedDot(self.nCurTag)
end
function IceCreamLevelDetailCtrl:RefreshReward()
self.tbReward = {}
for i = 1, 4 do
local nRewardId = self.CurrentMapData["FirstCompleteReward" .. i .. "Tid"]
local nRewardQty = self.CurrentMapData["FirstCompleteReward" .. i .. "Qty"]
if nRewardId ~= nil and 0 < nRewardId and nRewardQty ~= nil and 0 < nRewardQty then
table.insert(self.tbReward, {nRewardId, nRewardQty})
self._mapNode.btn_item[i].gameObject:SetActive(true)
else
self._mapNode.btn_item[i].gameObject:SetActive(false)
end
end
local bIsComplete = self.IceCreamActData:GetLevelData(self.curLevelId).bFirstComplete
for k, v in pairs(self.tbReward) do
self._mapNode.item[k]:SetItem(v[1], nil, v[2], nil, bIsComplete)
end
end
function IceCreamLevelDetailCtrl:RefreshButton()
local bIsPreLock = false
local bIsUnlockIsland = false
if self.IceCreamActData:CheckLevelLockByPrev(self.curLevelId) then
bIsPreLock = true
end
if self.tbLevels[2] ~= nil and self.IceCreamActData:GetLevelData(self.tbLevels[2]).bFirstComplete and not self.IceCreamActData:GetNextIslandIsLock(self.LevelType) then
bIsUnlockIsland = true
end
self._mapNode.LevelState:SetActive(not bIsPreLock)
self._mapNode.levelLockRoot:SetActive(bIsPreLock)
self._mapNode.btn_Next.gameObject:SetActive(bIsUnlockIsland)
end
function IceCreamLevelDetailCtrl:RefreshTagState()
if not self.nCurTag then
self.nCurTag = 1
end
for key, tag in ipairs(self._mapNode.btn_tag) do
local obj_Select = tag.gameObject.transform:Find("AnimRoot/obj_Select")
local obj_UnSelect = tag.gameObject.transform:Find("AnimRoot/obj_UnSelect")
obj_Select.gameObject:SetActive(key == self.nCurTag)
obj_UnSelect.gameObject:SetActive(key ~= self.nCurTag)
end
end
function IceCreamLevelDetailCtrl:RefreshData()
if self.CurrentMapData then
NovaAPI.SetTMPText(self._mapNode.txt_LevelName, self.CurrentMapData.Name)
NovaAPI.SetTMPText(self._mapNode.txt_detailDesc, self.CurrentMapData.Des)
if self.CurrentMapData.PassScoreDes == "" then
self._mapNode.obj_Task[1]:SetActive(false)
else
self._mapNode.obj_Task[1]:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtTask[1], self.CurrentMapData.PassScoreDes)
end
if self.CurrentMapData.OrderNumDes == "" then
self._mapNode.obj_Task[2]:SetActive(false)
else
self._mapNode.obj_Task[2]:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtTask[2], self.CurrentMapData.OrderNumDes)
end
end
local bIsInfinite = self.LevelType == GameEnum.ActivityIceCreamLevelType.Infinite
self._mapNode.obj_MaxScore:SetActive(bIsInfinite)
if bIsInfinite then
local MaxScore = self.IceCreamActData:GetLevelMaxScore(self.curLevelId)
NovaAPI.SetTMPText(self._mapNode.txt_MaxScore, MaxScore)
end
self._mapNode.obj_Target:SetActive(not bIsInfinite)
end
function IceCreamLevelDetailCtrl:RefreshLevelRedDot(nIndex)
self.IceCreamActData:SetLevelNew(self.LevelType, self.tbLevels[nIndex])
self.IceCreamActData:RefreshLevelRedDot()
end
function IceCreamLevelDetailCtrl:OnDisable()
self:UnRegisterNewRedNode()
end
function IceCreamLevelDetailCtrl:OnDestroy()
end
function IceCreamLevelDetailCtrl:OnBtnClick_RewardItem(btn, nIndex)
local nRewardId
if self.tbReward ~= nil and self.tbReward[nIndex] ~= nil then
nRewardId = self.tbReward[nIndex][1]
end
if nRewardId ~= nil then
UTILS.ClickItemGridWithTips(nRewardId, btn.transform, true, true, false)
end
end
function IceCreamLevelDetailCtrl:OnBtn_SwitchTag(btn, nIndex)
if nIndex == self.nCurTag then
return
end
self.nCurTag = nIndex
self:RefreshLevelRedDot(nIndex)
self:RefreshPanel()
end
function IceCreamLevelDetailCtrl:OnBtn_ClosePanel()
self.gameObject:SetActive(false)
EventManager.Hit("Event_CloseLevelDetail", self.LevelType)
end
function IceCreamLevelDetailCtrl:OnBtnClick_Next()
self.gameObject:SetActive(false)
EventManager.Hit("Event_ChangeNextDetail", self.LevelType, self.LevelType + 1)
end
function IceCreamLevelDetailCtrl:OnBtnClick_Go()
self.gameObject:SetActive(false)
EventManager.Hit(EventId.OpenPanel, PanelId.IceCreamTruckGamePanel, self.nActId, self.curLevelId)
end
function IceCreamLevelDetailCtrl:RegisterNewRedNode(trTag, nActId, nIndex, nLevel)
local objRed = trTag:Find("AnimRoot/redH")
RedDotManager.RegisterNode(RedDotDefine.Activity_IceCreamTruck_NewLevel, {
nActId,
nIndex,
nLevel
}, objRed)
end
function IceCreamLevelDetailCtrl:UnRegisterNewRedNode()
for i = 1, 2 do
local objRed = self._mapNode.btn_tag[i] and self._mapNode.btn_tag[i].gameObject.transform:Find("AnimRoot/redH")
if objRed then
RedDotManager.UnRegisterNode(RedDotDefine.Activity_IceCreamTruck_NewLevel, {
nActId,
nIndex,
nLevel
}, objRed)
end
end
end
return IceCreamLevelDetailCtrl
@@ -0,0 +1,205 @@
local IceCreamLevelGroupCtrl = class("IceCreamLevelGroupCtrl", BaseCtrl)
local SpineManager = require("Game.Spine.SpineManager")
IceCreamLevelGroupCtrl._mapNodeConfig = {
btn_LevelDetail = {
sComponentName = "UIButton",
callback = "OnBtn_OpenDetail"
},
txt_LevelTypeName = {sComponentName = "TMP_Text"},
LockRoot = {},
txt_Lock = {sComponentName = "TMP_Text"},
iconCert = {},
SpRoot_Island = {},
redH = {}
}
IceCreamLevelGroupCtrl._mapEventConfig = {
Event_CloseLevelDetail = "Event_CloseDetail",
Event_ChangeNextDetail = "Event_ChangeNextDetail",
Event_OpenLevelDetail = "Event_OpenLevelDetail"
}
function IceCreamLevelGroupCtrl:Awake()
end
function IceCreamLevelGroupCtrl:OnEnable()
end
function IceCreamLevelGroupCtrl:InitData(nActId, nIndex, tbLevels, parent)
self.parent = parent
self.nIndex = nIndex
self.nActId = nActId
self.IceCreamActData = PlayerData.Activity:GetActivityDataById(self.nActId)
if self.IceCreamActData == nil then
printError("没有冰淇淋活动数据")
return
end
self.tbLevels = tbLevels
if self.tbLevels == nil then
printError("关卡组信息为空")
return
end
self.CurrentMapData = self.IceCreamActData:GetLevelMapData(self.tbLevels[1])
self:RefreshState()
self:RegisterGroupSpines()
self:RegisterNewRedNode(self.nActId, self.nIndex)
end
function IceCreamLevelGroupCtrl:RefreshState()
self._mapNode.iconCert:SetActive(self:GetIsAllFinish())
local nLevelId = self.tbLevels[1]
local bLock, nRemain = self.IceCreamActData:CheckLevelIsLockByTime(nLevelId)
if bLock then
self.bLock = bLock
self._mapNode.LockRoot:SetActive(self.bLock)
self:RefreshLevelTime(nRemain)
self:SetTypeName(bLock)
return
end
bLock = self.IceCreamActData:CheckLevelLockByPrev(nLevelId)
if bLock then
self.bLock = bLock
self._mapNode.LockRoot:SetActive(bLock)
NovaAPI.SetTMPText(self._mapNode.txt_Lock, ConfigTable.GetUIText("IceCreamTruck_LevelLockPreTitle"))
self:SetTypeName(bLock)
return
end
self.bLock = bLock
self._mapNode.LockRoot:SetActive(self.bLock)
self:SetTypeName(bLock)
end
function IceCreamLevelGroupCtrl:GetIsAllFinish()
for _, value in ipairs(self.tbLevels) do
if not self.IceCreamActData:GetLevelData(value).bFirstComplete then
return false
end
end
return true
end
function IceCreamLevelGroupCtrl:SetTypeName(bLock)
if bLock then
NovaAPI.SetTMPText(self._mapNode.txt_LevelTypeName, ConfigTable.GetUIText("IceCreamTruck_LevelLockName"))
elseif self.CurrentMapData then
local LevelTypeName = self.CurrentMapData.IslandName
NovaAPI.SetTMPText(self._mapNode.txt_LevelTypeName, LevelTypeName)
end
end
function IceCreamLevelGroupCtrl:OnDisable()
self:UnRegisterNewRedNode()
end
function IceCreamLevelGroupCtrl:OnDestroy()
self:UnregisterGroupSpines()
end
function IceCreamLevelGroupCtrl:RefreshLevelTime(remainTime)
local sTime = self:GetTimeText(remainTime)
NovaAPI.SetTMPText(self._mapNode.txt_Lock, orderedFormat(ConfigTable.GetUIText("IceCreamTruck_TimeTips") or "", sTime))
end
function IceCreamLevelGroupCtrl:GetTimeText(remainTime)
local sTimeStr = ""
if remainTime <= 60 then
local sec = math.floor(remainTime)
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Sec") or "", sec)
elseif 60 < remainTime and remainTime <= 3600 then
local min = math.floor(remainTime / 60)
local sec = math.floor(remainTime - min * 60)
if sec == 0 then
min = min - 1
sec = 60
end
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Min") or "", min, sec)
elseif 3600 < remainTime and remainTime <= 86400 then
local hour = math.floor(remainTime / 3600)
local min = math.floor((remainTime - hour * 3600) / 60)
if min == 0 then
hour = hour - 1
min = 60
end
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Hour") or "", hour, min)
elseif 86400 < remainTime then
local day = math.floor(remainTime / 86400)
local hour = math.floor((remainTime - day * 86400) / 3600)
if hour == 0 then
day = day - 1
hour = 24
end
sTimeStr = orderedFormat(ConfigTable.GetUIText("Activity_Remain_Time_Day") or "", day, hour)
end
return sTimeStr
end
function IceCreamLevelGroupCtrl:OnBtn_OpenDetail()
if self.bLock then
return
end
self.parent._mapNode.LevelDetailsPanel:Open(self.nActId, self.nIndex)
self.parent:OpenLevelDetail_Animator(self.nIndex)
self:ClickIn_Spine()
end
function IceCreamLevelGroupCtrl:Event_CloseDetail(nIndex)
if self.nIndex == nIndex then
self:ClickOut_Spine()
self.parent:CloseLevelDetail_AnimatorOut(nIndex)
end
end
function IceCreamLevelGroupCtrl:Event_ChangeNextDetail(nIndex, nNextIndex)
if self.nIndex == nIndex then
self:ClickOut_Spine()
self.parent:OpenNextLevelDetail(nIndex, nNextIndex)
end
end
function IceCreamLevelGroupCtrl:Event_OpenLevelDetail(nNextIndex)
if self.nIndex == nNextIndex then
self.parent._mapNode.LevelDetailsPanel:Open(self.nActId, nNextIndex)
self.parent:OpenLevelDetail_Animator(nNextIndex)
self:ClickIn_Spine()
end
end
function IceCreamLevelGroupCtrl:RegisterGroupSpines()
local objSpine = self._mapNode.SpRoot_Island
if objSpine ~= nil then
local nId = SpineManager.Bind(objSpine)
if nId ~= nil then
self.GroupId = nId
if self.bLock then
SpineManager.PlayAnim(nId, "lock", true)
else
SpineManager.PlayAnim(nId, "idle", true)
end
end
end
end
function IceCreamLevelGroupCtrl:UnregisterGroupSpines()
if self.GroupId == nil then
return
end
SpineManager.Unbind(self.GroupId)
self.GroupId = nil
end
function IceCreamLevelGroupCtrl:ClickIn_Spine()
if self.GroupId == nil then
return
end
self:SetStatusSwitch(self.GroupId, "in", false, "idle2")
end
function IceCreamLevelGroupCtrl:ClickOut_Spine()
if self.GroupId == nil then
return
end
self:SetStatusSwitch(self.GroupId, "out", false, "idle")
end
function IceCreamLevelGroupCtrl:SetStatusSwitch(CurSpineId, sState, bLoop, sNextLoop)
if not CurSpineId then
return
end
if bLoop == nil then
bLoop = true
end
SpineManager.PlayAnim(CurSpineId, sState, bLoop)
if not bLoop and sNextLoop then
SpineManager.AddAnim(CurSpineId, sNextLoop, true, 0)
end
end
function IceCreamLevelGroupCtrl:RegisterNewRedNode(nActId, nIndex)
RedDotManager.RegisterNode(RedDotDefine.Activity_IceCreamTruck_NewType, {nActId, nIndex}, self._mapNode.redH)
end
function IceCreamLevelGroupCtrl:UnRegisterNewRedNode()
RedDotManager.UnRegisterNode(RedDotDefine.Activity_IceCreamTruck_NewLevel, {
nActId,
nIndex
}, self._mapNode.redH)
end
return IceCreamLevelGroupCtrl
@@ -0,0 +1,152 @@
local TimerManager = require("GameCore.Timer.TimerManager")
local IceCreamLevelsSelectCtrl = class("IceCreamLevelsSelectCtrl", BaseCtrl)
IceCreamLevelsSelectCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
LevelDetailsPanel = {
sCtrlName = "Game.UI.Play_IceCreamTruck.IceCreamLevelDetailCtrl"
},
LevelGroup = {
nCount = 4,
sCtrlName = "Game.UI.Play_IceCreamTruck.IceCreamLevelGroupCtrl"
},
btnTarget = {
sComponentName = "UIButton",
callback = "OnBtnClick_Target"
},
TMPBtnTarget = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_Target"
},
goRedDotTarget = {}
}
IceCreamLevelsSelectCtrl._mapEventConfig = {}
function IceCreamLevelsSelectCtrl:Awake()
end
function IceCreamLevelsSelectCtrl:FadeIn()
end
function IceCreamLevelsSelectCtrl:FadeOut()
end
function IceCreamLevelsSelectCtrl:OnEnable()
local param = self:GetPanelParam()
if type(param) == "table" then
self.nActId = param[1]
end
self.animatorRoot = self.gameObject:GetComponent("Animator")
self:InitLevel(self.nActId)
self:RegisterTaskRedNode()
EventManager.Hit(EventId.SetTransition)
end
function IceCreamLevelsSelectCtrl:OnDisable()
if self._tmrSwitchDetail ~= nil then
TimerManager.Remove(self._tmrSwitchDetail, false)
self._tmrSwitchDetail = nil
end
end
function IceCreamLevelsSelectCtrl:InitLevel(nActId)
self.IceCreamActData = PlayerData.Activity:GetActivityDataById(nActId)
if self.IceCreamActData == nil then
printError("没有冰淇淋活动数据")
return
end
self.AllLevelTypeTable = self.IceCreamActData:GetLevelTypeTable()
if self.AllLevelTypeTable == nil then
printError("关卡组信息为空")
return
end
local nGroupCount = #self._mapNode.LevelGroup
for i = 1, nGroupCount do
local value = self.AllLevelTypeTable[i]
if value ~= nil then
self._mapNode.LevelGroup[i].gameObject:SetActive(true)
self:OnRefreshLevelGroup(i, value)
else
self._mapNode.LevelGroup[i].gameObject:SetActive(false)
end
end
if nGroupCount < #self.AllLevelTypeTable then
printError(string.format("[IceCream] LevelType 数(%d) 超出预绑定 LevelGroup 数(%d)", #self.AllLevelTypeTable, nGroupCount))
end
end
function IceCreamLevelsSelectCtrl:OnRefreshLevelGroup(gridIndex, tbLevels)
self._mapNode.LevelGroup[gridIndex]:InitData(self.nActId, gridIndex, tbLevels, self)
end
function IceCreamLevelsSelectCtrl:OnDestroy()
end
function IceCreamLevelsSelectCtrl:OpenLevelDetail_Animator(nTypeIndex)
if nTypeIndex < 1 or 4 < nTypeIndex then
return
end
local sAnimatorIn = string.format("IceCreamLevelsSelectPanel_in%d", nTypeIndex)
self.animatorRoot:Play(sAnimatorIn, 0, 0)
local nAnimTime = NovaAPI.GetAnimClipLength(self.animatorRoot, {sAnimatorIn})
EventManager.Hit(EventId.TemporaryBlockInput, nAnimTime)
end
function IceCreamLevelsSelectCtrl:OpenNextLevelDetail(nTypeIndex, NextTypeIndex)
if nTypeIndex < 1 or 4 < nTypeIndex or NextTypeIndex < 1 or 4 < NextTypeIndex then
return
end
local sAnimatorOut = string.format("IceCreamLevelsSelectPanel_out%d", nTypeIndex)
self.animatorRoot:Play(sAnimatorOut, 0, 0)
local nAnimTime = NovaAPI.GetAnimClipLength(self.animatorRoot, {sAnimatorOut})
if type(nAnimTime) ~= "number" or nAnimTime <= 0 then
printWarn("[IceCream] 拿不到 out 动画时长,直接切到下一关详情:anim=" .. sAnimatorOut)
EventManager.Hit("Event_OpenLevelDetail", NextTypeIndex)
return
end
EventManager.Hit(EventId.TemporaryBlockInput, nAnimTime)
if self._tmrSwitchDetail ~= nil then
TimerManager.Remove(self._tmrSwitchDetail, false)
self._tmrSwitchDetail = nil
end
self._tmrSwitchDetail = self:AddTimer(1, nAnimTime, function()
self._tmrSwitchDetail = nil
EventManager.Hit("Event_OpenLevelDetail", NextTypeIndex)
end, true, true, true)
end
function IceCreamLevelsSelectCtrl:CloseLevelDetail_AnimatorOut(nTypeIndex)
if nTypeIndex < 1 or 4 < nTypeIndex then
return
end
local sAnimatorOut = string.format("IceCreamLevelsSelectPanel_out%d", nTypeIndex)
self.animatorRoot:Play(sAnimatorOut, 0, 0)
end
function IceCreamLevelsSelectCtrl:RegisterTaskRedNode()
local mapActivityData = ConfigTable.GetData("Activity", self.nActId)
if mapActivityData ~= nil then
local nGroupId = mapActivityData.MidGroupId
local mapGroupData = PlayerData.Activity:GetActivityGroupDataById(nGroupId)
if mapGroupData ~= nil then
local actData = mapGroupData:GetActivityDataByIndex(AllEnum.ActivityThemeFuncIndex.Task)
if actData ~= nil then
RedDotManager.RegisterNode(RedDotDefine.Activity_Group_Task_Group, {
nGroupId,
actData.ActivityId,
mapActivityData.MiniGameRedDot
}, self._mapNode.goRedDotTarget)
else
self._mapNode.goRedDotTarget:SetActive(false)
end
else
self._mapNode.goRedDotTarget:SetActive(false)
end
else
self._mapNode.goRedDotTarget:SetActive(false)
end
end
function IceCreamLevelsSelectCtrl:OnBtnClick_Target()
local mapActivityData = ConfigTable.GetData("Activity", self.nActId)
if mapActivityData ~= nil then
local nGroupId = mapActivityData.MidGroupId
local mapGroupData = PlayerData.Activity:GetActivityGroupDataById(nGroupId)
if mapGroupData ~= nil then
local actData = mapGroupData:GetActivityDataByIndex(AllEnum.ActivityThemeFuncIndex.Task)
if actData ~= nil then
EventManager.Hit(EventId.OpenPanel, self._panel.nQuestPanelId, actData.ActivityId, 4)
end
end
end
end
return IceCreamLevelsSelectCtrl
@@ -0,0 +1,14 @@
local IceCreamLevelsSelectPanel = class("IceCreamLevelsSelectPanel", BasePanel)
IceCreamLevelsSelectPanel._bIsMainPanel = true
IceCreamLevelsSelectPanel._sSortingLayerName = AllEnum.SortingLayerName.UI
IceCreamLevelsSelectPanel._sUIResRootPath = "UI_Activity/"
IceCreamLevelsSelectPanel._tbDefine = {
{
sPrefabPath = "_400013/IceCreamLevelsSelectPanel.prefab",
sCtrlName = "Game.UI.Play_IceCreamTruck.IceCreamLevelsSelectCtrl"
}
}
function IceCreamLevelsSelectPanel:Awake()
self.nQuestPanelId = PanelId.Task_20103
end
return IceCreamLevelsSelectPanel
@@ -0,0 +1,13 @@
local BuffItemBase = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItemBase")
local BuffItem_AutoOrder = class("BuffItem_AutoOrder", BuffItemBase)
function BuffItem_AutoOrder:Init(cfg)
BuffItemBase.Init(self, cfg)
self.nBuffType = GameEnum.IceBuffEffect.Order
end
function BuffItem_AutoOrder:Apply(ctx)
ctx.setAutoOrderMode(true)
end
function BuffItem_AutoOrder:Revoke(ctx)
ctx.setAutoOrderMode(false)
end
return BuffItem_AutoOrder
@@ -0,0 +1,12 @@
local BuffItemBase = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItemBase")
local BuffItem_Life = class("BuffItem_Life", BuffItemBase)
function BuffItem_Life:Init(cfg)
BuffItemBase.Init(self, cfg)
self.nBuffType = GameEnum.IceBuffEffect.HP
self.nHeal = cfg and cfg.Param and cfg.Param[1] or 1
self.nDuration = 0
end
function BuffItem_Life:Apply(ctx)
ctx.addHp(self.nHeal)
end
return BuffItem_Life
@@ -0,0 +1,14 @@
local BuffItemBase = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItemBase")
local BuffItem_Patience = class("BuffItem_Patience", BuffItemBase)
function BuffItem_Patience:Init(cfg)
BuffItemBase.Init(self, cfg)
self.nBuffType = GameEnum.IceBuffEffect.Patience
end
function BuffItem_Patience:Apply(ctx)
ctx.resetCustomerPatience()
ctx.freezeCustomerPatience(true)
end
function BuffItem_Patience:Revoke(ctx)
ctx.freezeCustomerPatience(false)
end
return BuffItem_Patience
@@ -0,0 +1,19 @@
local BuffItemBase = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItemBase")
local BuffItem_ScoreMul = class("BuffItem_ScoreMul", BuffItemBase)
function BuffItem_ScoreMul:Init(cfg)
BuffItemBase.Init(self, cfg)
self.nBuffType = GameEnum.IceBuffEffect.Score
self.fMul = cfg and cfg.Param and cfg.Param[2] or 2
if self.fMul <= 0 then
self.fMul = 1
end
self._fPrev = 1
end
function BuffItem_ScoreMul:Apply(ctx)
self._fPrev = ctx.scoreCalc:GetBuffMultiplier() or 1
ctx.scoreCalc:SetBuffMultiplier(self._fPrev * self.fMul)
end
function BuffItem_ScoreMul:Revoke(ctx)
ctx.scoreCalc:SetBuffMultiplier(self._fPrev or 1)
end
return BuffItem_ScoreMul
@@ -0,0 +1,19 @@
local BuffItemBase = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItemBase")
local BuffItem_TimeSlow = class("BuffItem_TimeSlow", BuffItemBase)
function BuffItem_TimeSlow:Init(cfg)
BuffItemBase.Init(self, cfg)
self.nBuffType = GameEnum.IceBuffEffect.Time
self.fFactor = cfg and cfg.Param and cfg.Param[2] or 2
if self.fFactor <= 0 then
self.fFactor = 1
end
self._fPrevScale = 1
end
function BuffItem_TimeSlow:Apply(ctx)
self._fPrevScale = ctx.getSpeedScale()
ctx.setSpeedScale(self._fPrevScale / self.fFactor)
end
function BuffItem_TimeSlow:Revoke(ctx)
ctx.setSpeedScale(self._fPrevScale)
end
return BuffItem_TimeSlow
@@ -0,0 +1,23 @@
local BuffItemBase = class("BuffItemBase")
function BuffItemBase:Init(cfg)
self.cfg = cfg
self.nBuffId = cfg and cfg.BuffId or 0
self.nBuffType = cfg and cfg.BuffType or 0
self.nDuration = cfg and cfg.Param and cfg.Param[1] or 0
end
function BuffItemBase:Apply(ctx)
end
function BuffItemBase:OnTick(ctx, dt)
end
function BuffItemBase:Revoke(ctx)
end
function BuffItemBase:GetType()
return self.nBuffType
end
function BuffItemBase:GetBuffId()
return self.nBuffId
end
function BuffItemBase:GetDuration()
return self.nDuration or 0
end
return BuffItemBase
@@ -0,0 +1,839 @@
local CustomerItemCtrl = class("CustomerItemCtrl", BaseCtrl)
local IceCreamUtils = require("Game.UI.Play_IceCreamTruck.Play.IceCreamUtils")
local TimerManager = require("GameCore.Timer.TimerManager")
local IceCreamTruckGameCtrl = require("Game.UI.Play_IceCreamTruck.Play.IceCreamTruckGameCtrl")
local enumQueueType = IceCreamUtils.EnumQueueType
local enumCustomerState = IceCreamUtils.EnumCustomerState
local SpineManager = require("Game.Spine.SpineManager")
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
local MOVE_TICK_INTERVAL = 0.02
local MOVE_BASE_PX_PER_SEC = 1
local LEAVE_PERFORM_MAP = {
[enumCustomerState.happy] = enumCustomerState.happy_walk,
[enumCustomerState.angry] = enumCustomerState.angry_walk
}
local FALLBACK_PERFORM_DURATION = 1.0
CustomerItemCtrl._mapNodeConfig = {
Patience = {
sComponentName = "RectTransform"
},
imgProgressBar = {sComponentName = "Image"},
IconStar = {
sComponentName = "RectTransform"
},
img_ProgressLock = {},
img_ProgressBarLock = {},
IceCreamOrder = {
sCtrlName = "Game.UI.Play_IceCreamTruck.Play.IceCreamOrdersCtrl"
},
IceCreamOrderAnim = {
sNodeName = "IceCreamOrder",
sComponentName = "Animator"
},
imgIceCreamOrder = {
sComponentName = "RectTransform"
},
Char = {},
IceCreamIcon = {
sComponentName = "RectTransform"
},
Icon_ = {nCount = 6, sComponentName = "Image"},
CompleteRoot = {},
CompleteRootAnimator = {
sNodeName = "CompleteRoot",
sComponentName = "Animator"
},
txt_BaseScore = {
sNodeName = "txt_AddScore",
sComponentName = "TMP_Text"
},
txt_TimesScore = {
sNodeName = "txt_TimesScore",
sComponentName = "TMP_Text"
}
}
CustomerItemCtrl._mapEventConfig = {
Event_CustomerMoveTo = "CustomerMoveTo",
Event_CustomerLeaveQueue = "CustomerLeaveQueue",
Event_OrderMakeMistake = "Event_OrderMakeMistake",
Event_CustomerTeleportTo = "CustomerTeleportTo",
Event_FeverModeChanged = "FeverModeChanged",
Event_IceCreamPatienceFreeze = "Event_IceCreamPatienceFreeze",
Event_SetPause = "Event_Pause",
Event_IceCreamSpeedScaleChanged = "Event_IceCreamSpeedScaleChanged"
}
function CustomerItemCtrl:Awake()
end
function CustomerItemCtrl:OnEnable()
self.moveTimer = nil
self.tbMoveCtx = nil
self.fFeverFactor = self.fFeverFactor or 1
self.fBuffFactor = self.fBuffFactor or 1
self.nRemainSpeedBuff = self.nRemainSpeedBuff or 1
self._bStartLeavingFired = false
self:EnableIceIcon(false)
end
function CustomerItemCtrl:OnDisable()
self:_TryFireStartLeavingOnInterrupt()
self:KillUpDateTime()
self:KillMoveTimer()
self:_KillLeavePerformTimer()
self:_KillScorePopupTimer()
self:_KillOrderOutDoneTimer()
self:ClearSpine()
self.CurSpineId = nil
end
function CustomerItemCtrl:OnDestroy()
self:_TryFireStartLeavingOnInterrupt()
self:KillUpDateTime()
self:KillMoveTimer()
self:_KillLeavePerformTimer()
self:_KillScorePopupTimer()
self:_KillOrderOutDoneTimer()
end
function CustomerItemCtrl:SetBlankData(recyclePoint, patienceValue)
if not self._mapNode or not self._mapNode.imgIceCreamOrder then
printError("初始化上层节点未绑定完毕")
return
end
self.nCharacterId = nil
self.nRoleId = nil
self.nPoint = self.gameObject.transform.position
if patienceValue then
self.MaxPatienceValue = patienceValue
self.PatienceValue = self.MaxPatienceValue
end
self.CustomerState = nil
self.MoveSpeed = 5
self.bGetOrder = false
self.bIsSpecial = false
self.nItemID = 0
self.bInPatience = false
self.bInFever = false
self.bFreezePatience = false
self.fFeverFactor = 1
self.fBuffFactor = 1
self.nRemainSpeedBuff = 1
self._bStartLeavingFired = false
if recyclePoint then
self.RecyclePoint = recyclePoint
local tr = self.gameObject:GetComponent("RectTransform")
tr.position = self.RecyclePoint.position
end
self._bLeaving = false
self:SetShowOrder(false)
self:SetPatienceLockBuff(self.bFreezePatience)
self:RefreshSpecialState()
end
function CustomerItemCtrl:ResetData()
self:_TryFireStartLeavingOnInterrupt()
self:KillMoveTimer()
self:KillUpDateTime()
self:_KillLeavePerformTimer()
self:_KillScorePopupTimer()
self:_KillOrderOutDoneTimer()
self:ReverTrIceIcon()
self:ClearSpine()
self:SetBlankData()
self._mapNode.CompleteRoot:SetActive(false)
end
function CustomerItemCtrl:SetActiveData(nInstId, nRoleId, bIsSpecial, nItemID, nMaxPatienceValue, nMaxScoop)
self.nCharacterId = nInstId
self.nRoleId = nRoleId
self.bIsSpecial = bIsSpecial
if self.bIsSpecial then
self.nItemID = nItemID
if self.nItemID == nil or self.nItemID == 0 then
printError("丢失道具ID")
end
end
self:CreatSpine(self.nRoleId)
self:RefreshSpecialState()
self.bGetOrder = self._mapNode.IceCreamOrder:SetNewOrder(self.nCharacterId, nMaxScoop)
if not self.bGetOrder then
printError("丢失订单")
end
self.MaxPatienceValue = nMaxPatienceValue
self.PatienceValue = self.MaxPatienceValue
self:CreatIceCreamIcon()
self:_SyncGlobalRuntimeState()
end
function CustomerItemCtrl:_SyncGlobalRuntimeState()
local gameCtrl = IceCreamTruckGameCtrl.GetInstance()
if gameCtrl == nil then
return
end
self:FeverModeChanged(gameCtrl.bInFever and true or false)
self:Event_IceCreamSpeedScaleChanged(gameCtrl.fSpeedScale or 1)
self:Event_IceCreamPatienceFreeze(gameCtrl.bFreezePatience and true or false)
end
function CustomerItemCtrl:CustomerMoveTo(QueuePoints)
if self.nCharacterId == nil or QueuePoints.currentCustomerId == nil then
return
end
if QueuePoints.currentCustomerId ~= self.nCharacterId then
return
end
if QueuePoints.enumQueueTyp == enumQueueType.InQueue then
self:SetStatusSwitch(enumCustomerState.walk)
self:MoveToTargetPoint(QueuePoints.Point, function()
self:SetStatusSwitch(enumCustomerState.idle)
self:SetShowOrder(false)
end)
elseif QueuePoints.enumQueueTyp == enumQueueType.InMake then
self:SetStatusSwitch(enumCustomerState.walk)
self:MoveToTargetPoint(QueuePoints.Point, function()
self:SetStatusSwitch(enumCustomerState.idle)
self:SetShowOrder(true)
self.bInPatience = true
self:_StartPatienceTween()
local gameCtrl = IceCreamTruckGameCtrl.GetInstance()
if gameCtrl then
gameCtrl:Event_CustomerReadyToServe(self)
end
end)
end
end
function CustomerItemCtrl:PlayVoice(nState)
local CustomerData = ConfigTable.GetData("IceCreamChar", self.nRoleId)
if CustomerData == nil then
printError("没有该角色信息:" .. self.nRoleId)
return
end
local voiceEvent
if nState == enumCustomerState.happy then
voiceEvent = CustomerData.Voice_Happy
WwiseAudioMgr:PostEvent("mode_400013_love")
elseif nState == enumCustomerState.sad then
voiceEvent = CustomerData.Voice_Sad
WwiseAudioMgr:PostEvent("mode_400013_bad")
elseif nState == enumCustomerState.angry then
voiceEvent = CustomerData.Voice_Angry
WwiseAudioMgr:PostEvent("mode_400013_angry")
end
if voiceEvent and voiceEvent ~= "" then
WwiseAudioMgr:PlaySound(voiceEvent, WwiseAudioMgr.AkListener, true)
end
end
function CustomerItemCtrl:CreatSpine(nId)
if self.CurSpineId then
self:ClearSpine()
self.CurSpineId = nil
end
local nCurSpineID = SpineManager.Create(nId, self._mapNode.Char.transform)
if not nCurSpineID then
printError("Spine对象创建失败:" .. nId)
return
end
self.CurSpineId = nCurSpineID
end
function CustomerItemCtrl:SetStatusSwitch(eState, bLoop, sNextLoop)
self.CustomerState = eState
if not self.CurSpineId then
return
end
if bLoop == nil then
bLoop = true
end
SpineManager.PlayAnim(self.CurSpineId, eState, bLoop)
if not bLoop and sNextLoop then
SpineManager.AddAnim(self.CurSpineId, sNextLoop, true, 0)
end
self:PlayVoice(eState)
end
function CustomerItemCtrl:ClearSpine()
if self.CurSpineId then
SpineManager.Destroy(self.CurSpineId)
self.CurSpineId = nil
end
end
function CustomerItemCtrl:SetSpineSpeed()
if self.CurSpineId then
SpineManager.SetTimeScale(self.CurSpineId, self:_GetMoveScale())
self.time = 0.37 / self:_GetMoveScale()
end
end
function CustomerItemCtrl:MoveToTargetPoint(Point, callback)
self:KillMoveTimer()
local tr = self.gameObject:GetComponent("RectTransform")
local fromWorld = tr.position
local targetWorld = Point.position
local cam
local fromScreen = CS.UnityEngine.RectTransformUtility.WorldToScreenPoint(cam, fromWorld)
local targetScreen = CS.UnityEngine.RectTransformUtility.WorldToScreenPoint(cam, targetWorld)
local distPx = Vector2.Distance(fromScreen, targetScreen)
if distPx < 0.01 then
if callback then
local nGen = IceCreamTruckGameCtrl.GetRestartGen()
cs_coroutine.start(function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
if nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
return
end
callback()
end)
end
return
end
self.tbMoveCtx = {
trRect = tr,
vStartWorld = fromWorld,
vTargetWorld = targetWorld,
fTotalPx = distPx,
fTraveledPx = 0,
fBasePxPerSec = self.MoveSpeed * MOVE_BASE_PX_PER_SEC,
fnCallback = callback,
nGen = IceCreamTruckGameCtrl.GetRestartGen()
}
self.moveTimer = self:AddTimer(0, MOVE_TICK_INTERVAL, "MoveTick", true, true, false)
if self.moveTimer ~= nil then
self.moveTimer:SetSpeed(self:_GetMoveScale())
local gameCtrl = IceCreamTruckGameCtrl.GetInstance()
if gameCtrl and gameCtrl.bIPause then
self.moveTimer:Pause(true)
end
end
return
end
function CustomerItemCtrl:CustomerTeleportTo(nCustomerId, SpawnPoint)
if self.nCharacterId == nil or nCustomerId == nil then
return
end
if nCustomerId ~= self.nCharacterId then
return
end
self:KillMoveTimer()
local tr = self.gameObject:GetComponent("RectTransform")
tr.position = SpawnPoint.position
end
function CustomerItemCtrl:MoveTick()
local ctx = self.tbMoveCtx
if ctx == nil or self.nCharacterId == nil then
self:KillMoveTimer()
return
end
if ctx.nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
self:KillMoveTimer()
return
end
local dPx = ctx.fBasePxPerSec * MOVE_TICK_INTERVAL
ctx.fTraveledPx = ctx.fTraveledPx + dPx
local t = ctx.fTraveledPx / ctx.fTotalPx
if 1 <= t then
ctx.trRect.position = ctx.vTargetWorld
local fn = ctx.fnCallback
self:KillMoveTimer()
if fn then
fn()
end
return
end
ctx.trRect.position = CS.UnityEngine.Vector3.Lerp(ctx.vStartWorld, ctx.vTargetWorld, t)
end
function CustomerItemCtrl:KillMoveTimer()
if self.moveTimer ~= nil then
TimerManager.Remove(self.moveTimer)
self.moveTimer = nil
end
self.tbMoveCtx = nil
end
function CustomerItemCtrl:KillUpDateTime()
if self.remainTimer ~= nil then
TimerManager.Remove(self.remainTimer)
self.remainTimer = nil
end
self:_KillPatienceTween()
end
function CustomerItemCtrl:_StartPatienceTween()
self:_KillPatienceTween()
local img = self._mapNode and self._mapNode.imgProgressBar
if img == nil then
return
end
local nMax = self.MaxPatienceValue
if nMax == nil or nMax <= 0 then
return
end
local nCur = math.max(0, math.min(self.PatienceValue or 0, nMax))
self.PatienceValue = nCur
NovaAPI.SetImageFillAmount(img, nCur / nMax)
if nCur <= 0 then
EventManager.Hit("Event_CustomerLeave_False", self.nCharacterId)
return
end
local fDur = nCur
self._nPatienceGen = IceCreamTruckGameCtrl.GetRestartGen()
local nGen = self._nPatienceGen
local nCharId = self.nCharacterId
self._patienceTweener = DOTween.To(function()
return img.fillAmount
end, function(v)
img.fillAmount = v
end, 0, fDur)
if self._patienceTweener == nil then
return
end
self._patienceTweener:SetEase(CS.DG.Tweening.Ease.Linear)
self._patienceTweener:OnComplete(function()
if nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
return
end
if self.nCharacterId == nil or self.nCharacterId ~= nCharId then
return
end
if self._patienceTweener == nil then
return
end
self._patienceTweener = nil
self.PatienceValue = 0
EventManager.Hit("Event_CustomerLeave_False", nCharId)
end)
if self.bInFever or self.bFreezePatience then
self._patienceTweener:Pause()
else
local gameCtrl = IceCreamTruckGameCtrl.GetInstance()
if gameCtrl and gameCtrl.bIPause then
self._patienceTweener:Pause()
end
end
self:_ApplyPatienceTweenScale()
end
function CustomerItemCtrl:_SnapshotPatienceFromImage()
local img = self._mapNode and self._mapNode.imgProgressBar
local nMax = self.MaxPatienceValue
if img == nil or nMax == nil or nMax <= 0 then
return
end
local fFill = img.fillAmount or 0
if fFill < 0 then
fFill = 0
elseif 1 < fFill then
fFill = 1
end
self.PatienceValue = math.max(0, math.min(nMax, fFill * nMax))
end
function CustomerItemCtrl:_ApplyPatienceTweenScale()
if self._patienceTweener == nil then
return
end
local fScale = self.fBuffFactor or 1
if fScale <= 0 then
fScale = 1
end
self._patienceTweener.timeScale = fScale
end
function CustomerItemCtrl:_KillPatienceTween()
if self._patienceTweener ~= nil then
self._patienceTweener:Kill()
self._patienceTweener = nil
end
self._nPatienceGen = nil
end
function CustomerItemCtrl:RefreshSpecialState()
local canvasGroup = self._mapNode.IconStar:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupAlpha(canvasGroup, self.bIsSpecial and 1 or 0)
end
function CustomerItemCtrl:SetShowOrder(bShow)
if bShow then
self._mapNode.IceCreamOrderAnim:Play("IceCreamOrder_in")
WwiseAudioMgr:PostEvent("mode_400013_pop")
self._mapNode.CompleteRoot:SetActive(false)
self._bPendingOrderOut = false
self._bScorePopupPlaying = false
elseif self._bScorePopupPlaying then
self._bPendingOrderOut = true
else
self:_PlayOrderOutNow()
end
local canvasOrder = self._mapNode.imgIceCreamOrder:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupAlpha(canvasOrder, bShow and 1 or 0)
local canvasPatience = self._mapNode.Patience:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupAlpha(canvasPatience, bShow and 1 or 0)
end
function CustomerItemCtrl:_PlayOrderOutNow()
self._bPendingOrderOut = false
self._mapNode.IceCreamOrderAnim:Play("IceCreamOrder_out")
if self._fnOrderOutDone == nil then
return
end
local nDur = NovaAPI.GetAnimClipLength(self._mapNode.IceCreamOrderAnim, {
"IceCreamOrder_out"
})
if type(nDur) ~= "number" or nDur <= 0 then
nDur = 0.5
end
if self.orderOutDoneTimer ~= nil then
TimerManager.Remove(self.orderOutDoneTimer)
self.orderOutDoneTimer = nil
end
self.orderOutDoneTimer = self:AddTimer(1, nDur, "_OnOrderOutDone", true, true)
end
function CustomerItemCtrl:_OnOrderOutDone()
self.orderOutDoneTimer = nil
local fn = self._fnOrderOutDone
self._fnOrderOutDone = nil
if fn then
fn()
end
end
function CustomerItemCtrl:SetOnOrderOutDone(fnDone)
self._fnOrderOutDone = fnDone
end
function CustomerItemCtrl:_KillOrderOutDoneTimer()
if self.orderOutDoneTimer ~= nil then
TimerManager.Remove(self.orderOutDoneTimer)
self.orderOutDoneTimer = nil
end
self._fnOrderOutDone = nil
end
function CustomerItemCtrl:MoveTrIceIcon()
if not self.CurSpineId then
return
end
local spineGo = SpineManager.GetGameObject(self.CurSpineId)
if not spineGo then
return
end
local trParent = spineGo.transform:Find("Skeleton/hand_right")
if not trParent then
return
end
local trIcon = self._mapNode.IceCreamIcon.transform
trIcon:SetParent(trParent, false)
trIcon.localPosition = Vector3.zero
trIcon.localRotation = Quaternion.identity
trIcon.localScale = Vector3.one
local rt = trIcon:GetComponent("RectTransform")
if rt then
rt.anchoredPosition3D = Vector3.zero
rt.sizeDelta = rt.sizeDelta
end
self._mapNode.IceCreamIcon:SetParent(trParent)
self.time = 0.37 / self:_GetMoveScale()
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForSeconds(self.time))
self:EnableIceIcon(true)
end
cs_coroutine.start(wait)
end
function CustomerItemCtrl:CreatIceCreamIcon()
for _, txt in ipairs(self._mapNode.Icon_) do
local canvasGroup = txt:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupAlpha(canvasGroup, 0)
end
if self.bGetOrder then
local tbSlots = self._mapNode.IceCreamOrder:GetSlots()
if tbSlots == nil then
return
end
for step, v in ipairs(tbSlots) do
if v ~= 0 then
local nDisplay = self._mapNode.IceCreamOrder:GetDisplayIndex(step)
if nDisplay ~= nil then
local IconPath = IceCreamUtils.SetCondimentIcon(step, v)
if IconPath == "" then
printError("资源路径是空的")
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Icon_[nDisplay]:GetComponent("CanvasGroup"), 0)
else
self:SetActivityAtlasSprite_New(self._mapNode.Icon_[nDisplay], "_400013/SpriteAtlas/Item", IconPath)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Icon_[nDisplay]:GetComponent("CanvasGroup"), 1)
end
end
end
end
end
end
function CustomerItemCtrl:EnableIceIcon(bShow)
self._mapNode.IceCreamIcon.gameObject:SetActive(bShow)
end
function CustomerItemCtrl:ReverTrIceIcon()
self._mapNode.IceCreamIcon:SetParent(self._mapNode.Char.transform)
self:EnableIceIcon(false)
end
function CustomerItemCtrl:RefreshPatienceList()
local img = self._mapNode and self._mapNode.imgProgressBar
if img == nil then
return
end
local nMax = self.MaxPatienceValue
local nCur = math.max(0, self.PatienceValue or 0)
if nMax == nil or nMax <= 0 then
nMax = 0 < nCur and nCur or 1
end
if nCur > nMax then
nCur = nMax
end
NovaAPI.SetImageFillAmount(img, nCur / nMax)
end
function CustomerItemCtrl:SetPatienceLockBuff(bShow)
self._mapNode.img_ProgressLock:SetActive(bShow)
self._mapNode.img_ProgressBarLock:SetActive(bShow)
end
function CustomerItemCtrl:CustomerLeaveQueue(nCustomerId, bSucceed)
if self.nCharacterId == nil or nCustomerId == nil then
return
end
if nCustomerId ~= self.nCharacterId then
return
end
if self._bLeaving then
return
end
self._bLeaving = true
self._bStartLeavingFired = false
self.bInPatience = false
self:SetShowOrder(false)
TimerManager.Remove(self.remainTimer)
self.remainTimer = nil
self:_KillPatienceTween()
local ePerform
if bSucceed then
ePerform = enumCustomerState.happy
if self.bIsSpecial and self.nItemID ~= 0 then
EventManager.Hit("Event_GetNewItem", self.nItemID)
end
self:MoveTrIceIcon()
else
ePerform = enumCustomerState.angry
end
self:SetStatusSwitch(ePerform, false)
local eWalk = LEAVE_PERFORM_MAP[ePerform]
local nGen = IceCreamTruckGameCtrl.GetRestartGen()
local fDur = SpineManager.GetAnimDuration(self.CurSpineId, ePerform)
if fDur == nil or fDur <= 0 then
fDur = FALLBACK_PERFORM_DURATION
end
self:_StartLeavePerformDelay(fDur, nGen, function()
if nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
return
end
if self.nCharacterId == nil then
return
end
self:_FireStartLeavingOnce()
if eWalk then
self:SetStatusSwitch(eWalk, true)
end
self:MoveToTargetPoint(self.RecyclePoint, function()
EventManager.Hit("Event_ReturnCustomer", self.nCharacterId)
end)
end)
end
function CustomerItemCtrl:_FireStartLeavingOnce()
if self._bStartLeavingFired then
return
end
self._bStartLeavingFired = true
EventManager.Hit("Event_FirstCustomerStartLeaving", self.nCharacterId)
end
function CustomerItemCtrl:_StartLeavePerformDelay(fDuration, nGen, fnDone)
self:_KillLeavePerformTimer()
self.tbLeavePerformCtx = {nGen = nGen, fnDone = fnDone}
self.leavePerformTimer = self:AddTimer(1, fDuration, "_OnLeavePerformDone", true, true, false)
if self.leavePerformTimer ~= nil then
self.leavePerformTimer:SetSpeed(self:_GetMoveScale())
local gameCtrl = IceCreamTruckGameCtrl.GetInstance()
if gameCtrl and gameCtrl.bIPause then
self.leavePerformTimer:Pause(true)
end
end
end
function CustomerItemCtrl:_OnLeavePerformDone()
local ctx = self.tbLeavePerformCtx
self:_KillLeavePerformTimer()
if ctx == nil then
return
end
if ctx.nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
return
end
if ctx.fnDone then
ctx.fnDone()
end
end
function CustomerItemCtrl:_KillLeavePerformTimer()
if self.leavePerformTimer ~= nil then
TimerManager.Remove(self.leavePerformTimer)
self.leavePerformTimer = nil
end
self.tbLeavePerformCtx = nil
end
function CustomerItemCtrl:_TryFireStartLeavingOnInterrupt()
if self._bLeaving and not self._bStartLeavingFired then
self:_FireStartLeavingOnce()
end
end
function CustomerItemCtrl:GetOrdersCtrl()
return self._mapNode.IceCreamOrder
end
function CustomerItemCtrl:GetCustomerId()
return self.nCharacterId
end
function CustomerItemCtrl:IsSpecial()
return self.bIsSpecial
end
function CustomerItemCtrl:IsReadyToServe()
return self.bInPatience == true
end
function CustomerItemCtrl:ShowCompleteRoot(BaseScore, FComboMul, FeverMul, FBuffMul)
self._mapNode.CompleteRoot:SetActive(true)
local nBaseScore = BaseScore * FeverMul
local sBaseScore = string.format("+%d", nBaseScore)
local nBuffMul = FComboMul * FBuffMul
NovaAPI.SetTMPText(self._mapNode.txt_BaseScore, sBaseScore)
NovaAPI.SetTMPText(self._mapNode.txt_TimesScore, string.format("%.1f", nBuffMul))
local sKey = "CompleteRoot_in1"
if 1 <= nBuffMul and nBuffMul < 1.2 then
sKey = "CompleteRoot_in1"
elseif 1.2 <= nBuffMul and nBuffMul <= 1.5 then
sKey = "CompleteRoot_in1_2"
elseif 1.5 < nBuffMul and nBuffMul <= 2.5 then
sKey = "CompleteRoot_in1_5"
elseif 3 <= nBuffMul then
sKey = "CompleteRoot_in2"
end
self._mapNode.CompleteRootAnimator:Play(sKey)
WwiseAudioMgr:PostEvent("mode_400013_goal")
if 1.2 <= nBuffMul then
WwiseAudioMgr:PostEvent("mode_400013_goal_ex")
end
self._bScorePopupPlaying = true
local nDur = NovaAPI.GetAnimClipLength(self._mapNode.CompleteRootAnimator, {sKey})
if type(nDur) ~= "number" or nDur <= 0 then
nDur = 1.0
end
if self.scorePopupTimer ~= nil then
TimerManager.Remove(self.scorePopupTimer)
self.scorePopupTimer = nil
end
self.scorePopupTimer = self:AddTimer(1, nDur, "_OnScorePopupDone", true, true)
end
function CustomerItemCtrl:_OnScorePopupDone()
self.scorePopupTimer = nil
self._bScorePopupPlaying = false
if self._bPendingOrderOut then
self:_PlayOrderOutNow()
end
end
function CustomerItemCtrl:_KillScorePopupTimer()
if self.scorePopupTimer ~= nil then
TimerManager.Remove(self.scorePopupTimer)
self.scorePopupTimer = nil
end
self._bScorePopupPlaying = false
self._bPendingOrderOut = false
end
function CustomerItemCtrl:Event_OrderMakeMistake(nCustomerId)
if self.nCharacterId == nil or nCustomerId == nil then
return
end
if nCustomerId ~= self.nCharacterId then
return
end
self:SetStatusSwitch(enumCustomerState.sad, false, enumCustomerState.idle)
end
function CustomerItemCtrl:Event_Pause(bPause)
if self.remainTimer ~= nil then
self.remainTimer:Pause(bPause)
end
if self._patienceTweener ~= nil then
if bPause then
self:_SnapshotPatienceFromImage()
self._patienceTweener:Pause()
elseif not self.bInFever and not self.bFreezePatience then
self._patienceTweener:Play()
end
end
if self.moveTimer ~= nil then
self.moveTimer:Pause(bPause)
end
if self.leavePerformTimer ~= nil then
self.leavePerformTimer:Pause(bPause)
end
if self.scorePopupTimer ~= nil then
self.scorePopupTimer:Pause(bPause)
end
if self.orderOutDoneTimer ~= nil then
self.orderOutDoneTimer:Pause(bPause)
end
if self.CurSpineId then
if bPause then
SpineManager.Pause(self.CurSpineId)
else
SpineManager.Resume(self.CurSpineId)
end
end
end
function CustomerItemCtrl:_GetMoveScale()
return (self.fFeverFactor or 1) * (self.fBuffFactor or 1)
end
function CustomerItemCtrl:FeverModeChanged(bInFever)
self.bInFever = bInFever
self.fFeverFactor = bInFever and 2 or 1
self:RecalcSpeedBuff()
self:_ApplyPatienceGating()
end
function CustomerItemCtrl:Event_IceCreamPatienceFreeze(bFreeze)
self.bFreezePatience = bFreeze and true or false
self:SetPatienceLockBuff(self.bFreezePatience)
self:_ApplyPatienceGating()
end
function CustomerItemCtrl:_ApplyPatienceGating()
if self._patienceTweener == nil then
return
end
local gameCtrl = IceCreamTruckGameCtrl.GetInstance()
local bGlobalPause = gameCtrl and gameCtrl.bIPause
if self.bInFever or self.bFreezePatience or bGlobalPause then
self:_SnapshotPatienceFromImage()
self._patienceTweener:Pause()
else
self._patienceTweener:Play()
end
end
function CustomerItemCtrl:RecalcSpeedBuff()
self.nRemainSpeedBuff = self.fBuffFactor or 1
if self.remainTimer ~= nil then
self.remainTimer:SetSpeed(self.nRemainSpeedBuff)
end
self:_ApplyPatienceTweenScale()
if self.moveTimer ~= nil then
self.moveTimer:SetSpeed(self:_GetMoveScale())
end
if self.leavePerformTimer ~= nil then
self.leavePerformTimer:SetSpeed(self:_GetMoveScale())
end
self:SetSpineSpeed()
end
function CustomerItemCtrl:Event_IceCreamSpeedScaleChanged(fBuffScale_Speed)
self.fBuffFactor = fBuffScale_Speed
self:RecalcSpeedBuff()
end
function CustomerItemCtrl:RefillPatienceToMax()
self.PatienceValue = self.MaxPatienceValue or self.PatienceValue
if self.bInPatience then
self:_StartPatienceTween()
else
self:RefreshPatienceList()
end
end
function CustomerItemCtrl:AddPatienceVal(nPatienceVal)
self:_SnapshotPatienceFromImage()
if 0 <= nPatienceVal then
self.PatienceValue = math.min(self.PatienceValue + nPatienceVal, self.MaxPatienceValue)
else
self.PatienceValue = math.max(self.PatienceValue + nPatienceVal, 0)
end
if self.bInPatience then
self:_StartPatienceTween()
else
self:RefreshPatienceList()
end
local sTip = string.format("当前顾客耐心值:%d", self.PatienceValue)
EventManager.Hit(EventId.OpenMessageBox, sTip)
end
function CustomerItemCtrl:RefreshCurrentCustomer(CustomerId)
self:ClearSpine()
self:CreatSpine(CustomerId)
end
return CustomerItemCtrl
@@ -0,0 +1,207 @@
local CustomerQueueCtrl = class("CustomerQueueCtrl", BaseCtrl)
local IceCreamUtils = require("Game.UI.Play_IceCreamTruck.Play.IceCreamUtils")
local IceCreamTruckGameCtrl = require("Game.UI.Play_IceCreamTruck.Play.IceCreamTruckGameCtrl")
local enumQueueType = IceCreamUtils.EnumQueueType
CustomerQueueCtrl._mapNodeConfig = {
Customers = {
sCtrlName = "Game.UI.Play_IceCreamTruck.Play.CustomersCtrl"
},
obj_Point = {nCount = 4}
}
CustomerQueueCtrl._mapEventConfig = {
Event_FirstCustomerLeave = "Event_FirstCustomerLeave",
Event_FirstCustomerStartLeaving = "Event_FirstCustomerStartLeaving",
Event_StartBusiness = "Event_StartBusiness"
}
function CustomerQueueCtrl:Awake()
local param = self:GetPanelParam()
if type(param) == "table" then
self.nActId = param[1]
self.nLevelId = param[2]
end
self.nPendingCount = 0
self.tbQueuePoints = {}
self.MaxQueueLine = 4
self.LevelData = ConfigTable.GetData("ActivityIceCreamLevel", self.nLevelId)
end
function CustomerQueueCtrl:OnEnable()
if self.LevelData == nil then
printError("LevelData是空的")
end
self._bOpened = false
end
function CustomerQueueCtrl:Event_StartBusiness()
if self._bOpened then
return
end
self:StartOpen()
end
function CustomerQueueCtrl:StartOpen()
self._bOpened = true
EventManager.Hit("Event_InitCharPool", self.LevelData)
EventManager.Hit("Event_InitBuffPool", self.LevelData)
self:InitQueuePoints()
self._mapNode.Customers:Init()
local fInitInterval = 1.5
for i = 1, self.MaxQueueLine do
self:CreatWaitCustomers((i - 1) * fInitInterval)
end
end
function CustomerQueueCtrl:CreatWaitCustomers(nDelay)
local nMax = self.LevelData.CustomerCount
if nMax and 0 < nMax and nMax <= self._mapNode.Customers:GetAllCustomerCount() then
return
end
self.nPendingCount = self.nPendingCount + 1
self:TryFillQueuePoints(nDelay or 0)
end
function CustomerQueueCtrl:InitQueuePoints()
for i, point in ipairs(self._mapNode.obj_Point) do
local rectTransform = point.gameObject:GetComponent("RectTransform")
if i == 1 then
self.tbQueuePoints[i] = {
Point = rectTransform,
bIsFree = true,
enumQueueTyp = enumQueueType.InMake,
currentCustomerId = nil
}
else
self.tbQueuePoints[i] = {
Point = rectTransform,
bIsFree = true,
enumQueueTyp = enumQueueType.InQueue,
currentCustomerId = nil
}
end
end
end
function CustomerQueueCtrl:TryFillQueuePoints(nDelay)
local maxNum = self.LevelData.CustomerCount < 0 and self.MaxQueueLine or math.min(self.MaxQueueLine, self.LevelData.CustomerCount)
for i = 1, maxNum do
if self.tbQueuePoints[i].bIsFree and 0 < self.nPendingCount then
self.nPendingCount = self.nPendingCount - 1
local customerId = self._mapNode.Customers:GetCustomerNew(self.LevelData)
if customerId then
self.tbQueuePoints[i].currentCustomerId = customerId
self.tbQueuePoints[i].bIsFree = false
EventManager.Hit("Event_CustomerTeleportTo", customerId, self:GetSpawnPoint())
self:CustomerMove(self.tbQueuePoints[i], nDelay)
end
end
end
end
function CustomerQueueCtrl:CompactQueue()
local nDelay = 0
local fInterval = 0.4
for i = 1, #self.tbQueuePoints - 1 do
local currentPoint = self.tbQueuePoints[i]
local nextPoint = self.tbQueuePoints[i + 1]
if currentPoint.bIsFree and not nextPoint.bIsFree then
local customerId = nextPoint.currentCustomerId
currentPoint.bIsFree = false
currentPoint.currentCustomerId = customerId
nextPoint.bIsFree = true
nextPoint.currentCustomerId = nil
self:CustomerMove(currentPoint, nDelay)
nDelay = nDelay + fInterval
end
end
end
function CustomerQueueCtrl:Event_FirstCustomerLeave(customerId, bSucceed)
EventManager.Hit("Event_CustomerLeaveQueue", customerId, bSucceed)
local nIdx
for i = 1, self.MaxQueueLine do
if not self.tbQueuePoints[i].bIsFree and self.tbQueuePoints[i].currentCustomerId == customerId then
nIdx = i
break
end
end
if nIdx == nil then
printLog("[IceCream] FirstCustomerLeave: 找不到 id=" .. tostring(customerId) .. " 的队列槽位(可能已处理)")
return
end
if nIdx ~= 1 then
end
self._bPendingCompact = customerId
end
function CustomerQueueCtrl:Event_FirstCustomerStartLeaving(customerId)
if self._bPendingCompact == nil then
return
end
if self._bPendingCompact ~= customerId then
printLog(string.format("[IceCream] StartLeaving id 不匹配: pending=%s incoming=%s", tostring(self._bPendingCompact), tostring(customerId)))
return
end
self._bPendingCompact = nil
self.tbQueuePoints[1].currentCustomerId = nil
self.tbQueuePoints[1].bIsFree = true
self:CompactQueue()
self:CreatWaitCustomers()
end
function CustomerQueueCtrl:CustomerMove(QueuePoints, nDelay)
local nGen = IceCreamTruckGameCtrl.GetRestartGen()
local nExpectId = QueuePoints.currentCustomerId
if nExpectId == nil then
return
end
if 0 < nDelay then
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForSeconds(nDelay))
if nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
return
end
if QueuePoints.currentCustomerId ~= nExpectId then
return
end
EventManager.Hit("Event_CustomerMoveTo", QueuePoints)
end
cs_coroutine.start(wait)
else
cs_coroutine.start(function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
if nGen ~= IceCreamTruckGameCtrl.GetRestartGen() then
return
end
if QueuePoints.currentCustomerId ~= nExpectId then
return
end
EventManager.Hit("Event_CustomerMoveTo", QueuePoints)
end)
end
end
function CustomerQueueCtrl:ClearQueue()
self.nPendingCount = 0
if self.tbQueuePoints ~= nil then
self.tbQueuePoints = {}
end
self._bPendingCompact = nil
self._bOpened = false
end
function CustomerQueueCtrl:GetSpawnPoint()
return self.tbQueuePoints[self.MaxQueueLine].Point
end
function CustomerQueueCtrl:GetServingCustomer()
local slot = self.tbQueuePoints and self.tbQueuePoints[1]
if slot == nil or slot.bIsFree or slot.currentCustomerId == nil then
return nil
end
if self._mapNode.Customers == nil then
return nil
end
return self._mapNode.Customers:GetCustomerById(slot.currentCustomerId)
end
function CustomerQueueCtrl:Restart()
if self._mapNode.Customers and self._mapNode.Customers.Restart then
self._mapNode.Customers:Restart()
end
self.nPendingCount = 0
self.tbQueuePoints = {}
self._bPendingCompact = nil
self.LevelData = ConfigTable.GetData("ActivityIceCreamLevel", self.nLevelId)
if self.LevelData == nil then
printError("[IceCream] CustomerQueueCtrl:Restart LevelData 为空")
return
end
self._bOpened = false
end
return CustomerQueueCtrl
@@ -0,0 +1,230 @@
local CustomersCtrl = class("CustomersCtrl", BaseCtrl)
CustomersCtrl._mapNodeConfig = {
customerItem_ = {
nCount = 6,
sCtrlName = "Game.UI.Play_IceCreamTruck.Play.CustomerItemCtrl"
},
IceCreamBuffs = {
sCtrlName = "Game.UI.Play_IceCreamTruck.Play.IceCreamBuffsCtrl"
},
Point_Recycle = {}
}
CustomersCtrl._mapEventConfig = {
Event_ReturnCustomer = "Event_ReturnCustomer",
Event_InitCharPool = "InitCharPool"
}
function CustomersCtrl:Awake()
self.maxSize = 6
self.nCustomerCount = 0
self.tbCurrentCharPool = {}
self._nInstSeq = 0
self.ActiveRoles = {}
self:Init()
self.tbCustomersId = ConfigTable.GetConfigNumberArray("IceCreamSpecialCustomerId")
self.SpecialCustomerNum = ConfigTable.GetConfigNumber("IceCreamSpecialCustomerOrderNum")
self.SpecialProbability = ConfigTable.GetConfigNumber("IceCreamSpecialCustomerProbability")
self.PatienceGroup = ConfigTable.GetConfigNumber("IceCreamPatienceGroup")
self.PatienceLowerVal = ConfigTable.GetConfigNumber("IceCreamPatienceLowerValue")
self.PatiencePerReduce = ConfigTable.GetConfigNumber("IceCreamPatiencePerReduce")
end
function CustomersCtrl:OnEnable()
end
function CustomersCtrl:Init()
if self.UnActive == nil then
self.UnActive = {}
end
if self.InActive == nil then
self.InActive = {}
end
end
function CustomersCtrl:OnDestroy()
if self._mapNode and self._mapNode.customerItem_ then
for i = 1, self.maxSize do
local customerItem = self._mapNode.customerItem_[i]
if customerItem and customerItem.ClearSpine then
customerItem:ClearSpine()
end
end
end
self:ClearAllTable()
self.tbCurrentCharPool = {}
end
function CustomersCtrl:ClearAllTable()
if self.UnActive ~= nil then
self.UnActive = {}
end
if self.InActive ~= nil then
self.InActive = {}
end
end
function CustomersCtrl:_NextInstId()
self._nInstSeq = self._nInstSeq + 1
return self._nInstSeq
end
function CustomersCtrl:InitCharPool(LevelData)
if LevelData == nil then
printError("初始角色池--LevelData 为空")
return
end
self.LevelData = LevelData
self.nMaxPatienceValue = self.LevelData.PatienceValue
local nPoolId = self.LevelData.CharPoolId
local CurrentCharPool = {}
local forEachLine_CharPool = function(mapLineData)
if mapLineData.PoolId == nPoolId then
local nCharType = ConfigTable.GetData("IceCreamChar", mapLineData.CharId).CharType
table.insert(CurrentCharPool, {
charId = mapLineData.CharId,
weight = mapLineData.Weight,
charType = nCharType
})
end
end
ForEachTableLine(DataTable.IceCreamCharPool, forEachLine_CharPool)
self.tbCurrentCharPool = CurrentCharPool
self:CreatNewCustomers()
end
function CustomersCtrl:CreatNewCustomers()
self:ClearAllTable()
for i = 1, self.maxSize do
self._mapNode.customerItem_[i]:SetBlankData(self._mapNode.Point_Recycle.gameObject:GetComponent("RectTransform"), self.nMaxPatienceValue)
table.insert(self.UnActive, self._mapNode.customerItem_[i])
end
end
function CustomersCtrl:GetCustomerNew(CurrentLevelData)
if CurrentLevelData == nil then
printError("当前的关卡数据为空")
return
end
local AllCustomerCount = CurrentLevelData.CustomerCount
if 0 < AllCustomerCount and AllCustomerCount <= self.nCustomerCount then
printLog(string.format("[IceCream] 已达本关顾客上限:nCustomerCount=%d / CustomerCount=%d", self.nCustomerCount, AllCustomerCount))
return nil
end
if #self.UnActive == 0 then
printLog("[IceCream] 当前没有空缺角色对象,等待回收")
return nil
end
local customerItem = self.UnActive[1]
customerItem = self:SetInActiveCustomer(customerItem)
if customerItem == nil then
return nil
end
table.remove(self.UnActive, 1)
self.InActive[customerItem.nCharacterId] = customerItem
return customerItem.nCharacterId
end
function CustomersCtrl:SetInActiveCustomer(customerItem)
if not self.LevelData then
printError("关卡信息为空")
return nil
end
local nTryCount = self.nCustomerCount + 1
local bIsSpecial = false
if self.LevelData.LevelType ~= GameEnum.ActivityIceCreamLevelType.Teaching and nTryCount % self.SpecialCustomerNum == 0 then
bIsSpecial = math.random() <= self.SpecialProbability
end
local nItemID = 0
if bIsSpecial then
if not self.tbCustomersId or #self.tbCustomersId == 0 then
bIsSpecial = false
printError("特殊角色池数据为空")
else
local nBuffId = self._mapNode.IceCreamBuffs:GetBuffItemID()
if nBuffId == nil or nBuffId == 0 then
bIsSpecial = false
else
nItemID = nBuffId
end
end
end
local nSelectedRoleId
local bSpecialFromPool = false
if bIsSpecial then
nSelectedRoleId = self.tbCustomersId[math.random(1, #self.tbCustomersId)]
bSpecialFromPool = true
else
local tbCandidates = {}
local nTotalWeight = 0
for _, mapCfg in pairs(self.tbCurrentCharPool) do
local bAllowRepeat = mapCfg.charType == GameEnum.iceChar.Low
if bAllowRepeat or (self.ActiveRoles[mapCfg.charId] or 0) == 0 then
table.insert(tbCandidates, {
nId = mapCfg.charId,
nWeight = mapCfg.weight
})
nTotalWeight = nTotalWeight + mapCfg.weight
end
end
if #tbCandidates == 0 or nTotalWeight <= 0 then
printError("没有可用的候选角色")
return nil
end
local nRand = math.random(1, nTotalWeight)
local nCumWeight = 0
nSelectedRoleId = tbCandidates[1].nId
for _, item in ipairs(tbCandidates) do
nCumWeight = nCumWeight + item.nWeight
if nRand <= nCumWeight then
nSelectedRoleId = item.nId
break
end
end
end
self.nCustomerCount = nTryCount
if not bSpecialFromPool then
self.ActiveRoles[nSelectedRoleId] = (self.ActiveRoles[nSelectedRoleId] or 0) + 1
end
if self.LevelData.LevelType == GameEnum.ActivityIceCreamLevelType.Infinite and self.nCustomerCount % self.PatienceGroup == 0 then
self.nMaxPatienceValue = math.max(self.PatienceLowerVal, self.nMaxPatienceValue - self.PatiencePerReduce)
end
local nMaxScoop = self.LevelData.IceCreamBallLimit or 1
local nInstId = self:_NextInstId()
customerItem:SetActiveData(nInstId, nSelectedRoleId, bIsSpecial, nItemID, self.nMaxPatienceValue, nMaxScoop)
return customerItem
end
function CustomersCtrl:Event_ReturnCustomer(customerInstId)
local customerItem = self.InActive[customerInstId]
if not customerItem then
printError("要销毁的是未激活的错误实例ID:" .. tostring(customerInstId))
return
end
local roleId = customerItem.nRoleId
if roleId and self.ActiveRoles[roleId] then
self.ActiveRoles[roleId] = self.ActiveRoles[roleId] - 1
if self.ActiveRoles[roleId] <= 0 then
self.ActiveRoles[roleId] = nil
end
end
self.InActive[customerInstId] = nil
customerItem:ResetData()
table.insert(self.UnActive, customerItem)
end
function CustomersCtrl:GetAllCustomerCount()
return self.nCustomerCount
end
function CustomersCtrl:GetCustomerById(nInstId)
if nInstId == nil then
return nil
end
return self.InActive and self.InActive[nInstId] or nil
end
function CustomersCtrl:Restart()
for i = 1, self.maxSize do
local customerItem = self._mapNode.customerItem_[i]
if customerItem then
if customerItem._mapNode and customerItem._mapNode.IceCreamOrder then
customerItem._mapNode.IceCreamOrder:Clear()
end
customerItem:ResetData()
end
end
self.nCustomerCount = 0
self._nInstSeq = 0
self.ActiveRoles = {}
self.tbCurrentCharPool = {}
self.nMaxPatienceValue = nil
self:ClearAllTable()
self:CreatNewCustomers()
end
return CustomersCtrl
@@ -0,0 +1,74 @@
local IceCreamBackPackCtrl = class("IceCreamBackPackCtrl", BaseCtrl)
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
IceCreamBackPackCtrl._mapNodeConfig = {
txt_BagTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_BagTitle"
},
btn_Close = {
sComponentName = "NaviButton",
callback = "OnBtn_Close",
sAction = "Back"
},
txt_BuffItemInfo = {nCount = 2, sComponentName = "TMP_Text"},
obj_BuffItemUnEmpty = {nCount = 2},
obj_BuffItemEmpty = {nCount = 2},
txt_BuffItemTitle = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_EmptyTips"
},
txt_BuffItemEmpty = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_Empty"
}
}
IceCreamBackPackCtrl._mapEventConfig = {}
function IceCreamBackPackCtrl:Awake()
self.tbGamepadUINode = self:GetGamepadUINode()
end
function IceCreamBackPackCtrl:OnEnable()
self.gameObject:SetActive(false)
end
function IceCreamBackPackCtrl:OpenBackPack(tbCurrentItems)
GamepadUIManager.EnableGamepadUI("IceCreamBackPackCtrl", self.tbGamepadUINode)
if tbCurrentItems ~= nil then
EventManager.Hit("Event_SetPause", true)
self.gameObject:SetActive(true)
self:InitBackPack(tbCurrentItems)
end
end
function IceCreamBackPackCtrl:InitBackPack(tbCurrentItems)
for i = 1, 2 do
local value = tbCurrentItems[i] or 0
if value ~= 0 then
local txtItemName = self._mapNode.obj_BuffItemUnEmpty[i].transform:Find("txt_BuffItemName"):GetComponent("TMP_Text")
local txtItemInfo = self._mapNode.txt_BuffItemInfo[i]
local imgBuffIcon = self._mapNode.obj_BuffItemUnEmpty[i].transform:Find("ImgBuffIcon"):GetComponent("Image")
local buffData = ConfigTable.GetData("IceCreamBuff", value)
if buffData ~= nil then
NovaAPI.SetTMPText(txtItemName, buffData.Name)
NovaAPI.SetTMPText(txtItemInfo, buffData.Desc)
local IconPath = buffData.Icon
if IconPath == nil then
imgBuffIcon.gameObject:SetActive(false)
printError("道具资源路径为空,ID: " .. tostring(value))
else
self:SetActivityAtlasSprite_New(imgBuffIcon, "_400013/SpriteAtlas", IconPath)
end
end
end
self._mapNode.obj_BuffItemUnEmpty[i]:SetActive(value ~= 0)
self._mapNode.obj_BuffItemEmpty[i]:SetActive(value == 0)
end
end
function IceCreamBackPackCtrl:CloseBackPack()
GamepadUIManager.DisableGamepadUI("IceCreamBackPackCtrl")
EventManager.Hit("Event_SetPause", false)
self.gameObject:SetActive(false)
end
function IceCreamBackPackCtrl:OnBtn_Close(btn)
self:CloseBackPack()
end
return IceCreamBackPackCtrl
@@ -0,0 +1,164 @@
local TimerManager = require("GameCore.Timer.TimerManager")
local BuffItem_TimeSlow = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItem_TimeSlow")
local BuffItem_Patience = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItem_Patience")
local BuffItem_ScoreMul = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItem_ScoreMul")
local BuffItem_Life = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItem_Life")
local BuffItem_AutoOrder = require("Game.UI.Play_IceCreamTruck.Play.Buff.BuffItem_AutoOrder")
local IceCreamBuffRuntimeCtrl = class("IceCreamBuffRuntimeCtrl")
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
local BuffClassMap = {
[GameEnum.IceBuffEffect.Time] = BuffItem_TimeSlow,
[GameEnum.IceBuffEffect.Patience] = BuffItem_Patience,
[GameEnum.IceBuffEffect.Score] = BuffItem_ScoreMul,
[GameEnum.IceBuffEffect.HP] = BuffItem_Life,
[GameEnum.IceBuffEffect.Order] = BuffItem_AutoOrder
}
function IceCreamBuffRuntimeCtrl:Init(ctx)
self.ctx = ctx
self.tbActive = {}
end
function IceCreamBuffRuntimeCtrl:Clear()
if self.tbActive == nil then
return
end
for _, node in pairs(self.tbActive) do
if node.timer then
TimerManager.Remove(node.timer, false)
end
if node.inst then
node.inst:Revoke(self.ctx)
end
end
self.tbActive = {}
end
function IceCreamBuffRuntimeCtrl:IsTypeActive(nBuffType)
return self.tbActive[nBuffType] ~= nil
end
function IceCreamBuffRuntimeCtrl:ReadCfg(nItemId)
local cfg = ConfigTable.GetData("IceCreamBuff", nItemId)
if cfg == nil then
printError("道具ID未配置:" .. tostring(nItemId))
end
return cfg
end
function IceCreamBuffRuntimeCtrl:TryUseBuff(nItemId)
local cfg = self:ReadCfg(nItemId)
if cfg == nil then
return false
end
local nBuffType = cfg.BuffType
local BuffClass = BuffClassMap[nBuffType]
if BuffClass == nil then
printError("未注册的 BuffType:" .. tostring(nBuffType))
return false
end
if self:IsTypeActive(nBuffType) then
printLog("同类型 Buff 已生效,无法叠加。BuffType=" .. tostring(nBuffType))
return false
end
local inst = BuffClass.new()
inst:Init(cfg)
inst:Apply(self.ctx)
local nDuration = inst:GetDuration() or 0
if nDuration <= 0 then
printLog(string.format("道具 %d 已生效(类型=%s, 瞬发)", nItemId, tostring(nBuffType)))
EventManager.Hit("Event_IceCreamBuffStart", nBuffType, nItemId, 0)
return true
end
local node = {
inst = inst,
timer = nil,
nLeftSec = nDuration
}
self.tbActive[nBuffType] = node
node.timer = TimerManager.Add(nDuration, 1, self, function()
self:_OnBuffTick(nBuffType, nItemId)
end, true, true, false)
local fScale = self.ctx and self.ctx.getSpeedScale and self.ctx.getSpeedScale() or 1
if node.timer ~= nil and fScale ~= 1 and 0 < fScale then
node.timer:SetSpeed(fScale)
end
EventManager.Hit("Event_IceCreamBuffStart", nBuffType, nItemId, nDuration)
self:SetBuffAuido(nItemId, true)
return true
end
function IceCreamBuffRuntimeCtrl:_OnBuffTick(nBuffType, nItemId)
local node = self.tbActive[nBuffType]
if node == nil then
return
end
node.nLeftSec = (node.nLeftSec or 0) - 1
if node.nLeftSec < 0 then
node.nLeftSec = 0
end
EventManager.Hit("Event_IceCreamBuffTick", nBuffType, nItemId, node.nLeftSec)
if node.nLeftSec <= 0 then
self:RemoveBuff(nBuffType, nItemId)
end
end
function IceCreamBuffRuntimeCtrl:RemoveBuff(nBuffType, nItemId)
local node = self.tbActive[nBuffType]
if node == nil then
return
end
self.tbActive[nBuffType] = nil
if node.timer then
TimerManager.Remove(node.timer, false)
node.timer = nil
end
if node.inst then
node.inst:Revoke(self.ctx)
end
printLog(string.format("道具 %d 生效结束(类型=%s", nItemId, tostring(nBuffType)))
EventManager.Hit("Event_IceCreamBuffEnd", nBuffType, nItemId)
self:SetBuffAuido(nItemId, false)
end
function IceCreamBuffRuntimeCtrl:InPause(bPause)
if self.tbActive == nil then
return
end
for _, node in pairs(self.tbActive) do
if node.timer ~= nil then
node.timer:Pause(bPause)
end
end
end
function IceCreamBuffRuntimeCtrl:SetTimersSpeed(fScale)
if self.tbActive == nil then
return
end
if fScale == nil or fScale <= 0 then
fScale = 1
end
for _, node in pairs(self.tbActive) do
if node.timer ~= nil then
node.timer:SetSpeed(fScale)
end
end
end
function IceCreamBuffRuntimeCtrl:SetBuffAuido(nBuffId, bIsUse)
if nBuffId == 101 then
if bIsUse then
WwiseAudioMgr:PostEvent("mode_400013_lowtime_lp")
else
WwiseAudioMgr:PostEvent("mode_400013_lowtime_lp_stop")
end
elseif nBuffId == 102 then
if bIsUse then
WwiseAudioMgr:PostEvent("mode_400013_veryhappy")
end
elseif nBuffId == 103 then
if bIsUse then
WwiseAudioMgr:PostEvent("mode_400013_doubletime_lp")
else
WwiseAudioMgr:PostEvent("mode_400013_doubletime_lp_stop")
end
elseif nBuffId == 105 then
if bIsUse then
WwiseAudioMgr:PostEvent("mode_400013_auto_lp")
else
WwiseAudioMgr:PostEvent("mode_400013_auto_stop")
end
end
end
return IceCreamBuffRuntimeCtrl
@@ -0,0 +1,79 @@
local IceCreamBuffsCtrl = class("IceCreamBuffsCtrl", BaseCtrl)
IceCreamBuffsCtrl._mapEventConfig = {
Event_InitBuffPool = "InitBuffPool",
GMEvent_PrintBuffPool = "GM_PrintBuffPool"
}
function IceCreamBuffsCtrl:Awake()
self.tbCurrentBuffsPool = {}
end
function IceCreamBuffsCtrl:OnEnable()
end
function IceCreamBuffsCtrl:OnDestroy()
self.tbCurrentBuffsPool = {}
end
function IceCreamBuffsCtrl:InitBuffPool(LevelData)
if LevelData == nil then
printError("初始道具池--LevelData 为空")
return
end
self.LevelData = LevelData
local nPoolId = self.LevelData.BuffPoolId
local CurrentBuffPool = {}
local forEachLine_BuffPool = function(mapLineData)
if mapLineData.PoolId == nPoolId then
table.insert(CurrentBuffPool, {
buffId = mapLineData.BuffId,
weight = mapLineData.Weight
})
end
end
ForEachTableLine(DataTable.IceCreamBuffPool, forEachLine_BuffPool)
self.tbCurrentBuffsPool = CurrentBuffPool
end
function IceCreamBuffsCtrl:GetBuffItemID()
local tbAllBuff = self.tbCurrentBuffsPool
local tbCandidates = {}
local nTotalWeight = 0
for _, mapCfg in ipairs(tbAllBuff) do
table.insert(tbCandidates, {
nId = mapCfg.buffId,
nWeight = mapCfg.weight
})
nTotalWeight = nTotalWeight + mapCfg.weight
end
if #tbCandidates == 0 or nTotalWeight <= 0 then
printError("没有可用的候选道具")
return nil
end
local nRand = math.random(1, nTotalWeight)
local nCumWeight = 0
local nSelectedId = tbCandidates[1].nId
for _, item in ipairs(tbCandidates) do
nCumWeight = nCumWeight + item.nWeight
if nRand <= nCumWeight then
nSelectedId = item.nId
break
end
end
return nSelectedId
end
function IceCreamBuffsCtrl:GM_PrintBuffPool()
if self.tbCurrentBuffsPool == nil or #self.tbCurrentBuffsPool == 0 then
printLog("[IceCream][GM] 当前道具池为空")
return
end
local nTotalWeight = 0
for _, mapCfg in ipairs(self.tbCurrentBuffsPool) do
nTotalWeight = nTotalWeight + mapCfg.weight
end
printLog(string.format("[IceCream][GM] 当前道具池数量=%d, 总权重=%d", #self.tbCurrentBuffsPool, nTotalWeight))
for _, mapCfg in ipairs(self.tbCurrentBuffsPool) do
local nBuffId = mapCfg.buffId
local nWeight = mapCfg.weight
local mapBuffCfg = ConfigTable.GetData("IceCreamBuff", nBuffId)
local sName = mapBuffCfg ~= nil and mapBuffCfg.Name or "<未配置>"
local fProb = 0 < nTotalWeight and nWeight / nTotalWeight * 100 or 0
printLog(string.format("buffId:%d, Name%s, weight%d ,概率:%.2f%%", nBuffId, tostring(sName), nWeight, fProb))
end
end
return IceCreamBuffsCtrl
@@ -0,0 +1,116 @@
local LocalData = require("GameCore.Data.LocalData")
local RapidJson = require("rapidjson")
local IceCreamLevelData = class("IceCreamLevelData")
function IceCreamLevelData:InitData(nLevelId, nActId)
self.levelId = nLevelId
self.nActId = nActId
self.cacheHasDicList = {}
self.levelConfig = ConfigTable.GetData("ActivityIceCreamLevel", nLevelId)
if not self.levelConfig then
printError("关卡Id" .. nLevelId .. "不存在")
return
end
self:InitTbBuffs()
local sJson = LocalData.GetPlayerLocalData("IceCreamDicId")
local tb = decodeJson(sJson)
if type(tb) == "table" then
self.cacheHasDicList = tb
end
end
function IceCreamLevelData:InitTbBuffs()
if self.tbCurrentBuffs == nil then
self.tbCurrentBuffs = {}
self.tbCurrentBuffs[1] = 0
self.tbCurrentBuffs[2] = 0
end
end
function IceCreamLevelData:GetCurrentLevelData(nLevelId)
if self.levelId ~= nLevelId then
printError("关卡ID 错误")
return nil
end
return self.levelConfig
end
function IceCreamLevelData:GetNewBuffItem(nItemId)
local nIndex = 1
local bSlot1Empty = self.tbCurrentBuffs[1] == 0
local bSlot2Empty = self.tbCurrentBuffs[2] == 0
if bSlot1Empty and bSlot2Empty then
self.tbCurrentBuffs[1] = nItemId
elseif bSlot1Empty then
self.tbCurrentBuffs[1] = nItemId
elseif bSlot2Empty then
self.tbCurrentBuffs[2] = nItemId
nIndex = 2
else
self.tbCurrentBuffs[1] = self.tbCurrentBuffs[2]
self.tbCurrentBuffs[2] = nItemId
nIndex = 2
end
return nIndex
end
function IceCreamLevelData:GetCurrentBuffs()
if not self.tbCurrentBuffs then
self:InitTbBuffs()
end
return self.tbCurrentBuffs
end
function IceCreamLevelData:UseBuffsItem(nItemId, nIndex)
if self.tbCurrentBuffs[nIndex] == nil or self.tbCurrentBuffs[nIndex] ~= nItemId then
printError("在不存在的位置点击了道具--虚空索道具")
return
end
self.tbCurrentBuffs[nIndex] = 0
printLog("使用了道具:" .. nItemId)
end
function IceCreamLevelData:GetCurrentLevelFever()
if self.levelConfig == nil then
return -1
end
return self.levelConfig.Fever
end
function IceCreamLevelData:IsTrueBuffID(nBuffId)
if ConfigTable.GetData("IceCreamBuff", nBuffId) then
return true
end
return false
end
function IceCreamLevelData:GM_GetNewBuffItem(nBuffId, nIndex)
self.tbCurrentBuffs[nIndex] = nBuffId
end
function IceCreamLevelData:GetFloorHasOpenDic(nLevelId)
if self.levelId ~= nLevelId then
printError("关卡ID 错误")
return false
end
local bResult = false
if self.levelConfig ~= nil and self.levelConfig.DictionaryId ~= 0 then
if table.indexof(self.cacheHasDicList, nLevelId) == 0 then
bResult = false
else
bResult = true
end
end
return bResult
end
function IceCreamLevelData:GetDicId(nLevelId)
if self.levelId ~= nLevelId then
printError("关卡ID 错误")
return 0
end
if self.levelConfig ~= nil then
return self.levelConfig.DictionaryId
end
return 0
end
function IceCreamLevelData:OnEvent_SetFloorHasDic(nLevelId)
if table.indexof(self.cacheHasDicList, nLevelId) == 0 then
table.insert(self.cacheHasDicList, nLevelId)
local tbLocalSave = {}
for _, v in ipairs(self.cacheHasDicList) do
table.insert(tbLocalSave, v)
end
LocalData.SetPlayerLocalData("IceCreamDicId", RapidJson.encode(tbLocalSave))
end
end
return IceCreamLevelData
@@ -0,0 +1,154 @@
local IceCreamOrdersCtrl = class("IceCreamOrdersCtrl", BaseCtrl)
local IceCreamUtils = require("Game.UI.Play_IceCreamTruck.Play.IceCreamUtils")
local SLOT_CONE = IceCreamUtils.EnumSlotType.SLOT_CONE
local SLOT_SCOOP1 = IceCreamUtils.EnumSlotType.SLOT_SCOOP1
local SLOT_SCOOP2 = IceCreamUtils.EnumSlotType.SLOT_SCOOP2
local SLOT_TOPPING = IceCreamUtils.EnumSlotType.SLOT_TOPPING
local SLOT_COUNT = 6
IceCreamOrdersCtrl._mapNodeConfig = {
imgIcon_ = {nCount = 6, sComponentName = "Image"}
}
IceCreamOrdersCtrl._mapEventConfig = {}
function IceCreamOrdersCtrl:Awake()
end
function IceCreamOrdersCtrl:OnEnable()
end
function IceCreamOrdersCtrl:OnDestroy()
end
function IceCreamOrdersCtrl:InitNewOrder()
self.nCharacterId = nil
self.nOrderState = IceCreamUtils.EnumOrderState.Null
self.tbSlots = {}
for i = 1, SLOT_COUNT do
self.tbSlots[i] = 0
end
self.nScoopCount = 0
self.nCurrentStep = 0
self.bHasMistake = false
end
function IceCreamOrdersCtrl:SetNewOrder(nCharacterId, nMaxScoop, nToppingChance)
self:InitNewOrder()
self.nCharacterId = nCharacterId
self:RandomOrder(nMaxScoop, 100)
if self.tbSlots[1] == 0 then
return false
end
self:CreatIceCreamIcon()
return true
end
function IceCreamOrdersCtrl:Clear()
self.nCharacterId = nil
self.nOrderState = IceCreamUtils.EnumOrderState.Null
self.nCurrentStep = 0
self.bHasMistake = false
self.nScoopCount = 0
if self.tbSlots then
for i = 1, SLOT_COUNT do
self.tbSlots[i] = 0
end
end
end
function IceCreamOrdersCtrl:RandomOrder(nMaxScoop, nToppingChance)
nMaxScoop = nMaxScoop or 3
nToppingChance = nToppingChance or 50
for i = 1, SLOT_COUNT do
self.tbSlots[i] = 0
end
self.tbSlots[SLOT_CONE] = math.random(1, 2)
self.nScoopCount = math.random(1, nMaxScoop)
for i = 1, self.nScoopCount do
self.tbSlots[SLOT_SCOOP1 + i - 1] = math.random(3, 6)
end
if nToppingChance >= math.random(1, 100) then
self.tbSlots[SLOT_TOPPING] = math.random(8, 11)
end
end
function IceCreamOrdersCtrl:CheckStep(nSlotIndex, nValue)
if self.tbSlots[nSlotIndex] == nValue and nSlotIndex == (self:GetNextStepIndex() or -1) then
self.nCurrentStep = nSlotIndex
if self:IsOrderComplete() then
self.nOrderState = self.bHasMistake and IceCreamUtils.EnumOrderState.Normal or IceCreamUtils.EnumOrderState.Perfect
end
return true
else
self.bHasMistake = true
self.nCurrentStep = 0
return false
end
end
function IceCreamOrdersCtrl:GetOrderState()
return self.nOrderState
end
function IceCreamOrdersCtrl:GetCharacterId()
return self.nCharacterId
end
function IceCreamOrdersCtrl:GetDisplayIndex(nSlotIndex)
if not nSlotIndex or not self.tbSlots then
return nil
end
if (self.tbSlots[nSlotIndex] or 0) == 0 then
return nil
end
local n = 0
for i = 1, nSlotIndex do
if self.tbSlots[i] ~= 0 then
n = n + 1
end
end
return n
end
function IceCreamOrdersCtrl:IsOrderComplete()
for i = 1, SLOT_COUNT do
if self.tbSlots[i] ~= 0 and i > self.nCurrentStep then
return false
end
end
return true
end
function IceCreamOrdersCtrl:GetSlots()
return self.tbSlots
end
function IceCreamOrdersCtrl:IsFresh()
return (self.nCurrentStep or 0) == 0
end
function IceCreamOrdersCtrl:IsFinished()
return self:IsOrderComplete() and 0 < (self.nCurrentStep or 0)
end
function IceCreamOrdersCtrl:MarkPerfectComplete()
self.nCurrentStep = SLOT_COUNT
self.bHasMistake = false
self.nOrderState = IceCreamUtils.EnumOrderState.Perfect
end
function IceCreamOrdersCtrl:GetNextStepIndex()
if self.nCurrentStep == nil then
self.nCurrentStep = 0
end
for i = self.nCurrentStep + 1, SLOT_COUNT do
if self.tbSlots[i] ~= 0 then
return i
end
end
return nil
end
function IceCreamOrdersCtrl:CreatIceCreamIcon()
for _, txt in ipairs(self._mapNode.imgIcon_) do
local canvasGroup = txt:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupAlpha(canvasGroup, 0)
end
for step, v in ipairs(self.tbSlots) do
if v ~= 0 then
local nDisplay = self:GetDisplayIndex(step)
if nDisplay ~= nil then
local IconPath = IceCreamUtils.SetCondimentIcon(step, v)
if IconPath == "" then
printError("资源路径是空的")
NovaAPI.SetCanvasGroupAlpha(self._mapNode.imgIcon_[nDisplay]:GetComponent("CanvasGroup"), 0)
else
self:SetActivityAtlasSprite_New(self._mapNode.imgIcon_[nDisplay], "_400013/SpriteAtlas/Item", IconPath)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.imgIcon_[nDisplay]:GetComponent("CanvasGroup"), 1)
end
end
end
end
end
return IceCreamOrdersCtrl
@@ -0,0 +1,158 @@
local IceCreamResultCtrl = class("IceCreamResultCtrl", BaseCtrl)
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
IceCreamResultCtrl._mapNodeConfig = {
txt_SettleScoreTitle = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_CurrentScore"
},
txt_SettleScore = {nCount = 2, sComponentName = "TMP_Text"},
txt_FinishOrderTitle = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_FinishOrder"
},
txt_SettleOrder = {nCount = 2, sComponentName = "TMP_Text"},
txt_MaxCombosTitle = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_MaxCombos"
},
txt_MaxCombos = {nCount = 2, sComponentName = "TMP_Text"},
txt_MaxScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_HistoryMaxScore"
},
txt_MaxScore = {sComponentName = "TMP_Text"},
txt_SucceedTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_Succeed"
},
txt_FailTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_Fail"
},
obj_Succeed = {},
obj_Fail = {},
obj_MaScoreBg = {},
btn_OutResult = {
nCount = 2,
sComponentName = "NaviButton",
callback = "OnBtn_OutResult",
sAction = "Retry"
},
btn_InRestart = {
sComponentName = "NaviButton",
callback = "OnBtn_InRestart",
sAction = "Giveup",
sActionIconType = "Dark"
},
btn_InNext = {
sComponentName = "NaviButton",
callback = "OnBtn_InNext",
sAction = "Giveup",
sActionIconType = "Dark"
},
txtBtnClose = {
nCount = 4,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_BtnEnd"
},
txtBtnNext = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_BtnNext"
},
txtBtnConfirm = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_BtnRestart"
}
}
function IceCreamResultCtrl:Awake()
self.tbGamepadUINode = self:GetGamepadUINode()
self.animator = self.gameObject:GetComponent("Animator")
self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
end
function IceCreamResultCtrl:FadeIn()
end
function IceCreamResultCtrl:FadeOut()
end
function IceCreamResultCtrl:OnEnable()
end
function IceCreamResultCtrl:OnDisable()
EventManager.Hit("Event_SetPause", false)
GamepadUIManager.DisableGamepadUI("IceCreamResultCtrl")
end
function IceCreamResultCtrl:OnDestroy()
end
function IceCreamResultCtrl:OnRelease()
end
function IceCreamResultCtrl:ShowResultPanel(bWin, nCurrentScore, nNumOrder, nMaxStreakCount, nMaxScore, bShowMaxScore, changeInfo, bNextTimeLock, nNextLevel)
EventManager.Hit("Event_SetPause", true)
GamepadUIManager.EnableGamepadUI("IceCreamResultCtrl", self.tbGamepadUINode)
self.bWin = bWin
NovaAPI.SetCanvasGroupAlpha(self.canvasGroup, 1)
self.gameObject:SetActive(true)
self._mapNode.obj_Succeed:SetActive(self.bWin)
self._mapNode.obj_Fail:SetActive(not self.bWin)
if self.bWin then
NovaAPI.SetTMPText(self._mapNode.txt_SettleScore[1], nCurrentScore)
NovaAPI.SetTMPText(self._mapNode.txt_SettleOrder[1], nNumOrder)
NovaAPI.SetTMPText(self._mapNode.txt_MaxCombos[1], nMaxStreakCount)
else
NovaAPI.SetTMPText(self._mapNode.txt_SettleScore[2], nCurrentScore)
NovaAPI.SetTMPText(self._mapNode.txt_SettleOrder[2], nNumOrder)
NovaAPI.SetTMPText(self._mapNode.txt_MaxCombos[2], nMaxStreakCount)
end
self.nNextLevel = nNextLevel
self._mapNode.obj_MaScoreBg:SetActive(bShowMaxScore)
if bShowMaxScore then
NovaAPI.SetTMPText(self._mapNode.txt_MaxScore, nMaxScore)
end
if self.bWin then
self._mapNode.btn_InNext.gameObject:SetActive(not bNextTimeLock)
end
EventManager.Hit(EventId.TemporaryBlockInput, 0.5)
self:AddTimer(1, 1, function()
if not self.gameObject or not changeInfo then
return
end
local mapReward = PlayerData.Item:ProcessRewardChangeInfo(changeInfo.Change)
local tbItem = {}
for _, v in pairs(mapReward.tbReward) do
local item = {
Tid = v.id,
Qty = v.count,
rewardType = AllEnum.RewardType.First
}
table.insert(tbItem, item)
end
UTILS.OpenReceiveByDisplayItem(tbItem, changeInfo.Change)
end, true, true, true)
end
function IceCreamResultCtrl:OnBtn_OutResult()
GamepadUIManager.DisableGamepadUI("IceCreamTruckGameCtrl")
self:CloseResultPanel()
EventManager.Hit("Event_ExitIceCreamTruckGame")
end
function IceCreamResultCtrl:OnBtn_InRestart()
self:CloseResultPanel()
EventManager.Hit("Event_RestartIceCreamTruckGame")
end
function IceCreamResultCtrl:OnBtn_InNext()
GamepadUIManager.DisableGamepadUI("IceCreamTruckGameCtrl")
self:CloseResultPanel()
if self.nNextLevel then
EventManager.Hit("IceCream_NextLevel", self.nNextLevel)
end
end
function IceCreamResultCtrl:CloseResultPanel()
EventManager.Hit("Event_SetPause", false)
NovaAPI.SetCanvasGroupAlpha(self.canvasGroup, 0)
self.gameObject:SetActive(false)
GamepadUIManager.DisableGamepadUI("IceCreamResultCtrl")
PlayerData.Base:SetSkipNewDayWindow(false)
PlayerData.Base:OnBackToMainMenuModule()
end
return IceCreamResultCtrl
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,20 @@
local IceCreamTruckGamePanel = class("IceCreamTruckGamePanel", BasePanel)
IceCreamTruckGamePanel._bIsMainPanel = true
IceCreamTruckGamePanel._sSortingLayerName = AllEnum.SortingLayerName.UI
IceCreamTruckGamePanel._sUIResRootPath = "UI_Activity/"
IceCreamTruckGamePanel._tbDefine = {
{
sPrefabPath = "_400013/IceCreamPlayPanel.prefab",
sCtrlName = "Game.UI.Play_IceCreamTruck.Play.IceCreamTruckGameCtrl"
}
}
function IceCreamTruckGamePanel:Awake()
PlayerData.Base:SetSkipNewDayWindow(true)
end
function IceCreamTruckGamePanel:OnEnable()
end
function IceCreamTruckGamePanel:OnDisable()
end
function IceCreamTruckGamePanel:OnDestroy()
end
return IceCreamTruckGamePanel
@@ -0,0 +1,119 @@
local IceCreamTruckPauseCtrl = class("IceCreamTruckPauseCtrl", BaseCtrl)
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
IceCreamTruckPauseCtrl._mapNodeConfig = {
blur = {},
txt_title = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_ThrowGifts_Text_Pause"
},
txt_exit = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_Button_Leave"
},
txt_restart = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_Button_Re"
},
txt_continue = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_Button_Back"
},
btn_exit = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Exit",
sAction = "Giveup",
sActionIconType = "Dark"
},
btn_restart = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Restart",
sAction = "Retry",
sActionIconType = "Dark"
},
btn_continue = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Continue",
sAction = "Back",
sActionIconType = "Dark"
},
txt_SettleScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_CurrentScore"
},
txt_SettleScore = {sComponentName = "TMP_Text"},
txt_FinishOrderTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_FinishOrder"
},
txt_SettleOrder = {sComponentName = "TMP_Text"},
txt_MaxCombosTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_MaxCombos"
},
txt_MaxCombos = {sComponentName = "TMP_Text"},
txt_MaxScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "IceCreamTruck_HistoryMaxScore"
},
txt_MaxScore = {sComponentName = "TMP_Text"},
txt_LevelName = {sComponentName = "TMP_Text"},
btn_dic = {
sComponentName = "NaviButton",
callback = "OnBtnClick_OpenDic",
sAction = "Depot",
sActionIconType = "Dark"
},
txt_dic = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "Tutorial_DicTitle"
},
obj_MaScoreBg = {}
}
IceCreamTruckPauseCtrl._mapEventConfig = {}
IceCreamTruckPauseCtrl._mapRedDotConfig = {}
function IceCreamTruckPauseCtrl:Awake()
self.tbGamepadUINode = self:GetGamepadUINode()
end
function IceCreamTruckPauseCtrl:Open(levelName, nCurrentScore, nNumOrder, nMaxStreakCount, nMaxScore, bShowMaxScore, nDicId)
self.gameObject:SetActive(true)
EventManager.Hit("Event_SetPause", true)
self:ShowPauseDetail(levelName, nCurrentScore, nNumOrder, nMaxStreakCount, nMaxScore, bShowMaxScore)
GamepadUIManager.EnableGamepadUI("IceCreamTruckPauseCtrl", self.tbGamepadUINode)
self.nDicId = nDicId
self._mapNode.btn_dic.gameObject:SetActive(self.nDicId ~= 0)
end
function IceCreamTruckPauseCtrl:Close()
self.gameObject:SetActive(false)
EventManager.Hit("Event_SetPause", false)
GamepadUIManager.DisableGamepadUI("IceCreamTruckPauseCtrl")
end
function IceCreamTruckPauseCtrl:ShowPauseDetail(levelName, nCurrentScore, nNumOrder, nMaxStreakCount, nMaxScore, bShowMaxScore)
NovaAPI.SetTMPText(self._mapNode.txt_LevelName, levelName)
NovaAPI.SetTMPText(self._mapNode.txt_SettleScore, nCurrentScore)
NovaAPI.SetTMPText(self._mapNode.txt_SettleOrder, nNumOrder)
NovaAPI.SetTMPText(self._mapNode.txt_MaxCombos, nMaxStreakCount)
self._mapNode.obj_MaScoreBg:SetActive(bShowMaxScore)
if bShowMaxScore then
NovaAPI.SetTMPText(self._mapNode.txt_MaxScore, nMaxScore)
end
end
function IceCreamTruckPauseCtrl:OnBtnClick_Exit()
EventManager.Hit("IceCream_Exit_OnClick")
end
function IceCreamTruckPauseCtrl:OnBtnClick_Restart()
EventManager.Hit("IceCream_Restart_OnClick")
end
function IceCreamTruckPauseCtrl:OnBtnClick_Continue()
EventManager.Hit("IceCream_Continue_OnClick")
end
function IceCreamTruckPauseCtrl:OnBtnClick_OpenDic()
if self.nDicId == 0 then
return
end
EventManager.Hit(EventId.OpenPanel, PanelId.DictionaryEntry, self.nDicId, false)
end
return IceCreamTruckPauseCtrl
@@ -0,0 +1,81 @@
local IceCreamUtils = {}
IceCreamUtils.EnumConeType = {Cone = 1, Cup = 2}
IceCreamUtils.EnumFlavor = {
Vanilla = 3,
Strawberry = 4,
Melon = 5,
Chocolate = 6
}
IceCreamUtils.EnumTopping = {
Cherry = 8,
Rainbow = 9,
Cookie = 10,
Cream = 11
}
IceCreamUtils.EnumSlotType = {
SLOT_CONE = 1,
SLOT_SCOOP1 = 2,
SLOT_SCOOP2 = 3,
SLOT_SCOOP3 = 4,
SLOT_SCOOP4 = 5,
SLOT_TOPPING = 6
}
IceCreamUtils.Cone_IconPath = {
[IceCreamUtils.EnumConeType.Cone] = "",
[IceCreamUtils.EnumConeType.Cup] = ""
}
IceCreamUtils.Flavor_IconPath = {
[IceCreamUtils.EnumFlavor.Vanilla] = "",
[IceCreamUtils.EnumFlavor.Strawberry] = "",
[IceCreamUtils.EnumFlavor.Chocolate] = "",
[IceCreamUtils.EnumFlavor.Melon] = ""
}
IceCreamUtils.Topping_IconPath = {
[IceCreamUtils.EnumTopping.Cream] = "",
[IceCreamUtils.EnumTopping.Cookie] = "",
[IceCreamUtils.EnumTopping.Rainbow] = "",
[IceCreamUtils.EnumTopping.Cherry] = ""
}
IceCreamUtils.EnumQueueType = {InQueue = 1, InMake = 2}
IceCreamUtils.EnumCustomerState = {
idle = "idle",
walk = "walk",
happy_walk = "walk_happy",
happy = "happy",
sad = "sad",
angry_walk = "walk_angry",
angry = "angry"
}
IceCreamUtils.EnumOrderState = {
Null = 0,
Normal = 1,
Perfect = 2,
Lose = 3
}
function IceCreamUtils.InitIconPath()
local forEachLine_IceCreamCreate = function(mapLineData)
if mapLineData.OptionType == GameEnum.iceOption.Cone then
IceCreamUtils.Cone_IconPath[mapLineData.LocalParm] = mapLineData.Path
elseif mapLineData.OptionType == GameEnum.iceOption.IceBall then
IceCreamUtils.Flavor_IconPath[mapLineData.LocalParm] = mapLineData.Path
elseif mapLineData.OptionType == GameEnum.iceOption.Topping then
IceCreamUtils.Topping_IconPath[mapLineData.LocalParm] = mapLineData.Path
end
end
ForEachTableLine(DataTable.IceCreamCreate, forEachLine_IceCreamCreate)
end
function IceCreamUtils.SetCondimentIcon(step, v)
local IconPath = ""
if step < IceCreamUtils.EnumSlotType.SLOT_CONE or step > IceCreamUtils.EnumSlotType.SLOT_TOPPING then
return IconPath
end
if step == IceCreamUtils.EnumSlotType.SLOT_CONE then
IconPath = IceCreamUtils.Cone_IconPath[v]
elseif step == IceCreamUtils.EnumSlotType.SLOT_TOPPING then
IconPath = IceCreamUtils.Topping_IconPath[v]
else
IconPath = IceCreamUtils.Flavor_IconPath[v]
end
return IconPath
end
return IceCreamUtils
@@ -0,0 +1,171 @@
local ScoreCalculationCtrl = class("ScoreCalculationCtrl")
function ScoreCalculationCtrl:Init(nMaxFever, bInFeverMode, fFeverDuration)
self.nCombo = 0
self.tbComboLevels = {}
self.nMaxFever = nMaxFever
self.nFeverValue = 0
self.bInFeverMode = bInFeverMode
self.fFeverDuration = fFeverDuration or 10
self.fFeverTimer = 0
self.fMistakePenalty = 2
self.fBuffMultiplier = 1
self:_InitComboTable()
end
function ScoreCalculationCtrl:_InitComboTable()
self.tbComboLevels = {}
local forEachLine = function(mapLineData)
local sCombo = tostring(mapLineData.Combo)
local nMin = tonumber(string.match(sCombo, "^(%d+)"))
if nMin then
table.insert(self.tbComboLevels, {
minCombo = nMin,
magnification = mapLineData.Magnification or 1
})
end
end
ForEachTableLine(DataTable.IceCreamFever, forEachLine)
table.sort(self.tbComboLevels, function(a, b)
return a.minCombo < b.minCombo
end)
end
function ScoreCalculationCtrl:GetComboMultiplier()
local fMul = 1
for _, level in ipairs(self.tbComboLevels) do
if self.nCombo >= level.minCombo then
fMul = level.magnification
else
break
end
end
return fMul
end
function ScoreCalculationCtrl:HasFever()
return self.nMaxFever > 0
end
function ScoreCalculationCtrl:IsInFeverMode()
return self.bInFeverMode
end
function ScoreCalculationCtrl:GetFeverPercent()
if not self:HasFever() then
return 0
end
if 0 >= self.nMaxFever then
self.nMaxFever = 0 < self.nFeverValue and self.nFeverValue or 1
end
if self.nFeverValue > self.nMaxFever then
self.nFeverValue = self.nMaxFever
end
return self.nFeverValue / self.nMaxFever
end
function ScoreCalculationCtrl:TryEnterFeverMode()
if not self:HasFever() then
return false
end
if self.bInFeverMode then
return false
end
if self.nFeverValue < self.nMaxFever then
return false
end
self.bInFeverMode = true
self.fFeverTimer = 0
return true
end
function ScoreCalculationCtrl:UpdateFeverDecay(dt)
if not self.bInFeverMode then
return false
end
self.fFeverTimer = self.fFeverTimer + dt
local fRemain = 1 - self.fFeverTimer / self.fFeverDuration
if fRemain <= 0 then
self:EndFeverMode()
return false
end
self.nFeverValue = math.floor(self.nMaxFever * fRemain)
return true
end
function ScoreCalculationCtrl:OnFeverMistake()
if not self.bInFeverMode then
return
end
self.fFeverTimer = self.fFeverTimer + self.fMistakePenalty
local fRemain = 1 - self.fFeverTimer / self.fFeverDuration
if fRemain < 0 then
fRemain = 0
end
self.nFeverValue = math.floor(self.nMaxFever * fRemain)
end
function ScoreCalculationCtrl:EndFeverMode()
self.bInFeverMode = false
self.nFeverValue = 0
self.fFeverTimer = 0
end
function ScoreCalculationCtrl:OnOrderSuccess(bIsSpecial)
self.nCombo = self.nCombo + 1
local bJustEnteredFever = false
if self:HasFever() and not self.bInFeverMode then
local nAdd = bIsSpecial and 20 or 10
self.nFeverValue = math.min(self.nMaxFever, self.nFeverValue + nAdd)
bJustEnteredFever = self:TryEnterFeverMode()
end
return bJustEnteredFever
end
function ScoreCalculationCtrl:OnMistake()
if self.bInFeverMode then
self:OnFeverMistake()
else
self.nCombo = 0
if self:HasFever() then
self.nFeverValue = math.max(0, self.nFeverValue - 10)
end
end
end
function ScoreCalculationCtrl:OnOrderFail()
if self.bInFeverMode then
self:OnFeverMistake()
else
self.nCombo = 0
if self:HasFever() then
self.nFeverValue = 0
end
end
end
function ScoreCalculationCtrl:SetBuffMultiplier(fMul)
self.fBuffMultiplier = fMul or 1
end
function ScoreCalculationCtrl:GetBuffMultiplier()
return self.fBuffMultiplier
end
function ScoreCalculationCtrl:CalcOrderScore(nBaseScore)
local fComboMul = self:GetComboMultiplier()
local fBuffMul = self.fBuffMultiplier
local fFeverMul = self.bInFeverMode and 2 or 1
local nFinal = math.floor(nBaseScore * fComboMul * fBuffMul * fFeverMul)
local tbDetail = {
nBase = nBaseScore,
fComboMul = fComboMul,
fBuffMul = fBuffMul,
fFeverMul = fFeverMul,
nFinal = nFinal
}
return nFinal, tbDetail
end
function ScoreCalculationCtrl:GetCombo()
return self.nCombo
end
function ScoreCalculationCtrl:GetFeverValue()
return self.nFeverValue
end
function ScoreCalculationCtrl:GetMaxFever()
return self.nMaxFever
end
function ScoreCalculationCtrl:SetInFeverMode(bInFeverMode)
self.bInFeverMode = bInFeverMode
end
function ScoreCalculationCtrl:ChangeCombo(nComboNum)
self.nCombo = nComboNum
end
function ScoreCalculationCtrl:ChangeFeverTime(nFeverTime)
self.fFeverDuration = nFeverTime
end
return ScoreCalculationCtrl