From 0456bf515e404143a9e442861a10f6e4aa221f01 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 20 Nov 2020 00:43:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96resetGameData=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 82 +++++++++-------------------------------- parts/player/player.lua | 2 +- parts/scenes/pause.lua | 2 +- parts/scenes/play.lua | 2 +- 4 files changed, 21 insertions(+), 67 deletions(-) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 7faf1b6b..edf73a07 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -439,26 +439,33 @@ function loadGame(M,ifQuickPlay) SCN.swapTo("play",ifQuickPlay and"swipeD"or"fade_togame") SFX.play("enter") end -function resetGameData() +function resetGameData(replaying) if PLAYERS[1]and not GAME.replaying then mergeStat(STAT,PLAYERS[1].stat) end - GAME.frame=150-SETTING.reTime*15 GAME.result=false - GAME.pauseTime=0 - GAME.pauseCount=0 GAME.garbageSpeed=1 GAME.warnLVL0=0 GAME.warnLVL=0 - GAME.recording=true - GAME.replaying=false - GAME.setting=copyGameSetting() - GAME.rec={} - GAME.rank=0 - math.randomseed(tm.getTime()) - GAME.seed=rnd(261046101471026) + if replaying then + GAME.frame=0 + GAME.recording=false + GAME.replaying=1 + else + GAME.frame=150-SETTING.reTime*15 + GAME.pauseTime=0 + GAME.pauseCount=0 + GAME.recording=true + GAME.replaying=false + GAME.setting=copyGameSetting() + GAME.rec={} + GAME.rank=0 + math.randomseed(tm.getTime()) + GAME.seed=rnd(1046101471,2662622626) + end + TASK.removeTask_code(TICK.autoPause) destroyPlayers() restoreVirtualKey() GAME.curMode.load() @@ -488,59 +495,6 @@ function resetGameData() SFX.play("ready") collectgarbage() end -function resetPartGameData(replaying) - TASK.removeTask_code(TICK.autoPause) - if PLAYERS[1]and not GAME.replaying then - mergeStat(STAT,PLAYERS[1].stat) - end - - GAME.result=false - GAME.garbageSpeed=1 - GAME.warnLVL0=0 - GAME.warnLVL=0 - if replaying then - GAME.frame=0 - GAME.recording=false - GAME.replaying=1 - else - GAME.frame=150-SETTING.reTime*15 - GAME.pauseTime=0 - GAME.pauseCount=0 - GAME.recording=true - GAME.replaying=false - GAME.setting=copyGameSetting() - GAME.rec={} - GAME.rank=0 - math.randomseed(tm.getTime()) - GAME.seed=rnd(1046101471,2662622626) - end - - destroyPlayers() - restoreVirtualKey() - GAME.curMode.load() - if GAME.modeEnv.task then - for i=1,#PLAYERS do - PLAYERS[i]:newTask(GAME.modeEnv.task) - end - end - BG.set(GAME.modeEnv.bg) - BGM.play(GAME.modeEnv.bgm) - - TEXT.clear() - if GAME.modeEnv.royaleMode then - for i=1,#PLAYERS do - PLAYERS[i]:changeAtk(randomTarget(PLAYERS[i])) - end - GAME.stage=nil - GAME.mostBadge=nil - GAME.secBadge=nil - GAME.mostDangerous=nil - GAME.secDangerous=nil - GAME.stage=1 - GAME.garbageSpeed=.3 - end - collectgarbage() -end function gameStart() SFX.play("start") for P=1,#PLAYERS do diff --git a/parts/player/player.lua b/parts/player/player.lua index c7ca4c00..c9be4886 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -1664,7 +1664,7 @@ function Player.act_func(P) end function Player.act_restart() if GAME.frame<240 or GAME.result then - resetPartGameData() + resetGameData() else LOG.print(text.holdR,20,COLOR.orange) end diff --git a/parts/scenes/pause.lua b/parts/scenes/pause.lua index 5a2b6f75..25502500 100644 --- a/parts/scenes/pause.lua +++ b/parts/scenes/pause.lua @@ -131,7 +131,7 @@ function keyDown.pause(key) resetGameData() SCN.swapTo("play","none") elseif key=="p"and(GAME.result or GAME.replaying)and #PLAYERS==1 then - resetPartGameData(true) + resetGameData(true) SCN.swapTo("play","none") end end diff --git a/parts/scenes/play.lua b/parts/scenes/play.lua index 80c3d725..b2840a18 100644 --- a/parts/scenes/play.lua +++ b/parts/scenes/play.lua @@ -202,7 +202,7 @@ function Tmr.play(dt) elseif P1.keyPressing[10]then restartCount=restartCount+1 if restartCount>20 then - resetPartGameData() + resetGameData() return end elseif restartCount>0 then