From b3610017608467e1387e5c4b53c256f57d516748 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Tue, 7 May 2024 00:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B0=94=E6=B3=A1=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E8=89=B2=E6=96=B9=E6=A1=88=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=87=A0=E5=A5=97=E9=BB=98=E8=AE=A4=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=88=B08=E4=B8=AA=E7=9A=84=E9=85=8D=E8=89=B2=E6=96=B9?= =?UTF-8?q?=E6=A1=88=EF=BC=88=E9=9A=8F=E6=9C=BA=E9=85=8D=E8=89=B2wip?= =?UTF-8?q?=EF=BC=89=20=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/game/basePlayer.lua | 12 +++ assets/game/classes.lua | 14 +-- assets/game/gemPlayer.lua | 16 +++- assets/game/mechanicLib/init.lua | 1 + assets/game/mechanicLib/mino/sequence.lua | 2 +- assets/game/mechanicLib/puyo/colorSet.lua | 28 ++++++ assets/game/mechanicLib/puyo/sequence.lua | 2 +- assets/game/minoPlayer.lua | 17 +++- assets/game/puyoPlayer.lua | 106 +++++++++++++--------- assets/game/rectField.lua | 3 + assets/game/rotsys_mino/trs.lua | 2 +- main.lua | 15 +++ 12 files changed, 163 insertions(+), 55 deletions(-) create mode 100644 assets/game/mechanicLib/puyo/colorSet.lua diff --git a/assets/game/basePlayer.lua b/assets/game/basePlayer.lua index 8990f1e3..fed13afe 100644 --- a/assets/game/basePlayer.lua +++ b/assets/game/basePlayer.lua @@ -10,11 +10,14 @@ local P={} -------------------------------------------------------------- -- Tools + function P:drawInfoPanel(x,y,w,h) return SKIN.get(self.settings.skin).drawInfoPanel(x,y,w,h) end + -------------------------------------------------------------- -- Effects + function P:shakeBoard(args,v) local shake=self.settings.shakeness local pos=self.pos @@ -116,11 +119,15 @@ function P:say(arg) a=arg.c and arg.c[4] or 1, } end + -------------------------------------------------------------- -- Game methods + +---Random Int function P:random(a,b) return self.RND:random(a,b) end +---Random Float function P:rand(a,b) return a+self.RND:random()*(b-a) end @@ -240,8 +247,10 @@ function P:finish(reason) self:playSound(reason=='AC' and 'win' or 'fail') end end + -------------------------------------------------------------- -- Press & Release & Update & Render + function P:pressKey(act) if self.settings.inputDelay<=0 then self:press(act) @@ -434,8 +443,10 @@ function P:update(dt) for _,v in next,self.particles do v:update(dt) end self.texts:update(dt) end + -------------------------------------------------------------- -- Builder + function P:addSoundEvent(name,F) assert(self.soundEvent[name],"Wrong soundEvent key: '"..tostring(name).."'") assert(type(F)=='function',"soundEvent must be function") @@ -827,6 +838,7 @@ end function P:unserialize_custom() -- Flandre kawaii end + -------------------------------------------------------------- return P diff --git a/assets/game/classes.lua b/assets/game/classes.lua index 0d573eac..a009c9da 100644 --- a/assets/game/classes.lua +++ b/assets/game/classes.lua @@ -63,9 +63,9 @@ ---|'drawOnPlayer' ---@alias Techmino.Mech.basic table ----@alias Techmino.Mech.mino table ----@alias Techmino.Mech.puyo table ----@alias Techmino.Mech.gem table +---@alias Techmino.Mech.mino table +---@alias Techmino.Mech.puyo table +---@alias Techmino.Mech.gem table ---@class Techmino.ParticleSystems ---@field rectShade love.ParticleSystem @@ -125,10 +125,10 @@ ---@field event table> ---@class Techmino.mino.clearRule ----@field getDelay fun(P:Techmino.Player.mino, lines:number[]): number? ----@field isFill fun(P:Techmino.Player.mino, y:number): boolean ----@field getFill fun(P:Techmino.Player.mino): number[]? ----@field clear fun(P:Techmino.Player.mino, lines:number[]) +---@field getDelay fun(P:Techmino.Player.Mino, lines:number[]): number? +---@field isFill fun(P:Techmino.Player.Mino, y:number): boolean +---@field getFill fun(P:Techmino.Player.Mino): number[]? +---@field clear fun(P:Techmino.Player.Mino, lines:number[]) ---@class Techmino.Game ---@field playing boolean diff --git a/assets/game/gemPlayer.lua b/assets/game/gemPlayer.lua index d1336f3a..b6e594b7 100644 --- a/assets/game/gemPlayer.lua +++ b/assets/game/gemPlayer.lua @@ -11,7 +11,7 @@ local max,min=math.max,math.min local floor=math.floor local ins,rem=table.insert,table.remove ----@class Techmino.Player.gem: Techmino.Player +---@class Techmino.Player.Gem: Techmino.Player ---@field field any[][] local GP=setmetatable({},{__index=require'basePlayer',__metatable=true}) @@ -47,6 +47,7 @@ local GP=setmetatable({},{__index=require'basePlayer',__metatable=true}) -------------------------------------------------------------- -- Function tables + local defaultSoundFunc={ countDown= countDownSound, move= function() FMOD.effect('move') end, @@ -71,17 +72,22 @@ local defaultSoundFunc={ win= function() FMOD.effect('win') end, fail= function() FMOD.effect('fail') end, } ----@type Map +---@type Map GP.scriptCmd={ } + -------------------------------------------------------------- -- Actions + GP._actions={} for k,v in next,mechLib.mino.actions do GP._actions[k]=GP:_getActionObj(v) end + -------------------------------------------------------------- -- Effects + -------------------------------------------------------------- -- Game methods + function GP:printField() -- For debugging local F=self.field print('----------') @@ -473,8 +479,10 @@ function GP:getScriptValue(arg) arg.d=='field_size' and self.settings.fieldSize or arg.d=='cell' and (self.field[arg.y][arg.x] and 1 or 0) end + -------------------------------------------------------------- -- Press & Release & Update & Render + function GP:getMousePos(x,y) local pos=self.pos x,y=((x-pos.x)/pos.k/360+1)/2,((pos.y-y)/pos.k/360+1)/2 @@ -813,8 +821,10 @@ function GP:render() gc_pop() end + -------------------------------------------------------------- -- Other + function GP:decodeScript(line,errMsg) -- TODO -- error(errMsg.."No string command '"..cmd.."'") @@ -822,8 +832,10 @@ end function GP:checkScriptSyntax(cmd,arg,errMsg) -- TODO end + -------------------------------------------------------------- -- Builder + ---@class Techmino.Mode.Setting.Gem local baseEnv={ -- Size diff --git a/assets/game/mechanicLib/init.lua b/assets/game/mechanicLib/init.lua index e057e260..42561f4a 100644 --- a/assets/game/mechanicLib/init.lua +++ b/assets/game/mechanicLib/init.lua @@ -39,6 +39,7 @@ local mechLib={ actions=require'puyo/actions', statistics=require'puyo/statistics', sequence=require'puyo/sequence', + colorSet=require'puyo/colorSet', attackSys=require'puyo/attackSys', misc=require'puyo/misc', }, diff --git a/assets/game/mechanicLib/mino/sequence.lua b/assets/game/mechanicLib/mino/sequence.lua index 1bd7f892..87852502 100644 --- a/assets/game/mechanicLib/mino/sequence.lua +++ b/assets/game/mechanicLib/mino/sequence.lua @@ -16,7 +16,7 @@ end ---@type Techmino.Mech.mino local sequence={} ----@param P Techmino.Player.mino +---@param P Techmino.Player.Mino ---@param d table cached data of generator ---@param init boolean true if this is the first initializating call ---@diagnostic disable-next-line diff --git a/assets/game/mechanicLib/puyo/colorSet.lua b/assets/game/mechanicLib/puyo/colorSet.lua new file mode 100644 index 00000000..8e893aac --- /dev/null +++ b/assets/game/mechanicLib/puyo/colorSet.lua @@ -0,0 +1,28 @@ +---@type Techmino.Mech.puyo +local colorSet={} + +-- R Y B G P C O M +colorSet.light={955,994,469,696,759,699,974,969} +colorSet.classic={933,882,249,484,539,489,952,849} +colorSet.black={400,440,014,141,204,144,420,414} + +colorSet.grey={111,333,555,999,888,666,444,222} + +function colorSet.getRandom(P) + P:random() +end + +setmetatable(colorSet,{ + __index=function(_,k) + assertf(k=='random','Invalid color set key : %s',k) + if 1 then + local l={} + -- TODO + return l + else + error('Not color set : '..k) + end + end +}) + +return colorSet diff --git a/assets/game/mechanicLib/puyo/sequence.lua b/assets/game/mechanicLib/puyo/sequence.lua index 365dbef5..42d9ce16 100644 --- a/assets/game/mechanicLib/puyo/sequence.lua +++ b/assets/game/mechanicLib/puyo/sequence.lua @@ -15,7 +15,7 @@ end ---@type Techmino.Mech.puyo local sequence={} ----@param P Techmino.Player.puyo +---@param P Techmino.Player.Puyo ---@param d table cached data of generator ---@param init boolean true if this is the first initializating call ---@diagnostic disable-next-line diff --git a/assets/game/minoPlayer.lua b/assets/game/minoPlayer.lua index 61e1277f..4a7c9e86 100644 --- a/assets/game/minoPlayer.lua +++ b/assets/game/minoPlayer.lua @@ -12,12 +12,13 @@ local ins,rem=table.insert,table.remove local clamp,expApproach=MATH.clamp,MATH.expApproach ----@class Techmino.Player.mino: Techmino.Player +---@class Techmino.Player.Mino: Techmino.Player ---@field field Techmino.RectField local MP=setmetatable({},{__index=require'basePlayer',__metatable=true}) -------------------------------------------------------------- -- Function tables + local defaultSoundFunc={ countDown= countDownSound, move= function() FMOD.effect('move') end, @@ -66,7 +67,7 @@ local defaultSoundFunc={ win= function() FMOD.effect('win') end, fail= function() FMOD.effect('fail') end, } ----@type Map +---@type Map MP.scriptCmd={ clearHold=function(P) P:clearHold() end, clearNext=function(P) P:clearNext() end, @@ -74,12 +75,16 @@ MP.scriptCmd={ setField=function(P,arg) P:setField(arg) end, switchAction=function(P,arg) P:switchAction(arg) end, } + -------------------------------------------------------------- -- Actions + MP._actions={} for k,v in next,mechLib.mino.actions do MP._actions[k]=MP:_getActionObj(v) end + -------------------------------------------------------------- -- Effects + function MP:createMoveEffect(x1,y1,x2,y2) local p=self.particles.rectShade local dx,dy=self:getSmoothPos() @@ -214,8 +219,10 @@ function MP:getSmoothPos() self.ghostY and self.handY>self.ghostY and 40*(max(1-self.dropTimer/self.settings.dropDelay*2.6,0))^2.6 or 0 end end + -------------------------------------------------------------- -- Game methods + ---@param action 'moveX'|'moveY'|'drop'|'rotate'|'reset' function MP:moveHand(action,A,B,C,D) --[[ @@ -1365,8 +1372,10 @@ function MP:getScriptValue(arg) arg.d=='field_height' and self.field:getHeight() or arg.d=='cell' and (self.field:getCell(arg.x,arg.y) and 1 or 0) end + -------------------------------------------------------------- -- Press & Release & Update & Render + function MP:updateFrame() local SET=self.settings @@ -1843,8 +1852,10 @@ function MP:render() gc_pop() end + -------------------------------------------------------------- -- Other + function MP:decodeScript(line,errMsg) if line.cmd=='setField' then elseif line.cmd=='switchAction' then @@ -1881,8 +1892,10 @@ function MP:checkScriptSyntax(cmd,arg,errMsg) end end end + -------------------------------------------------------------- -- Builder + ---@class Techmino.Mode.Setting.Mino local baseEnv={ -- Size diff --git a/assets/game/puyoPlayer.lua b/assets/game/puyoPlayer.lua index 59b7b32e..7f1e0488 100644 --- a/assets/game/puyoPlayer.lua +++ b/assets/game/puyoPlayer.lua @@ -12,12 +12,13 @@ local max,min=math.max,math.min local floor=math.floor local ins,rem=table.insert,table.remove ----@class Techmino.Player.puyo: Techmino.Player +---@class Techmino.Player.Puyo: Techmino.Player ---@field field Techmino.RectField local PP=setmetatable({},{__index=require'basePlayer',__metatable=true}) -------------------------------------------------------------- -- Function tables + local defaultSoundFunc={ countDown= countDownSound, move= function() FMOD.effect('move') end, @@ -49,15 +50,19 @@ local defaultSoundFunc={ win= function() FMOD.effect('win') end, fail= function() FMOD.effect('fail') end, } ----@type Map +---@type Map PP.scriptCmd={ } + -------------------------------------------------------------- -- Actions + PP._actions={} for k,v in next,mechLib.puyo.actions do PP._actions[k]=PP:_getActionObj(v) end + -------------------------------------------------------------- -- Effects + function PP:createMoveEffect(x1,y1,x2,y2) local p=self.particles.rectShade local dx,dy=self:getSmoothPos() @@ -136,8 +141,10 @@ function PP:getSmoothPos() self.ghostY and self.handY>self.ghostY and 40*(max(1-self.dropTimer/self.settings.dropDelay*2.6,0))^2.6 or 0 end end + -------------------------------------------------------------- -- Game methods + ---@param action 'moveX'|'moveY'|'drop'|'rotate'|'reset' function PP:moveHand(action,A,B,C) --[[ @@ -413,6 +420,46 @@ function PP:freshNextQueue() if shape then self:getPuyo(shape) end end end +function PP:decreaseNextColor(maxLength,maxColor) + while true do + -- Collect all cells in first N pieces + local cells={} + for n=1,min(maxLength,#self.nextQueue) do + local mat=self.nextQueue[n].matrix + for y=1,#mat do for x=1,#mat[1] do + local c=mat[y][x] + if c then + ins(cells,{n,y,x,c.color}) + end + end end + end + + -- Count colors + local colors={} + for i=1,#cells do + local c=cells[i] + local dictKey='mrz'..c[4] + if not colors[dictKey] then + colors[dictKey]={c[4],0} + ins(colors,colors[dictKey]) + end + colors[dictKey][2]=colors[dictKey][2]+1 + end + + -- Finish when color count is less enough + if #colors<=1 or #colors<=maxColor then break end + + -- Merge the rarest two colors + table.sort(colors,function(a,b) return a[2] SHADER={} for _,v in next,love.filesystem.getDirectoryItems('assets/shader') do @@ -434,5 +447,7 @@ SCN.addSwap('fastFadeHeader',{ end, }) DEBUG.checkLoadTime("Load shaders/BGs/SCNs/skins") + -------------------------------------------------------------- + DEBUG.logLoadTime()