Implemented basic Creep spawning and display option for messages.
This commit is contained in:
parent
63c68a3cf4
commit
7681a47568
@ -1,12 +1,18 @@
|
||||
var creepBuilds = {
|
||||
|
||||
getHarvesterSmall: function() {
|
||||
return [WORK, WORK, CARRY, MOVE];
|
||||
},
|
||||
getBuildsDict: function() {
|
||||
let harvester = [WORK, WORK, CARRY, MOVE]
|
||||
let upgrader = [WORK, CARRY, MOVE];
|
||||
let builder = [WORK, CARRY, MOVE];
|
||||
|
||||
getUpgraderSmall: function() {
|
||||
return [WORK, CARRY, MOVE];
|
||||
}
|
||||
let buildsDict = {
|
||||
harvester: harvester,
|
||||
upgrader: upgrader,
|
||||
builder: builder,
|
||||
}
|
||||
|
||||
return buildsDict;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = creepBuilds;
|
||||
|
@ -10,5 +10,6 @@ var creepManager = require("./manage_creeps");
|
||||
|
||||
module.exports.loop = function () {
|
||||
misc.clearMemory();
|
||||
misc.displayMessage(Game.spawns.Spawn1, "test")
|
||||
creepManager.run();
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ var creepManager = {
|
||||
|
||||
run: function() {
|
||||
if (spawnCreeps) {
|
||||
for (role in creepGoalAmount) {
|
||||
roleCreepsAmount = _.filter(Game.creeps, (creep) => creep.memory.role == role);
|
||||
for (let role in creepGoalAmount) {
|
||||
let roleCreepsAmount = (_.filter(Game.creeps, (creep) => creep.memory.role == role)).length;
|
||||
if (roleCreepsAmount < creepGoalAmount[role]) {
|
||||
spawnCreep(role, roleCreepsAmount);
|
||||
}
|
||||
@ -27,17 +27,15 @@ var creepManager = {
|
||||
module.exports = creepManager;
|
||||
|
||||
|
||||
|
||||
|
||||
function spawnCreep(role, existing) {
|
||||
let name = role + "_Spheal_" + existing;
|
||||
let newCreepName = role + "_Spheal_" + existing;
|
||||
let newCreepBuild = creepBuilds.getBuildsDict()[role];
|
||||
|
||||
Game.spawns.Spawn1.spawnCreep(newCreepBuild, newCreepName, { memory: { role: role } });
|
||||
|
||||
if (!Game.spawns.Spawn1.spawning) {
|
||||
misc.displayMessage("Spawn", Game.spawns.Spawn1, "Spawning next: " + name);
|
||||
}
|
||||
else {
|
||||
misc.displayMessage("Spawn", Game.spawns.Spawn1, "Spawning Creep");
|
||||
}
|
||||
|
||||
Game.spawns.Spawn1.spawnCreep(creepBuilds[buildType], newCreepName, { memory: { role: buildType } });
|
||||
misc.displayMessage(Game.spawns.Spawn1, "Spawning next: " + newCreepName);
|
||||
} else {
|
||||
misc.displayMessage(Game.spawns.Spawn1, "Spawning Creep");
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,30 @@ var settings = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
displayMessage: function(object, msgString) {
|
||||
if (object instanceof Spawn) {
|
||||
object.room.visual.text(
|
||||
msgString,
|
||||
object.pos.x,
|
||||
object.pos.y+1,
|
||||
{
|
||||
align: 'center',
|
||||
opacity: 0.9,
|
||||
backgroundPadding: 0.2,
|
||||
backgroundColor: "#222222",
|
||||
color: "#eeeeee"
|
||||
}
|
||||
);
|
||||
}
|
||||
else if (object instanceof Creep) {
|
||||
object.say(msgString);
|
||||
}
|
||||
else {
|
||||
console.log("ERROR: displayMessage(" + object + ", " + msgString + ") failed.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = settings;
|
||||
|
@ -1,12 +1,12 @@
|
||||
var settings = {
|
||||
|
||||
getCreepGoalAmount: function() {
|
||||
var getCreepAmountGoalDict = {
|
||||
var getCreepGoalAmountDict = {
|
||||
harvester: 1,
|
||||
upgrader: 1,
|
||||
builder: 1
|
||||
upgrader: 0,
|
||||
builder: 0
|
||||
}
|
||||
return getCreepAmountGoalDict;
|
||||
return getCreepGoalAmountDict;
|
||||
},
|
||||
|
||||
getSpawnCreeps: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user