52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
function c_selectunit(unitobject) {
|
|
if unitobject.waiting return false
|
|
unitobject.state = st_moving;
|
|
unitobject.drawstate = st_movingdraw;
|
|
unitobject.returnpos = new vec2(unitobject.pos.x, unitobject.pos.y);
|
|
var mov = unitobject.data.mov.val;
|
|
var i, j;
|
|
for (i=-mov; i<=mov; i++) {
|
|
for (j=-mov; j<=mov; j++) {
|
|
if abs(i)+abs(j) <= mov {
|
|
c_colortile(unitobject.pos.x+i, unitobject.pos.y+j, c_cyan);
|
|
}
|
|
}
|
|
}
|
|
ARTICULATOR.selectedunit = unitobject;
|
|
c_fulleval(unitobject);
|
|
return unitobject;
|
|
}
|
|
|
|
function c_deselectunit(unitobject) {
|
|
if ARTICULATOR.selectedunit != unitobject return false
|
|
unitobject.sprite_index = unitobject.data.idle;
|
|
state = st_standing;
|
|
drawstate = c_null;
|
|
c_decolor_all(c_cyan);
|
|
c_decolor_all(c_red);
|
|
c_decolor_all(c_green);
|
|
ARTICULATOR.selectedunit = noone;
|
|
c_fulleval(unitobject);
|
|
return true;
|
|
}
|
|
|
|
function c_colortile(x, y, color) {
|
|
if !c_tileexists(x, y) return false;
|
|
if !array_contains(global.map[x][y], color) {
|
|
array_push(global.map[x][y].overlays, color);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function c_markunit(unitobject) {
|
|
var i, j;
|
|
var mov = unitobject.data.mov.val;
|
|
for (i=-mov; i<=mov; i++) {
|
|
for (j=-mov; j<=mov; j++) {
|
|
if abs(i)+abs(j) <= mov {
|
|
(unitobject.marked ? c_decolor : c_colortile)(unitobject.pos.x+i, unitobject.pos.y+j, c_maroon);
|
|
}
|
|
}
|
|
}
|
|
unitobject.marked = !unitobject.marked;
|
|
} |