|
|
Line 9: |
Line 9: |
| |- | | |- |
| |} | | |} |
− |
| |
− |
| |
− |
| |
− | /**
| |
− | * This is used for gathering Clay or grass.
| |
− | * Find some clay or grass, choose "New Clay", place your mouse over a red area of the clay icon, and hit enter.
| |
− | *
| |
− | * @McArine
| |
− | * @23/02-2008
| |
− | */
| |
− | import java.awt.Robot;
| |
− | import java.awt.MouseInfo;
| |
− | import java.awt.AWTException;
| |
− |
| |
− | public class Grass
| |
− | {
| |
− | private int xClay;
| |
− | private int yClay;
| |
− | private int xPos;
| |
− | private int yPos;
| |
− | private int loop;
| |
− | private int nbloop;
| |
− | private int north;
| |
− | private int south;
| |
− | private int west;
| |
− | private int east;
| |
− | private int colorClay;
| |
− | private int i;
| |
− | private Robot robot;
| |
− | private Functions functions;
| |
− |
| |
− | public Grass()
| |
− | {
| |
− | try {
| |
− | robot = new Robot();
| |
− | }
| |
− | catch (AWTException awte) {
| |
− | System.out.println("The Robot was not initialized "+awte + "\n");
| |
− | }
| |
− | functions = new Functions(robot);
| |
− | xClay = MouseInfo.getPointerInfo().getLocation().x;
| |
− | yClay = MouseInfo.getPointerInfo().getLocation().y;
| |
− | xPos = 960;
| |
− | yPos = 540;
| |
− | loop = 1;
| |
− | nbloop = 100;
| |
− |
| |
− | i = 1;
| |
− | colorClay = robot.getPixelColor(xClay, yClay).getRGB();
| |
− |
| |
− | while (loop < nbloop) {
| |
− | /** Going North
| |
− | *
| |
− | */
| |
− | i = 1;
| |
− | while (i < 10 ) {
| |
− | if (colorClay == robot.getPixelColor(xClay, yClay).getRGB()) {
| |
− | functions.PressButton(xClay, yClay);
| |
− | robot.delay(20);
| |
− |
| |
− | functions.PressButton(xPos,yPos -70);
| |
− | robot.delay(500);
| |
− | loop = loop + 1;
| |
− | }
| |
− | else {
| |
− | functions.PressButton(xPos,yPos -70);
| |
− | robot.delay(500);
| |
− | robot.delay(50);
| |
− | }
| |
− | i=i+1;
| |
− | }
| |
− | /** Going west
| |
− | *
| |
− | */
| |
− | i = 1;
| |
− | while (i <10 ) {
| |
− | if (colorClay == robot.getPixelColor(xClay, yClay).getRGB()) {
| |
− | functions.PressButton(xClay, yClay);
| |
− | robot.delay(20);
| |
− |
| |
− | functions.PressButton(xPos-70,yPos);
| |
− | robot.delay(500);
| |
− | loop = loop + 1;
| |
− | }
| |
− | else {
| |
− | functions.PressButton(xPos-70,yPos);
| |
− | robot.delay(500);
| |
− | robot.delay(50);
| |
− | }
| |
− | i=i+1;
| |
− | }
| |
− | /** Going south
| |
− | *
| |
− | */
| |
− | i = 1;
| |
− | while (i <10 ) {
| |
− | if (colorClay == robot.getPixelColor(xClay, yClay).getRGB()) {
| |
− | functions.PressButton(xClay, yClay);
| |
− | robot.delay(20);
| |
− |
| |
− | functions.PressButton(xPos,yPos+70);
| |
− | robot.delay(500);
| |
− | loop = loop + 1;
| |
− | }
| |
− | else {
| |
− | functions.PressButton(xPos,yPos+70);
| |
− | robot.delay(500);
| |
− | robot.delay(50);
| |
− | }
| |
− | i=i+1;
| |
− | }
| |
− | /** Going east
| |
− | *
| |
− | */
| |
− | i = 1;
| |
− | while (i < 10 ) {
| |
− | if (colorClay == robot.getPixelColor(xClay, yClay).getRGB()) {
| |
− | functions.PressButton(xClay, yClay);
| |
− | robot.delay(20);
| |
− |
| |
− | functions.PressButton(xPos+70,yPos);
| |
− | robot.delay(500);
| |
− | loop = loop + 1;
| |
− | }
| |
− | else {
| |
− | functions.PressButton(xPos+70,yPos);
| |
− | robot.delay(500);
| |
− | robot.delay(50);
| |
− | }
| |
− | i=i+1;
| |
− | }
| |
− | }
| |
− |
| |
− | }
| |
− | }
| |