public void turn(String lr) { myTile = myLogic.getTile(x, y); if (lr.ToLower().Equals("left")) { if (dir == 0) { dir = 5; } else { dir--; } } else if (lr.ToLower().Equals("right")) { if (dir == 5) { dir = 0; } else { dir++; } } if (colour.ToLower().Equals("red")) { myLogic.loadTile(x, y, myLogic.texAntsOnHillRed[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } else if (colour.ToLower().Equals("black")) { myLogic.loadTile(x, y, myLogic.texAntsOnHillBlack[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } }
public void move() { myTile = myLogic.getTile(x, y); if (sense("ahead").getRocky() == false && sense("ahead").getAnt() == false) { if (myTile.getFood()) { myLogic.loadTile(x, y, myLogic.texTileFood, myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), false, null); } else if (myTile.getAntHill()) { if (myTile.getColour().Equals(this.colour)) { if (colour.ToLower().Equals("red")) { myLogic.loadTile(x, y, myLogic.texAntHillRed, myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), false, "red"); } else if (colour.ToLower().Equals("black")) { myLogic.loadTile(x, y, myLogic.texAntHillBlack, myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), false, "black"); } } else { if (colour.ToLower().Equals("red")) { myLogic.loadTile(x, y, myLogic.texAntHillBlack, myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), false, "black"); } else if (colour.ToLower().Equals("black")) { myLogic.loadTile(x, y, myLogic.texAntHillRed, myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), false, "red"); } } } else { myLogic.loadTile(x, y, myLogic.texTileBlank, myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), false, null); } switch (dir) { case 0: x++; break; case 1: if (y % 2 == 0) { y++; } else { x++; y++; } break; case 2: if (y % 2 == 0) { x--; y++; } else { y++; } break; case 3: x--; break; case 4: if (y % 2 == 0) { x--; y--; } else { y--; } break; case 5: if (y % 2 == 0) { y--; } else { x++; y--; } break; } Tile oldTile = myTile; myTile = myLogic.getTile(x, y); if (colour.ToLower().Equals("red")) { if (myTile.getFood()) { myLogic.loadTile(x, y, myLogic.texAntsOnFoodRed[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } else if (myTile.getAntHill()) { if (myTile.getColour().Equals(this.colour)) { myLogic.loadTile(x, y, myLogic.texAntsOnHillRed[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } else { myLogic.loadTile(x, y, myLogic.texAntsOnHillRed[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, oldTile.getColour()); } } else { myLogic.loadTile(x, y, myLogic.texAntsBlankRed[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } } else if (colour.ToLower().Equals("black")) { if (myTile.getFood()) { myLogic.loadTile(x, y, myLogic.texAntsOnFoodBlack[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } else if (myTile.getAntHill()) { myLogic.loadTile(x, y, myLogic.texAntsOnHillBlack[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } else { myLogic.loadTile(x, y, myLogic.texAntsBlankBlack[dir], myLogic.spriteBatch, myTile.getRocky(), myTile.getAntHill(), myTile.getFood(), myTile.getNumFood(), true, colour); } } } }