rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.18k stars 260 forks source link

Monopoly not finding the path #378

Closed pedroddomingues closed 11 months ago

pedroddomingues commented 11 months ago

Hi! I don't know exactly what I'm doing wrong.

I've tried to mix the monopoly example with the tilemap one. No matter how I create the board (with the tilemap or mannualy above the tilemap) it doesn't change the direction, so it only searchs the path for face direction of ChessA.

This is the running example: https://morram-vermes.vercel.app/phaser

This is te source code: https://github.com/pedroddomingues/morram-vermes

Thanks!

rexrainbow commented 11 months ago

Please provide a simplest, runnable test code for your issue. A project folder with many files will take too much time from setup to run and debug.

pedroddomingues commented 11 months ago

Sorry, the source code url was wrong, I meant the page url..

Here is a working codepen: https://codepen.io/pedroddomingues/pen/dywPdRP Click on map to move in path.

rexrainbow commented 11 months ago

As you see this demo, board only contains moveable tiles, yo can replace line 39 by board.removeChess(tile);, to keep moveable tiles only. If your requirement is keeping all tiles on board, i.e. the moveable path might be created during runtime. I could try to add that feature.

rexrainbow commented 11 months ago

rexBoard (monopoly) has been updated, now tile with invalid cost (null, or undefined) will be discarded from monopoly path.

            if (tile.index === 113) {
                var cost = ((tileXY.x === 2) && (tileXY.y === 5)) ? -1 : 1;
                scene.rexBoard.add.shape(board, tileXY.x, tileXY.y, 2, 0xffffff, 0.4).setOrigin(0).setData('cost', cost);
            } else {
                scene.rexBoard.add.shape(board, tileXY.x, tileXY.y, 2, 0xffffff, 0.1).setOrigin(0).setData('cost', undefined);
            }

Also return -1 at the path end tile (2,5).

NPM package will upgraded at end of this month.

pedroddomingues commented 11 months ago

This is perfect @rexrainbow ! Thank you very much.

Although creating path during runtime can be an awesome feature, it's not necessary for my case.

Congratulations on this project!

rexrainbow commented 11 months ago

Both solutions (removeChess(), or setData('cost', undefined) will work in latest minify rexBoard file.