diff --git a/Assets/ManagedResources/~Lua/Modules/Map/TrialMiniGame/Logic/Game_17.lua b/Assets/ManagedResources/~Lua/Modules/Map/TrialMiniGame/Logic/Game_17.lua index 590e321317..5f737a6f53 100644 --- a/Assets/ManagedResources/~Lua/Modules/Map/TrialMiniGame/Logic/Game_17.lua +++ b/Assets/ManagedResources/~Lua/Modules/Map/TrialMiniGame/Logic/Game_17.lua @@ -31,6 +31,10 @@ end local id local num +local itemId +local isStart +local timeSpace = 0 +local lastTime = 0 function this.Show() this.root:SetActive(true) this.liveNode = poolManager:LoadLive("live2d_c_yj_00040", this.liveRoot.transform, Vector3.one, Vector3.New(-6,62, 0)) @@ -60,7 +64,7 @@ function this.Show() id = msg.drop.itemlist[1].itemId num = msg.drop.itemlist[1].itemNum LogYellow("掉落的Id:"..id.." 数量:"..num) - this.test(msg.drop.itemlist[1].itemId) + this.test() --4秒后显示掉落 -- Timer.New(function() -- if TrialMiniGameManager.IsGameDone() then @@ -71,73 +75,65 @@ function this.Show() -- end, 20,1,true):Start() end) end) + + UpdateBeat:Add(this.Update, this) end + +function this.Update() + if isStart then + if Time.realtimeSinceStartup - lastTime >= timeSpace then + lastTime = Time.realtimeSinceStartup + this.tableTurnEffect() + end + end +end + --加减速 -function this.test(itemId) - local t =1 +function this.test() + timeSpace = 0 + lastTime = Time.realtimeSinceStartup + local thread=coroutine.start(function() - --加速阶段 - if this.turnEffect2 then - this.turnEffect2:Stop() - this.turnEffect2 = nil + -- 加速 + -- for i = 0, 10 do + -- timeSpace = timeSpace - 0.1 + -- coroutine.wait(0.1) + -- end + -- 减速 + for i = 0, 30 do + timeSpace = timeSpace + 0.01 + coroutine.wait(0.1) end - if not this.turnEffect2 then - this.turnEffect2 = Timer.New(function() - this.tableTurnEffect(1/t) - t=t+5 - end,0.2,10,true) - this.turnEffect2:Start() - end - coroutine.wait(2) - --减速阶段 - if this.turnEffect2 then - this.turnEffect2:Stop() - this.turnEffect2 = nil - end - if not this.turnEffect2 then - this.turnEffect2 = Timer.New(function() - this.tableTurnEffect(1/t) - t=t-3.3 - end,0.2,10,true) - this.turnEffect2:Start() - end - coroutine.wait(2) - this.tableTurnEffect(0.4,itemId) + itemId = id end) + + isStart = true end --设置速度 local index = 1 -function this.tableTurnEffect(speed,itemId) - if this.turnEffect then - this.turnEffect:Stop() - this.turnEffect = nil +function this.tableTurnEffect() + local red = Util.GetGameObject(this.itemsList[index],"Red") + red:SetActive(false) + if index == 12 then--t归零 + index = 0 end - if not this.turnEffect then - this.turnEffect = Timer.New(function() - local red = Util.GetGameObject(this.itemsList[index],"Red") - red:SetActive(false) - if index == 12 then--t归零 - index = 0 + local redNext = Util.GetGameObject(this.itemsList[index+1],"Red") + redNext:SetActive(true) + index = index + 1 + --检测最后的奖励 + if itemId and id == this.TrialGameConfig[this.list[index]].RewardID and num == this.TrialGameConfig[this.list[index]].Max then + -- this.turnEffect:Stop() + --游戏结束显示掉落 + Timer.New(function() + if TrialMiniGameManager.IsGameDone() then + TrialMiniGameManager.EndGame() end - local redNext = Util.GetGameObject(this.itemsList[index+1],"Red") - redNext:SetActive(true) - index = index + 1 - --检测最后的奖励 - if itemId and id == this.TrialGameConfig[this.list[index]].RewardID and num == this.TrialGameConfig[this.list[index]].Max then - this.turnEffect:Stop() - --游戏结束显示掉落 - Timer.New(function() - if TrialMiniGameManager.IsGameDone() then - TrialMiniGameManager.EndGame() - end - local data = TrialMiniGameManager.IdToNameIconNum(id,num) - PopupTipPanel.ShowColorTip(data[1],data[2],data[3]) - end, 1,1,true):Start() - - end - end,speed,-1,true) - this.turnEffect:Start() + local data = TrialMiniGameManager.IdToNameIconNum(id,num) + PopupTipPanel.ShowColorTip(data[1],data[2],data[3]) + isStart = true + itemId = nil + end, 1,1,true):Start() end end @@ -149,14 +145,7 @@ function this.Close() end poolManager:UnLoadLive("live2d_c_yj_00040", this.liveNode) index = 1 - if this.turnEffect2 then - this.turnEffect2:Stop() - this.turnEffect2 = nil - end - if this.turnEffect then - this.turnEffect:Stop() - this.turnEffect = nil - end + UpdateBeat:Remove(this.Update, this) end function this.Destroy()