-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathunitproduction.js
46 lines (36 loc) · 1.5 KB
/
unitproduction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var numberOfSCV = 4;
function makeSCV(ccid)
{
//increase scv counter var
numberOfSCV++;
//make new vars for new scv
eval('window.scv' + numberOfSCV + 'building' + '=' + '0');
eval('window.scv' + numberOfSCV + 'move' + '=' + '0');
eval('window.scv' + numberOfSCV + 'selected' + '=' + '0');
eval('window.scv' + numberOfSCV + 'buildingMode' + '=' + '0');
eval('window.scv' + numberOfSCV + 'building' + '=' + '0');
eval('window.scv' + numberOfSCV + 'buildingSet' + '=' + '0');
eval('window.scv' + numberOfSCV + 'buildingx' + '=' + '0');
eval('window.scv' + numberOfSCV + 'buildingy' + '=' + '0');
//create div for scv
newSCV = document.createElement('div');
//set scv div ID by instance
newSCVId = 'scv' + numberOfSCV;
newSCV.setAttribute('id', newSCVId);
//set sc dimensions
newSCV.style.width = 72;
newSCV.style.height = 72;
//set scv background. Dimensions must be set or bg will repeat.
newSCV.style.background = "url('images/scv/180.png')"; //set scv image as the div bg
document.getElementById('map').appendChild(newSCV);
//move to origin
new Effect.Move(newSCVId, { x: 0, y: -document.getElementById(newSCVId).offsetTop, mode: 'relative', duration:0 });
//set cursor
document.getElementById(newSCVId).style.cursor = 'url(images/cursor/magnifier.gif)';
//add scvid to array
unitArray[numberOfSCV]=newSCV;
var buildStateVar = eval("'scv" + "" + numberOfSCV + "" + "building'");
console.log(buildStateVar);
//add scv build state to array
scvbuildingModeArray[numberOfSCV]=buildStateVar;
}