Created
April 5, 2016 16:44
-
-
Save laverdet/dcb7435ad2b5fe2b56a8c82cc0017ca8 to your computer and use it in GitHub Desktop.
tmp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addBlockedRoomsToMatrix(theRoom) | |
{ | |
console.log(theRoom) | |
var theMatrix = new PathFinder.CostMatrix | |
{ | |
var exits = Game.map.describeExits(theRoom); | |
for(var ext in exits) | |
{ | |
var room = exits[ext]; | |
if((room) == 'E1N18') | |
{ | |
console.log('Adding blocked edge for direction ' + ext + " towards " + room,'matrix'); | |
blockRoomForPathfinder(theMatrix, Number(ext)); | |
} | |
} | |
} | |
return theMatrix; | |
} | |
function blockRoomForPathfinder(theMatrix, theDirection) | |
{ | |
for (var ii = 0; ii <= 49; ii++) | |
{ | |
if (theDirection == TOP) { | |
theMatrix.set(ii, 0, 0xff); | |
} | |
if (theDirection == RIGHT) { | |
theMatrix.set(49, ii, 0xff); | |
} | |
if (theDirection == BOTTOM) { | |
theMatrix.set(ii, 49, 0xff); | |
} | |
if (theDirection == LEFT) { | |
theMatrix.set(0, ii, 0xff); | |
} | |
} | |
} | |
console.log( | |
PathFinder.search(new RoomPosition(15,20, 'E2N19'), new RoomPosition(26, 27, 'E1N16'), { | |
roomCallback: addBlockedRoomsToMatrix, | |
}).path | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment