落块事件改名落块钩子

添加死亡钩子(仅在窒息和超高触发)
堆积模式消行动作挂到死亡钩子上
This commit is contained in:
MrZ626
2021-11-13 05:20:32 +08:00
parent 8cbb4a38bc
commit bc5193f95e
7 changed files with 48 additions and 29 deletions

View File

@@ -313,10 +313,13 @@ function Player:setRS(RSname)
end
end
function Player:triggerDropEvents()
local L=self.gameEnv.hook_drop
for i=1,#L do
L[i](self)
function Player:_triggerEvent(eventName)
local L=self.gameEnv[eventName]
if L[1]then
for i=1,#L do
L[i](self)
end
return true
end
end
@@ -378,9 +381,22 @@ function Player:garbageRise(color,amount,line)--Release n-lines garbage to field
_=self.dropFX[i]
_[3],_[5]=_[3]+amount,_[5]+amount
end
if #self.field>self.gameEnv.heightLimit then
if
#self.field>self.gameEnv.heightLimit and(
not self:_triggerEvent('hook_die')or
#self.field>self.gameEnv.heightLimit
)
then
self:lock()
self:lose()
end
if #self.field>self.gameEnv.heightLimit then
self:_triggerEvent('hook_die')
if #self.field>self.gameEnv.heightLimit then
self:lose()
end
end
end
local invList={2,1,4,3,5,6,7}
@@ -724,7 +740,7 @@ function Player:removeTopClearingFX()
return true
end
end
function Player:checkMission(piece,mission)
function Player:_checkMission(piece,mission)
if mission<5 then
return piece.row==mission and not piece.spin
elseif mission<9 then
@@ -736,6 +752,17 @@ function Player:checkMission(piece,mission)
end
return false
end
function Player:_checkSuffocate()
if
self:ifoverlap(self.cur.bk,self.curX,self.curY)and(
not self:_triggerEvent('hook_die')or
self:ifoverlap(self.cur.bk,self.curX,self.curY)
)
then
self:lock()
self:lose()
end
end
local spawnSFX_name={'spawn_1','spawn_2','spawn_3','spawn_4','spawn_5','spawn_6','spawn_7'}
function Player:resetBlock()--Reset Block's position and execute I*S
@@ -905,10 +932,7 @@ function Player:hold_norm(ifpre)
self:freshBlock('move')
self.dropDelay=ENV.drop
self.lockDelay=ENV.lock
if self:ifoverlap(self.cur.bk,self.curX,self.curY)then
self:lock()
self:lose()
end
self:_checkSuffocate()
end
self.freshTime=int(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount),ENV.freshLimit))
@@ -971,10 +995,7 @@ function Player:hold_swap(ifpre)
self:freshBlock('move')
self.dropDelay=ENV.drop
self.lockDelay=ENV.lock
if self:ifoverlap(self.cur.bk,self.curX,self.curY)then
self:lock()
self:lose()
end
self:_checkSuffocate()
end
self.freshTime=int(min(self.freshTime+ENV.freshLimit*.25,ENV.freshLimit*((self.holdTime+1)/ENV.holdCount),ENV.freshLimit))
@@ -1044,10 +1065,7 @@ function Player:popNext(ifhold)--Pop nextQueue to hand
self.freshTime=ENV.freshLimit
if self.cur then
if self:ifoverlap(self.cur.bk,self.curX,self.curY)then
self:lock()
self:lose()
end
self:_checkSuffocate()
self:freshBlock('newBlock')
end
@@ -1608,7 +1626,7 @@ do
--Check clearing task
if cc>0 and self.curMission then
if self:checkMission(piece,ENV.mission[self.curMission])then
if self:_checkMission(piece,ENV.mission[self.curMission])then
self.curMission=self.curMission+1
SFX.play('reach')
if self.curMission>#ENV.mission then
@@ -1670,13 +1688,13 @@ do
if finish=='lose'then
self:lose()
else
self:triggerDropEvents()
self:_triggerEvent('hook_drop')
if finish then
self:win(finish)
end
end
else
self:triggerDropEvents()
self:_triggerEvent('hook_drop')
end
end