2017-11-16 02:06:07 +00:00
|
|
|
var GetTilesWithin = require('./GetTilesWithin');
|
|
|
|
var ShuffleArray = require('../../../utils/array/Shuffle');
|
|
|
|
|
2017-11-22 01:19:13 +00:00
|
|
|
// Shuffles indices, not other properties. Does not modify collisions. Matches v2 functionality.
|
2017-11-16 02:06:07 +00:00
|
|
|
var Shuffle = function (tileX, tileY, width, height, layer)
|
|
|
|
{
|
|
|
|
var tiles = GetTilesWithin(tileX, tileY, width, height, layer);
|
|
|
|
|
|
|
|
var indices = tiles.map(function (tile) { return tile.index; });
|
|
|
|
ShuffleArray(indices);
|
|
|
|
|
|
|
|
for (var i = 0; i < tiles.length; i++)
|
|
|
|
{
|
|
|
|
tiles[i].index = indices[i];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Shuffle;
|