-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathnavigator.js
40 lines (32 loc) · 958 Bytes
/
navigator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var cga = require(process.env.CGA_DIR_PATH_UTF8+'/cgaapi')(function(){
if(process.argv[3] == undefined)
{
throw new Error('该寻路脚本为CGAssistant内部调用,无法单独使用!');
}
var x = parseInt(process.argv[3]);
var y = parseInt(process.argv[4]);
var entermap = parseInt(process.argv[5]);
var mapname = cga.GetMapName();
var curXY = cga.GetMapXY();
var Path = cga.calculatePath(curXY.x, curXY.y, x, y, mapname, null, null, []);
var PF = require('pathfinding');
if(Path.length > 0)
{
for(var i in Path){
if(Path[i][2] !== undefined || Path[i][5] !== undefined)
Path[i] = [Path[i][0], Path[i][1]];
}
Path.unshift([curXY.x, curXY.y]);
console.log('[PATH BEGIN]');
console.log(Path);
console.log('[PATH END]');
cga.walkList([
(entermap && entermap != 3) ? [x, y, ''] : [x, y],
], ()=>{
});
} else {
console.log('[PATH BEGIN]');
console.log(Path);
console.log('[PATH END]');
}
});