HTML and CSS Reference
In-Depth Information
var hasEnoughPowerSupplies =
(game.BuildingsData[name].needPopulations ===
0 || (game.powerSupplies-game.populations) >=
game.BuildingsData[name].needPopulations);
// The Boolean determines that the player has enough coins to
build that building.
var hasEnoughCoins =
(game.coins >= game.BuildingsData[name].needCoins);
if (hasEnoughPowerSupplies && hasEnoughCoins) {
// show the button and hide the disabled image
this['build' + name + 'Disabled'].visible = false;
this['build' + name].y = this['build' + name +
'Disabled'].y;
} else {
// show the disabled image and hide the button
this['build' + name + 'Disabled'].visible = true;
this['build' + name].y = 999;
}
}
};
11. Then, we need a way to quickly hide the building panel:
UILayer.prototype.hideBuildingPanel = function() {
this.newBuildingBtn.visible = true;
this.buildingPanel.visible = false;
};
12. After the player chooses a building to be built, we ready the game to place the
building:
UILayer.prototype.readyToPlaceBuilding = function() {
this.buildingPanel.visible = false;
this.cancelBuildBtn.visible = true;
game.isCreatingNewBuilding = true;
// we are going to really place the building in the next task.
};
At the end of the task, we will have created the building panel with the building selectable
by the mouse. We don't have any building placing logic yet. We are going to work on this in
the next task.
 
Search WWH ::




Custom Search