Package resource

Examples of resource.Resource


        String yString = null;
        String typeString = null;
        String[] colorString = null;
        short x = -1;
        short y = -1;
        Resource resource = null;

        while (scanner.hasNextLine()) {
            line = scanner.nextLine();
            cellString = line.split("#")[0];
View Full Code Here


        Cell tmpCell = null;
        while (!clean) {
            short counter = -1;
            Set<Cell> surroundings = EnvironmentFunction.getSurroundings(grid, refCell, 1, params.getCols(), params.getRows(), false);
            for (Cell surrCell : surroundings) {
                Resource artResource = surrCell.getResource();
                if (artResource.getType() == ResourceConstants.ARTISTIC_TRACE_RESOURCE) {
                    counter++;
                    if (!surrCell.equals(refCell)) {
                        tmpCell = null;
                        tmpCell = new Cell(surrCell.getX(), surrCell.getY(), surrCell.getResource(), null);
                    }
View Full Code Here

            int oldX = getUnit().getCell().getX();
            int oldY = getUnit().getCell().getY();
            Cell cell = getUnit().move(getDnaParams().getSpecies(), downMove, rightMove, getProgenitor());
            if (oldX != cell.getX() || oldY != cell.getY()) {
                Color resultantColor = null;
                Resource resource = getUnit().getCell().getResource();
                int artisticType = resource.getType();
                if (artisticType == ResourceConstants.ARTISTIC_COLOR_RESOURCE) {
                    // colore dell'agente in RGB
                    Color agentColor = getDnaParams().getColor();
                    int redAgent = agentColor.getRed();
                    int greenAgent = agentColor.getGreen();
                    int blueAgent = agentColor.getBlue();
                    // colore dell'agente in HSB
                    float[] hsbvalsAgent = Color.RGBtoHSB(redAgent, greenAgent, blueAgent, null);
                    float hAgent = hsbvalsAgent[0];
                    float sAgent = hsbvalsAgent[1];
                    float bAgent = hsbvalsAgent[2];

                    // colore della risorsa in RGB
                    Color resourceColor = resource.getColor();
                    int redResource = resourceColor.getRed();
                    int greenResource = resourceColor.getGreen();
                    int blueResource = resourceColor.getBlue();
                    // colore della risorsa in HSB
                    float[] hsbvalsRes = Color.RGBtoHSB(redResource, greenResource, blueResource, null);
                    float hRes = hsbvalsRes[0];
                    float sRes = hsbvalsRes[1];
                    // avvicinamento del colore dell'agente al colore della cella
                    if (sRes > 0.5) {
                        float diff = hAgent - hRes;
                        if (Math.abs(diff) > 0.5f) {
                            hAgent += diff / 50f;
                        } else {
                            hAgent -= diff / 50f;
                        }
                        // normalizzazione
                        if (hAgent > 1f) {
                            hAgent = hAgent - 1f;
                        } else if (hAgent < 0f) {
                            hAgent = hAgent + 1f;
                        }
                    }

                    if (getParams().isHunger()) {
                        // si verifica se c'e' almeno un bordo nelle vicinanze
                        boolean nearBorder = false;
                        Set<Cell> surroundings = EnvironmentFunction.getSurroundings(getWorld().getGrid(), getUnit().getCell(), 5, getWorld().getParams().getCols(), getWorld().getParams().getRows(), false);
                        for (Cell c : surroundings) {
                            Resource artres = c.getResource();
                            if (artres.getType() == ResourceConstants.ARTISTIC_TRACE_RESOURCE) {
                                nearBorder = true;
                                break;
                            }
                        }
View Full Code Here

        if (isAlive()) {
            int oldX = getUnit().getCell().getX();
            int oldY = getUnit().getCell().getY();
            Cell cell = getUnit().move(getDnaParams().getSpecies(), downMove, rightMove, getProgenitor());
            if (oldX != cell.getX() || oldY != cell.getY()) {
                Resource resource = getUnit().getCell().getResource();
                int artisticType = resource.getType();
                if (artisticType == ResourceConstants.ARTISTIC_TRACE_RESOURCE) {
                    TraceResource traceResource = (TraceResource) resource;
                    traceResource.setColor(getInternalColor());
                    traceResource.setTracer(this.toString());
                    duplicate();
View Full Code Here

        int progenitor = agent.getProgenitor();
        guiWorld.killUnit(id, progenitor);
    }

    private Color getCellColor(Cell cell) {
        Resource resource = cell.getResource();
        Color color = null;
        color = resource.getColor();
        return color;
    }
View Full Code Here

TOP

Related Classes of resource.Resource

Copyright © 2018 www.massapicom. 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.