Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added counter to bots

  • Loading branch information...
commit 0c20f3e53e72c1774e2f7b83d67b2b0041ec18cf 1 parent 4c45d04
@agryson authored
View
9 Prototypes/MapCanvas/MapCanvas.css
@@ -24,7 +24,7 @@ button:active{
box-shadow: inset 1px 1px 3px 1px #090909, 1px 1px 1px 0 white;
}
-.itemText, #notifications, .info, .action, #turnNumber, .start-button, #mainTitle, #loadMessage {
+.itemText, #notifications, .info, .action, #turnNumber, .start-button, #mainTitle, #loadMessage, .botCountNum {
font-family: Arial, sans-serif;
font-weight: bold;
}
@@ -269,6 +269,13 @@ button:active{
background: green;
}
+.botCountNum{
+ position: absolute;
+ right: 20px;
+ bottom: 5px;
+ font-size: 12px;
+}
+
.building{
display: none;
}
View
57 Prototypes/MapCanvas/MapCanvas.js
@@ -58,7 +58,7 @@ function Terrain() {
this.willBe = 3;
this.robotInUse = 0;
Game.robots[0][0] +=1;
- document.getElementById('dozerCount').style.height = ((Game.robots[0][1]-Game.robots[0][0])/Game.robots[0][1])*100 + '%';
+ reCount('dozer');
}else {
notify("You can't prepare this terrain...");
}
@@ -73,7 +73,7 @@ function Terrain() {
Game.robots[1][0]+=1;
this.robotInUse = 1;
this.digCavern(x,y,lowerTile,Game.level + 1,true,1000);
- document.getElementById('diggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
+ reCount('digger');
} else {
notify("Can't dig here...");
}
@@ -95,7 +95,7 @@ function Terrain() {
if(level > 0 && !wetTest([y,x], level) && nearWall && !tile.wip && Game.robots[1][0] < Game.robots[1][1] && !this.exists){
Game.robots[1][0]+=1;
tile.robotInUse = 1;
- document.getElementById('cavernDiggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
+ reCount('digger');
willBe >= 0 ? tile.willBe=willBe : tile.willBe = willBe+5; //this is for if we try to do it on prepared terrain
tile.wip = true;
tile.turns = eta(2, this.kind);
@@ -125,7 +125,7 @@ function Terrain() {
if(Game.level < 4 && lowerTile.kind !== 4 && !this.wip && this.diggable && !lowerTile.diggable && Game.robots[2][0] < Game.robots[2][1]){
Game.robots[2][0] += 1;
this.robotInUse = 2;
- document.getElementById('minerCount').style.height = ((Game.robots[2][1]-Game.robots[2][0])/Game.robots[2][1])*100 + '%';
+ reCount('miner');
this.turns = eta(5, this.kind);
this.kind=10;
this.wip = true;
@@ -149,7 +149,7 @@ function Terrain() {
this.willBe = 3;
Game.robots[3][0] +=1;
this.robotInUse = 3;
- document.getElementById('recyclerCount').style.height = ((Game.robots[3][1]-Game.robots[3][0])/Game.robots[3][1])*100 + '%';
+ reCount('recycler');
} else {
notify("You can't recycle this...");
}
@@ -271,11 +271,11 @@ function Param(){
function init() {
Game = new Param(); //TODO: Should add save and load game code here...
checkBuildings();
+ reCount('all');
}
function checkBuildings(){
for(var i = 0; i<Game.buildings.length; i++){
- console.log(Game.buildings[i]);
document.getElementById(Game.buildings[i]).style.display = 'table';
}
}
@@ -344,16 +344,51 @@ function nextTurn(){
}
drawRadar();
Game.turnNum.innerHTML = "Week: " + Game.turn;
- document.getElementById('dozerCount').style.height = ((Game.robots[0][1]-Game.robots[0][0])/Game.robots[0][1])*100 + '%';
- document.getElementById('diggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
- document.getElementById('cavernDiggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
- document.getElementById('minerCount').style.height = ((Game.robots[2][1]-Game.robots[2][0])/Game.robots[2][1])*100 + '%';
- document.getElementById('recyclerCount').style.height = ((Game.robots[3][1]-Game.robots[3][0])/Game.robots[3][1])*100 + '%';
+ reCount('all');
//The following hold code just prevents accidentally skipping two turns with accidental clicks...
document.getElementById('turn').disabled = true;
setTimeout(function(){document.getElementById('turn').disabled = false},300);
}
+function reCount(which){
+ console.log(((Game.robots[0][1]-Game.robots[0][0])/Game.robots[0][1])*100+'%');
+ console.log('Available: ' + parseInt(Game.robots[0][1]-Game.robots[0][0]));
+ switch(which){
+ case 'dozer':
+ document.getElementById('dozerCount').style.height = ((Game.robots[0][1]-Game.robots[0][0])/Game.robots[0][1])*100 + '%';
+ document.getElementById('dozerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[0][1]-Game.robots[0][0]);
+ break;
+ case 'digger':
+ document.getElementById('diggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
+ document.getElementById('cavernDiggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
+ document.getElementById('diggerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[1][1]-Game.robots[1][0]);
+ document.getElementById('cavernDiggerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[1][1]-Game.robots[1][0]);
+ break;
+ case 'miner':
+ document.getElementById('minerCount').style.height = ((Game.robots[2][1]-Game.robots[2][0])/Game.robots[2][1])*100 + '%';
+ document.getElementById('minerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[2][1]-Game.robots[2][0]);
+ break;
+ case 'recycler':
+ document.getElementById('recyclerCount').style.height = ((Game.robots[3][1]-Game.robots[3][0])/Game.robots[3][1])*100 + '%';
+ document.getElementById('recyclerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[3][1]-Game.robots[3][0]);
+ break;
+ case 'all':
+ document.getElementById('dozerCount').style.height = ((Game.robots[0][1]-Game.robots[0][0])/Game.robots[0][1])*100 + '%';
+ document.getElementById('dozerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[0][1]-Game.robots[0][0]);
+ document.getElementById('diggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
+ document.getElementById('cavernDiggerCount').style.height = ((Game.robots[1][1]-Game.robots[1][0])/Game.robots[1][1])*100 + '%';
+ document.getElementById('diggerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[1][1]-Game.robots[1][0]);
+ document.getElementById('cavernDiggerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[1][1]-Game.robots[1][0]);
+ document.getElementById('minerCount').style.height = ((Game.robots[2][1]-Game.robots[2][0])/Game.robots[2][1])*100 + '%';
+ document.getElementById('minerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[2][1]-Game.robots[2][0]);
+ document.getElementById('recyclerCount').style.height = ((Game.robots[3][1]-Game.robots[3][0])/Game.robots[3][1])*100 + '%';
+ document.getElementById('recyclerCountNum').innerHTML = 'Available: ' + parseInt(Game.robots[3][1]-Game.robots[3][0]);
+ break;
+ default:
+ console.log("Wait, I've lost count of the drones...");
+ }
+}
+
function leftMenuResize(bool) {
if (bool){
document.getElementById('leftMenu').onmousemove = resize;
View
7 Prototypes/MapCanvas/index.html
@@ -8,6 +8,7 @@
</head>
<body onload="init()">
+
<div class="popupContainer" id="popupContainer">
<div id="mainTitle">Codename: Eureka!</div>
<div class="popup" id="popup">
@@ -23,7 +24,6 @@
</div>
</div>
</div>
-
<!--loading screen moved up to improve performance-->
<div id="leftMenu">
@@ -182,6 +182,7 @@
<div class="botThumb" id="dozerCount">
</div>
</div>
+ <span class="botCountNum" id="dozerCountNum" ></span>
<img class="itemImage" src="images/dozer.png"></img>
<span class="itemText">Dronedoze terrain</span>
</div>
@@ -190,6 +191,7 @@
<div class="botThumb" id="diggerCount">
</div>
</div>
+ <span class="botCountNum" id="diggerCountNum" ></span>
<img class="itemImage" src="images/digger.png"></img>
<span class="itemText">Dig Down</span>
</div>
@@ -198,6 +200,7 @@
<div class="botThumb" id="cavernDiggerCount">
</div>
</div>
+ <span class="botCountNum" id="cavernDiggerCountNum" ></span>
<img class="itemImage" src="images/digger.png"></img>
<span class="itemText">Expand Cavern</span>
</div>
@@ -206,6 +209,7 @@
<div class="botThumb" id="minerCount">
</div>
</div>
+ <span class="botCountNum" id="minerCountNum" ></span>
<img class="itemImage" src="images/miner.png"></img>
<span class="itemText">Mine Resources</span>
</div>
@@ -214,6 +218,7 @@
<div class="botThumb" id="recyclerCount">
</div>
</div>
+ <span class="botCountNum" id="recyclerCountNum" ></span>
<img class="itemImage" src="images/recycle.png"></img>
<span class="itemText">Recycle Construction</span>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.