Skip to content
Snippets Groups Projects
Commit 3cbd15a9 authored by Susan Yuen's avatar Susan Yuen
Browse files

Unit now moves upon being selected first.

parent 813a8c28
No related branches found
No related tags found
No related merge requests found
......@@ -42,8 +42,8 @@ namespace Model
public Node getNode(Vector2 pixelCoordinates)
{
int x = (int) Math.Round(pixelCoordinates.X / 32);
int y = (int) Math.Round(pixelCoordinates.Y / 32);
int x = (int) Math.Floor(pixelCoordinates.X / 32);
int y = (int) Math.Floor(pixelCoordinates.Y / 32);
return nodes[x, y];
}
......
......@@ -29,7 +29,9 @@ namespace Controller
if (!endNode.getIsObstacle())
{
// update the unit's position to the clicked position
gameFunction.getSelectedUnit().setPixelCoordinates(position);
int positionX = (int) Math.Floor(position.X / 32);
int positionY = (int)Math.Floor(position.Y / 32);
gameFunction.getSelectedUnit().setPosition(positionX, positionY);
gameFunction.setPlayableUnitSelected(false);
gameFunction.setSelectedUnit(null);
}
......@@ -57,8 +59,8 @@ namespace Controller
Unit unit = currentPlayer.getUnits().ElementAt(i);
int unitX = unit.getPosition().Item1;
int unitY = unit.getPosition().Item2;
int clickedX = (int) Math.Round(positionClicked.X);
int clickedY = (int) Math.Round(positionClicked.Y);
int clickedX = (int) Math.Floor(positionClicked.X / 32);
int clickedY = (int) Math.Floor(positionClicked.Y / 32);
if (unitX == clickedX && unitY == clickedY)
{
return unit;
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment