Package com.jcloisterzone.ui.grid.layer

Source Code of com.jcloisterzone.ui.grid.layer.BarnAreaLayer

package com.jcloisterzone.ui.grid.layer;

import java.awt.geom.Area;
import java.util.Map;
import java.util.Set;

import com.jcloisterzone.action.BarnAction;
import com.jcloisterzone.board.Location;
import com.jcloisterzone.board.Position;
import com.jcloisterzone.board.Tile;
import com.jcloisterzone.board.pointer.FeaturePointer;
import com.jcloisterzone.ui.grid.ActionLayer;
import com.jcloisterzone.ui.grid.GridPanel;

public class BarnAreaLayer extends AbstractAreaLayer implements ActionLayer<BarnAction> {

    private BarnAction action;

    public BarnAreaLayer(GridPanel gridPanel) {
        super(gridPanel);
    }

    @Override
    protected Map<Location, Area> prepareAreas(Tile tile, Position p) {
        //quick fix
        if (getGame().getCurrentTile().getPosition().equals(p)) {
            Set<Location> locations = action.getLocations(p);
            return getClient().getResourceManager().getBarnTileAreas(tile, getSquareSize(), locations);
        }
        return null;
    }

    @Override
    protected void performAction(Position pos, Location selected) {
        action.perform(getClient().getServer(), new FeaturePointer(pos, selected));
    }

    @Override
    public void setAction(boolean active, BarnAction action) {
        this.action = action;
        setActive(active);
    }

    @Override
    public BarnAction getAction() {
        return action;
    }

}
TOP

Related Classes of com.jcloisterzone.ui.grid.layer.BarnAreaLayer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.