加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tasks.js 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
Lev 提交于 2020-02-17 12:50 . first commit
var B = require('behaviors');
module.exports = {
transport: function(src,target,resourceType,creep){
if(creep.store.getUsedCapacity() > creep.store[resourceType] || creep.ticksToLive < 30){ //Clear
if(creep.pos.isNearTo(creep.room.storage)){
for(var res in creep.store){
if(res != resourceType || creep.ticksToLive < 30) creep.transfer(creep.room.storage, res);
}
}else creep.moveTo(creep.room.storage);
creep.say('Ha?');
return;
}
if((!src.store.getUsedCapacity(resourceType) && !creep.store[resourceType]) || !target.store.getFreeCapacity(resourceType) || !creep) return creep.say('Break!');
creep.say('Ohayo!');
if(creep.store.getUsedCapacity() == 0){
if(creep.pos.isNearTo(src)){
B.GetResource(creep, src.pos, resourceType);
}else creep.moveTo(src,{reuse:100});
}else{
if(creep.pos.isNearTo(target)) creep.transfer(target, resourceType);
else creep.moveTo(target,{reuse:100});
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化