@@ -118,7 +118,15 @@ export class Grid {
118118 case Block . fallable :
119119 case Block . goal :
120120 case Block . switchBase : {
121- const sprite = createSprite ( cellSize , dblock , x , y , this . marginY ) ;
121+ const objectId = stageDefinition . blockGroups . find ( ( g ) => g . x === x && g . y === y ) ?. objectId || undefined ;
122+ let movableBlockColor : number | undefined = undefined ;
123+ if (
124+ dblock === Block . movable &&
125+ stageDefinition . blockGroups . filter ( ( b ) => b . objectId === objectId ) . length >= 2
126+ ) {
127+ movableBlockColor = consts . LARGE_BLOCK_COLOR ;
128+ }
129+ const sprite = createSprite ( cellSize , dblock , x , y , this . marginY , movableBlockColor ) ;
122130 stage . addChild ( sprite ) ;
123131 vspriteRow . push ( { sprite, block : dblock , dy : 0 , vy : 0 } ) ;
124132 break ;
@@ -211,7 +219,10 @@ export class Grid {
211219 const vsom = this . __vsom [ y ] [ x ] ;
212220 const newCell = newGrid [ y ] [ x ] ;
213221 if ( vsom ?. block !== newCell . block ) {
214- this . setBlock ( cx , x , y , newCell ) ;
222+ // TODO:this uses a lot of memory
223+ const isBlockLarge =
224+ newGrid . flatMap ( ( row ) => row . filter ( ( cell ) => cell . objectId === newCell . objectId ) ) . length >= 2 ;
225+ this . setBlock ( cx , x , y , newCell , isBlockLarge ) ;
215226 }
216227 }
217228 }
@@ -345,6 +356,7 @@ export class Grid {
345356 x : number ,
346357 y : number ,
347358 cNewCell : GridCell ,
359+ isLargeBlock ?: boolean , // todo: please fix shitty code this someone please
348360 ) {
349361 const stage = cx . _stage_container ;
350362 const cells = get ( cx . state ) . cells ;
@@ -363,6 +375,8 @@ export class Grid {
363375 assert ( cNewCell . objectId == null , "Cell is not movable but has an objectId" ) ;
364376 }
365377
378+ const movableBlockColor = isLargeBlock ? consts . LARGE_BLOCK_COLOR : undefined ;
379+
366380 if ( vprev ?. block === Block . switch && cNewCell . block === Block . switchPressed ) {
367381 // switchがプレイヤーに押されるとき
368382 assert (
@@ -409,7 +423,7 @@ export class Grid {
409423 console . log ( "cell.block" , cNewCell . block ) ;
410424 return ;
411425 }
412- const movableSprite = createSprite ( blockSize , cNewCell . block , x , y , marginY ) ;
426+ const movableSprite = createSprite ( blockSize , cNewCell . block , x , y , marginY , movableBlockColor ) ;
413427 stage . addChild ( movableSprite ) ;
414428 assert ( cNewCell . objectId !== undefined , "movable block must have objectId" ) ;
415429 assert (
@@ -551,7 +565,8 @@ export class Grid {
551565 break ;
552566 }
553567 case Block . movable : {
554- const movableSprite = createSprite ( blockSize , cNewCell . block , x , y , marginY ) ;
568+ const movableSprite = createSprite ( blockSize , cNewCell . block , x , y , marginY , movableBlockColor ) ;
569+ console . log ( movableBlockColor ) ;
555570 stage . addChild ( movableSprite ) ;
556571 assert ( cNewCell . objectId !== undefined , "movable block must have objectId" ) ;
557572 cells [ y ] [ x ] = {
@@ -666,7 +681,6 @@ export class Grid {
666681 vSwapCell . vy = vcell . vy ;
667682 vcell . dy = 0 ;
668683 vcell . vy = 0 ;
669- // また抽象化失敗してる...
670684 vSwapCell . sprite . y = ( y + swapDiff ) * blockSize + marginY + vSwapCell . dy ;
671685 console . log ( "dy" , vSwapCell . dy , "vy" , vSwapCell . vy ) ;
672686 }
@@ -908,7 +922,8 @@ function createSprite(
908922 x : number ,
909923 y : number ,
910924 marginY : number ,
911- switchColor ?: number , // 例: #ffa500
925+ // 使われたり使われなかったりするので注意
926+ color ?: number , // 例: #ffa500
912927) {
913928 switch ( block ) {
914929 case Block . block : {
@@ -918,10 +933,14 @@ function createSprite(
918933 return sprite ;
919934 }
920935 case Block . movable : {
921- const movableSprite = new Sprite ( rockTexture ) ;
922- movableSprite . tint = 0xff0000 ;
923- updateSprite ( movableSprite , blockSize , x , y , marginY , 0 ) ;
924- return movableSprite ;
936+ const sprite = new Sprite ( rockTexture ) ;
937+ if ( color ) {
938+ sprite . tint = color ;
939+ } else {
940+ sprite . tint = 0xff0000 ;
941+ }
942+ updateSprite ( sprite , blockSize , x , y , marginY , 0 ) ;
943+ return sprite ;
925944 }
926945 case Block . fallable : {
927946 const movableSprite = new Sprite ( fallableTexture ) ;
@@ -931,7 +950,7 @@ function createSprite(
931950 }
932951 case Block . switch : {
933952 const switchSprite = new Sprite ( switchTexture ) ;
934- if ( switchColor ) switchSprite . tint = switchColor ;
953+ if ( color ) switchSprite . tint = color ;
935954 updateSprite ( switchSprite , blockSize , x , y , marginY , 0 ) ;
936955 return switchSprite ;
937956 }
@@ -943,23 +962,23 @@ function createSprite(
943962 case Block . inverseSwitchingBlockON :
944963 case Block . switchingBlockOFF : {
945964 const sprite = new Sprite ( rockTexture ) ;
946- if ( switchColor ) sprite . tint = switchColor ;
965+ if ( color ) sprite . tint = color ;
947966 else sprite . tint = 0xffa500 ;
948967 updateSprite ( sprite , blockSize , x , y , marginY , 0 ) ;
949968 return sprite ;
950969 }
951970 case Block . inverseSwitchingBlockOFF :
952971 case Block . switchingBlockON : {
953972 const sprite = new Sprite ( rockTexture ) ;
954- if ( switchColor ) sprite . tint = switchColor ;
973+ if ( color ) sprite . tint = color ;
955974 else sprite . tint = 0xffa500 ;
956975 sprite . alpha = 0.3 ;
957976 updateSprite ( sprite , blockSize , x , y , marginY , 0 ) ;
958977 return sprite ;
959978 }
960979 case Block . switchPressed : {
961980 const sprite = new Sprite ( switchPressedTexture ) ;
962- if ( switchColor ) sprite . tint = switchColor ;
981+ if ( color ) sprite . tint = color ;
963982 else sprite . tint = 0xffa500 ;
964983 updateSprite ( sprite , blockSize , x , y , marginY , 0 ) ;
965984 return sprite ;
0 commit comments