整理玩家update代码,添加垃圾行缓冲条总数警告
This commit is contained in:
@@ -271,6 +271,16 @@ local function drawBuffer(P)
|
||||
end
|
||||
h=h+bar
|
||||
end
|
||||
local sum=P.atkBufferSum1
|
||||
if sum>=8 then
|
||||
gc_push('transform')
|
||||
gc_translate(300,max(0,600-30*sum))
|
||||
gc_scale(min(.2+sum/50,1))
|
||||
setFont(100)
|
||||
gc_setColor(1,.2+min(sum*.02,.8)*(.5+.5*sin(TIME()*min(sum,32))),.2,min(sum/30,.8))
|
||||
gc_printf(int(P.atkBufferSum1),-300,-20,292,'right')
|
||||
gc_pop()
|
||||
end
|
||||
end
|
||||
local function drawB2Bbar(P)
|
||||
local a,b=P.b2b,P.b2b1 if a>b then a,b=b,a end
|
||||
|
||||
@@ -129,6 +129,7 @@ local function newEmptyPlayer(id,mini)
|
||||
P.field,P.visTime={},{}
|
||||
P.atkBuffer={}
|
||||
P.atkBufferSum=0
|
||||
P.atkBufferSum1=0
|
||||
|
||||
--Royale-related
|
||||
P.badge,P.strength=0,0
|
||||
|
||||
@@ -391,6 +391,16 @@ function Player:receive(A,send,time,line)
|
||||
end
|
||||
end
|
||||
end
|
||||
function Player:clearAttackBuffer()
|
||||
for i=1,#self.atkBuffer do
|
||||
local A=self.atkBuffer[i]
|
||||
if not A.sent then
|
||||
A.sent=true
|
||||
A.time=0
|
||||
end
|
||||
end
|
||||
self.atkBufferSum=0
|
||||
end
|
||||
function Player:freshTarget()
|
||||
if self.atkMode==1 then
|
||||
if not self.atking or not self.atking.alive or rnd()<.1 then
|
||||
@@ -1620,10 +1630,7 @@ function Player:die()--Called both when win/lose!
|
||||
self.waiting=1e99
|
||||
self.b2b=0
|
||||
self.tasks={}
|
||||
for i=1,#self.atkBuffer do
|
||||
self.atkBuffer[i].sent=true
|
||||
self.atkBuffer[i].time=0
|
||||
end
|
||||
self:clearAttackBuffer()
|
||||
for i=1,#self.field do
|
||||
for j=1,10 do
|
||||
self.visTime[i][j]=min(self.visTime[i][j],20)
|
||||
@@ -1640,6 +1647,36 @@ function Player:die()--Called both when win/lose!
|
||||
end
|
||||
end
|
||||
end
|
||||
function Player:revive()
|
||||
self.waiting=62
|
||||
local h=#self.field
|
||||
for _=h,1,-1 do
|
||||
FREEROW.discard(self.field[_])
|
||||
FREEROW.discard(self.visTime[_])
|
||||
self.field[_],self.visTime[_]=nil
|
||||
end
|
||||
self.garbageBeneath=0
|
||||
if self.AI_mode=='CC'then
|
||||
CC.destroy(self.AI_bot)
|
||||
TABLE.cut(self.holdQueue)
|
||||
self:loadAI(self.AIdata)
|
||||
end
|
||||
|
||||
self:clearAttackBuffer()
|
||||
|
||||
self.life=self.life-1
|
||||
self.fieldBeneath=0
|
||||
self.b2b=0
|
||||
|
||||
for i=1,h do
|
||||
self:createClearingFX(i,1.5)
|
||||
end
|
||||
SYSFX.newShade(1.4,self.fieldX,self.fieldY,300*self.size,610*self.size)
|
||||
SYSFX.newRectRipple(2,self.fieldX,self.fieldY,300*self.size,610*self.size)
|
||||
SYSFX.newRipple(2,self.x+(475+25*(self.life<3 and self.life or 0)+12)*self.size,self.y+(665+12)*self.size,20)
|
||||
SFX.play('clear_3')
|
||||
SFX.play('emit')
|
||||
end
|
||||
function Player:win(result)
|
||||
if self.result then return end
|
||||
self:die()
|
||||
@@ -1670,45 +1707,7 @@ end
|
||||
function Player:lose(force)
|
||||
if self.result then return end
|
||||
if self.type=='remote'and not force then self.waiting=1e99 return end
|
||||
if self.life>0 and not force then
|
||||
self.waiting=62
|
||||
local h=#self.field
|
||||
for _=h,1,-1 do
|
||||
FREEROW.discard(self.field[_])
|
||||
FREEROW.discard(self.visTime[_])
|
||||
self.field[_],self.visTime[_]=nil
|
||||
end
|
||||
self.garbageBeneath=0
|
||||
|
||||
if self.AI_mode=='CC'then
|
||||
CC.destroy(self.AI_bot)
|
||||
TABLE.cut(self.holdQueue)
|
||||
self:loadAI(self.AIdata)
|
||||
end
|
||||
|
||||
self.life=self.life-1
|
||||
self.fieldBeneath=0
|
||||
self.b2b=0
|
||||
for i=1,#self.atkBuffer do
|
||||
local A=self.atkBuffer[i]
|
||||
if not A.sent then
|
||||
A.sent=true
|
||||
A.time=0
|
||||
end
|
||||
end
|
||||
self.atkBufferSum=0
|
||||
|
||||
for i=1,h do
|
||||
self:createClearingFX(i,1.5)
|
||||
end
|
||||
SYSFX.newShade(1.4,self.fieldX,self.fieldY,300*self.size,610*self.size)
|
||||
SYSFX.newRectRipple(2,self.fieldX,self.fieldY,300*self.size,610*self.size)
|
||||
SYSFX.newRipple(2,self.x+(475+25*(self.life<3 and self.life or 0)+12)*self.size,self.y+(665+12)*self.size,20)
|
||||
SFX.play('clear_3')
|
||||
SFX.play('emit')
|
||||
|
||||
return
|
||||
end
|
||||
if self.life>0 and not force then self:revive()return end
|
||||
self:die()
|
||||
local i=TABLE.find(PLY_ALIVE,self)
|
||||
if i then rem(PLY_ALIVE,i)end
|
||||
|
||||
@@ -4,10 +4,23 @@ local rem=table.remove
|
||||
local assert,resume,status=assert,coroutine.resume,coroutine.status
|
||||
|
||||
local TEXT,GAME=TEXT,GAME
|
||||
local PLAYERS,PLY_ALIVE=PLAYERS,PLY_ALIVE
|
||||
local PLY_ALIVE=PLY_ALIVE
|
||||
|
||||
local function update_misc(P,dt)
|
||||
--Finesse combo animation
|
||||
if P.finesseComboTime>0 then
|
||||
P.finesseComboTime=P.finesseComboTime-1
|
||||
end
|
||||
|
||||
local function updateLine(P)--Attacks, line pushing, camear moving
|
||||
--Update atkBuffer alert
|
||||
local t=P.atkBufferSum1
|
||||
if t<P.atkBufferSum then
|
||||
P.atkBufferSum1=t+.25
|
||||
elseif t>P.atkBufferSum then
|
||||
P.atkBufferSum1=t-.5
|
||||
end
|
||||
|
||||
--Update attack buffer
|
||||
local bf=P.atkBuffer
|
||||
for i=#bf,1,-1 do
|
||||
local A=bf[i]
|
||||
@@ -23,24 +36,26 @@ local function updateLine(P)--Attacks, line pushing, camear moving
|
||||
end
|
||||
end
|
||||
|
||||
--Push up garbages
|
||||
local y=P.fieldBeneath
|
||||
if y>0 then
|
||||
P.fieldBeneath=max(y-P.gameEnv.pushSpeed,0)
|
||||
end
|
||||
|
||||
--Move camera
|
||||
if P.gameEnv.highCam then
|
||||
local f=P.fieldUp
|
||||
if not P.alive then
|
||||
y=0
|
||||
else
|
||||
y=30*max(min(#P.field-18.5-P.fieldBeneath/30,P.ghoY-17),0)
|
||||
end
|
||||
local f=P.fieldUp
|
||||
if f~=y then
|
||||
P.fieldUp=f>y and max(f*.95+y*.05-2,y)or min(f*.97+y*.03+1,y)
|
||||
end
|
||||
end
|
||||
end
|
||||
local function updateFXs(P,dt)
|
||||
|
||||
--Update Score
|
||||
if P.stat.score>P.score1 then
|
||||
if P.stat.score-P.score1<10 then
|
||||
P.score1=P.score1+1
|
||||
@@ -49,7 +64,7 @@ local function updateFXs(P,dt)
|
||||
end
|
||||
end
|
||||
|
||||
--LockFX
|
||||
--Update lock FX
|
||||
for i=#P.lockFX,1,-1 do
|
||||
local S=P.lockFX[i]
|
||||
S[3]=S[3]+S[4]*dt
|
||||
@@ -58,7 +73,7 @@ local function updateFXs(P,dt)
|
||||
end
|
||||
end
|
||||
|
||||
--DropFX
|
||||
--Update drop FX
|
||||
for i=#P.dropFX,1,-1 do
|
||||
local S=P.dropFX[i]
|
||||
S[5]=S[5]+S[6]*dt
|
||||
@@ -67,7 +82,7 @@ local function updateFXs(P,dt)
|
||||
end
|
||||
end
|
||||
|
||||
--MoveFX
|
||||
--Update move FX
|
||||
for i=#P.moveFX,1,-1 do
|
||||
local S=P.moveFX[i]
|
||||
S[4]=S[4]+S[5]*dt
|
||||
@@ -76,7 +91,7 @@ local function updateFXs(P,dt)
|
||||
end
|
||||
end
|
||||
|
||||
--ClearFX
|
||||
--Update clear FX
|
||||
for i=#P.clearFX,1,-1 do
|
||||
local S=P.clearFX[i]
|
||||
S[2]=S[2]+S[3]*dt
|
||||
@@ -99,11 +114,12 @@ local function updateFXs(P,dt)
|
||||
-- if abs(O.a)<.3 then O.a,O.va=0,0 end
|
||||
end
|
||||
|
||||
--Update texts
|
||||
if P.bonus then
|
||||
TEXT.update(P.bonus)
|
||||
end
|
||||
end
|
||||
local function updateTasks(P)
|
||||
|
||||
--Update tasks
|
||||
local L=P.tasks
|
||||
for i=#L,1,-1 do
|
||||
local tr=L[i].thread
|
||||
@@ -356,15 +372,8 @@ function update.alive(P,dt)
|
||||
P.b2b1=max(P.b2b1*.95+P.b2b*.05-.6,P.b2b)
|
||||
end
|
||||
|
||||
--Finesse combo animation
|
||||
if P.finesseComboTime>0 then
|
||||
P.finesseComboTime=P.finesseComboTime-1
|
||||
end
|
||||
|
||||
--Update FXs
|
||||
updateLine(P)
|
||||
updateFXs(P,dt)
|
||||
updateTasks(P)
|
||||
--Others
|
||||
update_misc(P,dt)
|
||||
-- P:setPosition(640-150-(30*(P.curX+P.cur.sc[2])-15),30*(P.curY+P.cur.sc[1])+15-300+(ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0))
|
||||
end
|
||||
function update.dead(P,dt)
|
||||
@@ -389,12 +398,7 @@ function update.dead(P,dt)
|
||||
if P.b2b1>0 then
|
||||
P.b2b1=max(0,P.b2b1*.92-1)
|
||||
end
|
||||
if P.finesseComboTime>0 then
|
||||
P.finesseComboTime=P.finesseComboTime-1
|
||||
end
|
||||
updateLine(P)
|
||||
updateFXs(P,dt)
|
||||
updateTasks(P)
|
||||
update_misc(P,dt)
|
||||
end
|
||||
function update.remote_alive(P,dt)
|
||||
local frameRate=(P.stream[#P.stream-1]or 0)-P.frameRun
|
||||
|
||||
Reference in New Issue
Block a user