全局变量MODEENV移入全局变量GAME中,重构虚拟按键显示情况代码

This commit is contained in:
MrZ626
2020-11-19 22:45:10 +08:00
parent 1c31015fa8
commit f216e2d6e5
10 changed files with 73 additions and 63 deletions

View File

@@ -455,7 +455,7 @@ function draw.norm(P)
P:drawNext()
--Draw target selecting pad
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
if P.atkMode then
gc.setColor(1,.8,0,P.swappingAtkMode*.02)
gc.rectangle("fill",RCPB[2*P.atkMode-1],RCPB[2*P.atkMode],90,35,8,4)
@@ -606,7 +606,7 @@ function draw.small(P)
end
--Draw badge
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
gc.setColor(1,1,1)
for i=1,P.strength do
gc.draw(IMG.badgeIcon,12*i-7,4,nil,.5)
@@ -673,7 +673,7 @@ function draw.demo(P)
_=P.color[id]
gc.setColor(_[1],_[2],_[3],.3)
_=blockImg[id]
gc.draw(_,15,40*N-10,nil,16,nil,_:getWidth(),_:getHeight()*.5)
gc.draw(_,15,40*N-10,nil,16,nil,0,_:getHeight()*.5)
N=N+1
end

View File

@@ -196,8 +196,8 @@ local function loadGameEnv(P)--Load gameEnv
local SETTING=SETTING
--Load game settings
for k,v in next,gameEnv0 do
if MODEENV[k]~=nil then
v=MODEENV[k] --Mode setting
if GAME.modeEnv[k]~=nil then
v=GAME.modeEnv[k] --Mode setting
-- DBP("mode-"..k..":"..tostring(v))
elseif GAME.setting[k]~=nil then
v=GAME.setting[k] --Game setting
@@ -235,13 +235,11 @@ local function applyGameEnv(P)--Finish gameEnv processing
for i=11,20 do
if i~=14 then
P.keyAvailable[i]=false
virtualkey[i].ava=false
end
end
end
for _,v in next,ENV.keyCancel do
P.keyAvailable[v]=false
virtualkey[v].ava=false
end
P:setInvisible(
ENV.visible=="show"and -1 or
@@ -294,6 +292,13 @@ function PLY.check_attackReach(P)
end
end
local DemoEnv={
das=10,arr=2,sddas=2,sdarr=2,
drop=1e99,lock=1e99,
wait=10,fall=20,
highCam=false,
life=1e99,
}
function PLY.newDemoPlayer(id,x,y,size)
local P=newEmptyPlayer(id,x,y,size)
P.sound=true
@@ -305,19 +310,14 @@ function PLY.newDemoPlayer(id,x,y,size)
P.absFieldY=P.y+60*P.size
P.draw=PLY.draw.demo
P.control=true
P.gameEnv={
das=10,arr=2,sddas=2,sdarr=2,
drop=1e99,lock=1e99,
wait=10,fall=20,
life=1e99,
}
GAME.modeEnv=DemoEnv
loadGameEnv(P)
applyGameEnv(P)
prepareSequence(P)
P:loadAI({
type="CC",
nextCount=5,
hold=true,
holdCount=true,
delay=30,
delta=6,
bag="bag",

View File

@@ -96,7 +96,7 @@ function Player.createBeam(P,R,send,color)
local r,g,b=unpack(SKIN.libColor[color])
r,g,b=r*2,g*2,b*2
local a=MODEENV.royaleMode and not(P.human or R.human)and .2 or 1
local a=GAME.modeEnv.royaleMode and not(P.human or R.human)and .2 or 1
SYSFX.newAttack(1-SETTING.atkFX*.1,x1,y1,x2,y2,wid,r,g,b,a*(SETTING.atkFX+2)*.0626)
end
--------------------------</FX>--------------------------
@@ -117,7 +117,9 @@ end
function Player.set20G(P,if20g,init)--Only set init=true when initialize CC, do not use it
P._20G=if20g
P.keyAvailable[7]=not if20g
virtualkey[7].ava=not if20g
if P.human then
virtualkey[7].ava=not if20g
end
if init and if20g and P.AI_mode=="CC"then CC.switch20G(P)end
end
function Player.setHold(P,count)--Set hold count (false/true as 0/1)
@@ -128,8 +130,9 @@ function Player.setHold(P,count)--Set hold count (false/true as 0/1)
end
P.gameEnv.holdCount=count
P.holdTime=count
P.keyAvailable[8]=count>0
virtualkey[8].ava=count>0
if P.human then
virtualkey[8].ava=count>0
end
if count==0 then
P.drawHold=NULL
while P.holdQueue[1]do rem(P.holdQueue)end
@@ -1107,7 +1110,7 @@ do--Player.drop(P)--Place piece
if P.b2b>1200 then P.b2b=1200 end
--Bonus atk/def when focused
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
local i=min(#P.atker,9)
if i>1 then
atk=atk+reAtk[i]
@@ -1132,7 +1135,7 @@ do--Player.drop(P)--Place piece
off=off+_
if send>0 then
local T
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
if P.atkMode==4 then
local M=#P.atker
if M>0 then
@@ -1399,7 +1402,7 @@ function Player.win(P,result)
if P.result then return end
P:die()
P.result="WIN"
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
P.modeData.event=1
P:changeAtk()
end
@@ -1407,7 +1410,7 @@ function Player.win(P,result)
GAME.result=result or"win"
SFX.play("win")
VOC.play("win")
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
BGM.play("8-bit happiness")
end
end
@@ -1474,7 +1477,7 @@ function Player.lose(P,force)
end
end
P.result="K.O."
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
P:changeAtk()
P.modeData.event=#PLAYERS.alive+1
P.strength=0
@@ -1516,7 +1519,7 @@ function Player.lose(P,force)
GAME.result="gameover"
SFX.play("fail")
VOC.play("lose")
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
if P.modeData.event==2 then
BGM.play("hay what kind of feeling")
else

View File

@@ -113,7 +113,7 @@ function update.alive(P,dt)
for i=2,10 do v=v+i*(i-1)*7.2/(_-P.dropTime[i])end
P.dropSpeed=P.dropSpeed*.99+v*.1
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
if P.keyPressing[9]then
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
else
@@ -313,7 +313,7 @@ function update.dead(P,dt)
P.keySpeed=P.keySpeed*.96+P.stat.key/P.stat.time*60*.04
P.dropSpeed=P.dropSpeed*.96+P.stat.piece/P.stat.time*60*.04
--Final average speeds
if MODEENV.royaleMode then
if GAME.modeEnv.royaleMode then
P.swappingAtkMode=min(P.swappingAtkMode+2,30)
end
end