-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommand.js
75 lines (62 loc) · 1.88 KB
/
command.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//change unit portrait to 'file' variable
function portrait(file)
{
document.getElementById('portraitimage').src = 'images/portraits/' + file;
}
//change map cursor file
function mapCursor(file)
{
document.getElementById('map').style.cursor = 'url(images/' + file + ')';
}
//change build command visibility
function buildCommands(state)
{
document.getElementById('build1image').style.visibility = state;
}
function movementCommands(state)
{
document.getElementById('stopimage').style.visibility = state;
}
//play file as interface effect
function playInterfaceEffect(file)
{
document.getElementById('interfaceeffects').src = 'sounds/' + file;
var interfaceeffects = document.getElementById('interfaceeffects');
interfaceeffects.play();
}
//play file as secondary interface effect
function playInterfaceEffect2(file)
{
document.getElementById('interfaceeffects2').src = 'sounds/' + file;
var interfaceeffects2 = document.getElementById('interfaceeffects2');
interfaceeffects2.play();
}
function build1image() {
for (unitArrayAmount=unitArray.length-1;unitArrayAmount>=1;unitArrayAmount--)
{
var unitElement = 'scv'+unitArrayAmount+'selected';
var selectedStatus = eval(unitElement);
if(selectedStatus=='1')
{
eval('scv' + unitArrayAmount + 'buildingMode = 1');
mapCursor('academy/academyplc.png');
playInterfaceEffect('button.mp3');
unitArrayAmount = 1; //stop scanning as we already have one scv to set to build
}
}
}
function stopMovement() {
playInterfaceEffect('button.mp3');
//check which scvs are selected
for (unitArrayAmount=unitArray.length-1;unitArrayAmount>=1;unitArrayAmount--)
{
var unitElement = 'scv'+unitArrayAmount+'selected';
var selectedStatus = eval(unitElement);
if(selectedStatus=='1')
{
console.log(unitArrayAmount);
//cancel that unit's scope queue
Effect.Queues.get('scv' + unitArrayAmount + 'scope').invoke('cancel');
}
}
}