Search in sources :

Example 1 with FishColour

use of ca.hiphiparray.amazingmaze.FishCell.FishColour in project AmazingMaze by TheVirtualMachine.

the class Player method collectFish.

/** Handle the player collecting fish. */
private void collectFish() {
    Rectangle thisBox = getBoundingRectangle();
    for (int i = 0; i < maze.fishBoxes.size; i++) {
        if (thisBox.overlaps(maze.fishBoxes.get(i))) {
            TiledMapTileLayer layer = (TiledMapTileLayer) maze.map.getLayers().get(MapFactory.ITEM_LAYER);
            int x = (int) maze.fishBoxes.get(i).x;
            int y = (int) maze.fishBoxes.get(i).y;
            FishColour colour = ((FishCell) layer.getCell(x, y)).getColour();
            layer.setCell(x, y, null);
            maze.fishBoxes.removeIndex(i);
            switch(colour) {
                case BLUE:
                    blueCollected++;
                    break;
                case PURPLE:
                    purpleCollected++;
                    break;
                case GREEN:
                    greenCollected++;
                    break;
                case RED:
                    redCollected++;
                    break;
                case ORANGE:
                    orangeCollected++;
                    break;
            }
            break;
        }
    }
}
Also used : TiledMapTileLayer(com.badlogic.gdx.maps.tiled.TiledMapTileLayer) Rectangle(com.badlogic.gdx.math.Rectangle) FishColour(ca.hiphiparray.amazingmaze.FishCell.FishColour)

Aggregations

FishColour (ca.hiphiparray.amazingmaze.FishCell.FishColour)1 TiledMapTileLayer (com.badlogic.gdx.maps.tiled.TiledMapTileLayer)1 Rectangle (com.badlogic.gdx.math.Rectangle)1