@Override public void updatePosition() { if (xPos < xDestination) xPos++; else if (xPos > xDestination) xPos--; if (yPos < yDestination) yPos++; else if (yPos > yDestination) yPos--; if (xPos == xDestination && yPos == yDestination) { if (command != state.NoCommand) { role.msgActionComplete(); command = state.NoCommand; } } }
@Override public void draw(Graphics2D g) { if (xPos > xDestination) { g.drawImage(marketRoleLeft, xPos, yPos, null); } else if (xPos < xDestination) { g.drawImage(marketRoleRight, xPos, yPos, null); } else if (yPos > yDestination) { g.drawImage(marketRoleUp, xPos, yPos, null); } else if (yPos < yDestination) { g.drawImage(marketRoleDown, xPos, yPos, null); } else { g.drawImage(marketRoleDown, xPos, yPos, null); } info = role.getPersonAgent().getName(); g.setColor(Color.magenta); g.drawString(info, xPos, yPos); }