Implemented node movement
This commit is contained in:
parent
6085267cc4
commit
7744bad7c7
29
gamedata.cpp
29
gamedata.cpp
|
@ -82,20 +82,33 @@ void GameData::handle_click(int x, int y)
|
|||
int colour;
|
||||
colour = turn->get_colour();
|
||||
|
||||
if (mode == MODE_SELECT)
|
||||
Vertex* v = vertex_at(x, y, 0);
|
||||
|
||||
// fixme - energy expenditure should happen in each of these cases except
|
||||
// MODE_SELECT
|
||||
switch (mode)
|
||||
{
|
||||
case MODE_SELECT:
|
||||
// select_vertex handles making sure a point exists at (x,y)
|
||||
select_vertex(x, y);
|
||||
}
|
||||
else if (mode == MODE_BUILD)
|
||||
{
|
||||
break;
|
||||
case MODE_BUILD:
|
||||
add_vertex(x, y, 0, r, colour);
|
||||
}
|
||||
else if (mode == MODE_ATTACK)
|
||||
{
|
||||
Vertex* v = vertex_at(x, y, 0);
|
||||
break;
|
||||
case MODE_ATTACK:
|
||||
if (v == NULL || dynamic_cast<GameVertex*>(v)->player == turn) return;
|
||||
if (v->colour != colour) attack_vertex(v);
|
||||
break;
|
||||
case MODE_MOVE:
|
||||
if (current == NULL) return;
|
||||
if (MathUtils::distance(current->x, current->y, current->z, x, y, 0)
|
||||
<= get_range())
|
||||
{
|
||||
current->x = x;
|
||||
current->y = y;
|
||||
toggle_turn();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user