简化resetGameData函数
This commit is contained in:
@@ -439,26 +439,33 @@ function loadGame(M,ifQuickPlay)
|
|||||||
SCN.swapTo("play",ifQuickPlay and"swipeD"or"fade_togame")
|
SCN.swapTo("play",ifQuickPlay and"swipeD"or"fade_togame")
|
||||||
SFX.play("enter")
|
SFX.play("enter")
|
||||||
end
|
end
|
||||||
function resetGameData()
|
function resetGameData(replaying)
|
||||||
if PLAYERS[1]and not GAME.replaying then
|
if PLAYERS[1]and not GAME.replaying then
|
||||||
mergeStat(STAT,PLAYERS[1].stat)
|
mergeStat(STAT,PLAYERS[1].stat)
|
||||||
end
|
end
|
||||||
|
|
||||||
GAME.frame=150-SETTING.reTime*15
|
|
||||||
GAME.result=false
|
GAME.result=false
|
||||||
GAME.pauseTime=0
|
|
||||||
GAME.pauseCount=0
|
|
||||||
GAME.garbageSpeed=1
|
GAME.garbageSpeed=1
|
||||||
GAME.warnLVL0=0
|
GAME.warnLVL0=0
|
||||||
GAME.warnLVL=0
|
GAME.warnLVL=0
|
||||||
GAME.recording=true
|
if replaying then
|
||||||
GAME.replaying=false
|
GAME.frame=0
|
||||||
GAME.setting=copyGameSetting()
|
GAME.recording=false
|
||||||
GAME.rec={}
|
GAME.replaying=1
|
||||||
GAME.rank=0
|
else
|
||||||
math.randomseed(tm.getTime())
|
GAME.frame=150-SETTING.reTime*15
|
||||||
GAME.seed=rnd(261046101471026)
|
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()
|
destroyPlayers()
|
||||||
restoreVirtualKey()
|
restoreVirtualKey()
|
||||||
GAME.curMode.load()
|
GAME.curMode.load()
|
||||||
@@ -488,59 +495,6 @@ function resetGameData()
|
|||||||
SFX.play("ready")
|
SFX.play("ready")
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
end
|
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()
|
function gameStart()
|
||||||
SFX.play("start")
|
SFX.play("start")
|
||||||
for P=1,#PLAYERS do
|
for P=1,#PLAYERS do
|
||||||
|
|||||||
@@ -1664,7 +1664,7 @@ function Player.act_func(P)
|
|||||||
end
|
end
|
||||||
function Player.act_restart()
|
function Player.act_restart()
|
||||||
if GAME.frame<240 or GAME.result then
|
if GAME.frame<240 or GAME.result then
|
||||||
resetPartGameData()
|
resetGameData()
|
||||||
else
|
else
|
||||||
LOG.print(text.holdR,20,COLOR.orange)
|
LOG.print(text.holdR,20,COLOR.orange)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ function keyDown.pause(key)
|
|||||||
resetGameData()
|
resetGameData()
|
||||||
SCN.swapTo("play","none")
|
SCN.swapTo("play","none")
|
||||||
elseif key=="p"and(GAME.result or GAME.replaying)and #PLAYERS==1 then
|
elseif key=="p"and(GAME.result or GAME.replaying)and #PLAYERS==1 then
|
||||||
resetPartGameData(true)
|
resetGameData(true)
|
||||||
SCN.swapTo("play","none")
|
SCN.swapTo("play","none")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ function Tmr.play(dt)
|
|||||||
elseif P1.keyPressing[10]then
|
elseif P1.keyPressing[10]then
|
||||||
restartCount=restartCount+1
|
restartCount=restartCount+1
|
||||||
if restartCount>20 then
|
if restartCount>20 then
|
||||||
resetPartGameData()
|
resetGameData()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
elseif restartCount>0 then
|
elseif restartCount>0 then
|
||||||
|
|||||||
Reference in New Issue
Block a user