private void moveUnit(int id, int x, int y) { //basically like the right click function //moves unit of unit id to location if (x >= 0 && x < gameData.mapW && y >= 0 && y < gameData.mapH) //we are within bounds { if (gameData.isTree(x, y)) //we came into this if case because peasanto on tree { //so set tree as target allUnits[playerNum][id].target.owner = 0; //set tree owner to nature allUnits[playerNum][id].target.index = -1; //set to tree index allUnits[playerNum][id].target.x = x; allUnits[playerNum][id].target.y = y; } else { allUnits[playerNum][id].target = gameData.target(allUnits, x, y, allUnits[playerNum][id], 0); //set the (normal) target (if any) } allUnits[playerNum][id].xToGo = x; allUnits[playerNum][id].xToGo = y; allUnits[playerNum][id].findNearestOpenSpot(allUnits, ref gameData); allUnits[playerNum][id].onCommand = true; } }