Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
role.upgpicker.js 1.40 KB
Copy Edit Raw Blame History
Lev authored 2020-02-17 12:50 . first commit
var B = require('behaviors');
module.exports = {
run: function(creep){
const room = creep.room.name;
const pos = new RoomPosition(Memory.rooms[room].Upgrade.x, Memory.rooms[room].Upgrade.y, room);
if(B.DetectResource(pos,'energy') > 2000 && room != 'W42N28') return;
if(creep.store.getUsedCapacity() == 0){
const pos1 = new RoomPosition(Memory.rooms[room].Source1.x, Memory.rooms[room].Source1.y, room);
const pos2 = new RoomPosition(Memory.rooms[room].Source2.x, Memory.rooms[room].Source2.y, room);
var target = pos1;
if(B.DetectResource(pos1,'energy') < B.DetectResource(pos2,'energy')) target = pos2;
if(B.DetectResource(target, 'energy') < 100 && Memory.rooms[room].storage) target = creep.room.storage.pos;
if(Memory.rooms[room].storage) target = creep.room.storage.pos;
if(creep.pos.isNearTo(target)) B.GetResource(creep, target, 'energy');
else creep.moveTo(target, {visualizePathStyle: {stroke: '#ffffff'},reuse:200});
}else{
const pos = new RoomPosition(Memory.rooms[room].Upgrade.x, Memory.rooms[room].Upgrade.y, room);
if(creep.pos.isNearTo(pos)) creep.transferResource(pos,'energy');
else creep.moveTo(pos, {visualizePathStyle: {stroke: '#ffff00'},reuse:200});
}
}
}
// global.sayHello = function() { console.log('Hello!'); };
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化