精彩的游戏!
寻找一个例子,说明如何在蠕变者的记忆中保持对某一特定能源的引用。似乎存储实际的源对象无法工作(?)。
发布于 2014-11-21 13:12:55
不能存储对象实例,但可以存储它们的ID。
if(!creep.memory.targetSourceId) {
var source = creep.pos.findNearest(Game.SOURCES_ACTIVE);
creep.memory.targetSourceId = source.id;
} 然后您可以使用Game.getObjectById()找到这个特定的源。
var source = Game.getObjectById(creep.memory.targetSourceId);
creep.moveTo(source);https://stackoverflow.com/questions/27061998
复制相似问题