From e64cf48aa7a9755f957718ec45766adff2aeb195 Mon Sep 17 00:00:00 2001 From: facat Date: Sat, 24 Oct 2020 15:57:44 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=B3=A8?= =?UTF-8?q?=E9=87=8A.2.=E5=A2=9E=E5=8A=A0=E8=B7=AF=E5=BE=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 ---- path.js | 4 ++-- transfer.js | 8 ++++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/main.js b/main.js index 56d3482..9971b43 100644 --- a/main.js +++ b/main.js @@ -189,10 +189,6 @@ function assign_builder_to_controller() { Memory.WorkingTarget[`RoomController_${Game.spawns['Spawn1'].room.controller.id}`] = { id: Game.spawns['Spawn1'].room.controller.id, working_creep_names: [], cate: 'ROOM_CONTROLLER' } } let room_controller_mem = _.filter(Memory.WorkingTarget, { cate: 'ROOM_CONTROLLER' }) - //先移除已经失效的creep - _.each(room_controller_mem, function (m) { - _.remove(m.working_creep_names, creep_name => !Game.creeps[creep_name])//如果一个creep已经不存在了,就从列表中移除 - }) //寻找creep为0的room controller let room_controller_need_creep_array = _.filter(room_controller_mem, m => m.working_creep_names.length == 0 && m.cate=='ROOM_CONTROLLER') if (room_controller_need_creep_array.length > 0) { diff --git a/path.js b/path.js index 9ceee0b..331d9dc 100644 --- a/path.js +++ b/path.js @@ -1,8 +1,8 @@ module.exports = { visualPath(my_pos, target_pos) { // visualize the path - const path = PathFinder.search(my_pos, target_pos).path; + // let path = PathFinder.search(my_pos, target_pos).path; // console.log(path) - Game.map.visual.poly(path, { stroke: '#ffffff', strokeWidth: .8, opacity: .2, lineStyle: 'dashed' }); + // Game.map.visual.poly(path, { stroke: '#ffffff', strokeWidth: 8, opacity: .2, lineStyle: 'dashed' }); } } \ No newline at end of file diff --git a/transfer.js b/transfer.js index 2e05ec8..d1c5209 100644 --- a/transfer.js +++ b/transfer.js @@ -31,7 +31,7 @@ module.exports = { return } if (utils.distance(working_target_pos, my_pos) > 1.5) {//在附近就是1或者1.414 - creep.moveTo(working_target_pos); + creep.moveTo(working_target_pos,{visualizePathStyle: {stroke: '#ffffff'}}); path.visualPath(creep.pos, working_target_pos); } else { //find dropped source @@ -44,7 +44,7 @@ module.exports = { } else { if (creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { - creep.moveTo(Game.spawns['Spawn1']); + creep.moveTo(Game.spawns['Spawn1'],{visualizePathStyle: {stroke: '#ffffff'}}); path.visualPath(creep.pos, Game.spawns['Spawn1'].pos); } } @@ -52,14 +52,14 @@ module.exports = { if (working_target.memory.role == 'builder') { if (creep.store.energy > 0) { if (utils.distance(working_target_pos, my_pos) > 1.5) {//在附近就是1或者1.414 - creep.moveTo(working_target_pos); + creep.moveTo(working_target_pos,{visualizePathStyle: {stroke: '#ffffff'}}); path.visualPath(creep.pos, working_target_pos); } else { creep.drop(RESOURCE_ENERGY) } } else { if (creep.withdraw(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { - creep.moveTo(Game.spawns['Spawn1']); + creep.moveTo(Game.spawns['Spawn1'],{visualizePathStyle: {stroke: '#ffffff'}}); path.visualPath(creep.pos, Game.spawns['Spawn1'].pos); } }