private void displayPlayersPositions() { Map<Vector3f, Integer> playerPositions = gm.getMapManager().getBoard().getPlayerPositions(); Iterator it = playerPositions.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); Vector3f pos = (Vector3f) pairs.getKey(); Integer number = (Integer) pairs.getValue(); Box b = new Box(Vector3f.ZERO, 2.0f, 1.0f, 2.0f); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.randomColor()); geom.setMaterial(mat); geom.setLocalTranslation(pos.x, 0, pos.z); String geomName = "PLAYERMARKER"; geom.setName(geomName); geom.setUserData(geomName, pos); playerNodes.attachChild(geom); displayLocationName(number.toString(), new Vector3f(pos.x, 1, pos.z)); } }
private void displayMap() { MapManager mm = gm.getMapManager(); Board bord = mm.getBoard(); List<Location> locations = bord.getLocations(); if (locations != null && locations.size() > 0) { for (Location loc : locations) { Box b = new Box(Vector3f.ZERO, 2.0f, 0.2f, 2.0f); Geometry geom = new Geometry("Box", b); // Spatial geom = app.getAssetManager().loadModel("Models/Suzanne.j3o"); // Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); // mat.setBoolean("UseMaterialColors", true); // mat.setColor("Specular", ColorRGBA.White); // mat.setColor("Diffuse", ColorRGBA.White); // mat.setFloat("Shininess", 5f); // [1,128] Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Orange); geom.setMaterial(mat); geom.setLocalTranslation(loc.getX(), 1, loc.getY()); String geomName = "LOCATION_" + loc.getName(); geom.setName(geomName); geom.setUserData(geomName, loc); displayLocationName(loc.getName(), new Vector3f(loc.getX(), 1, loc.getY())); List<Transport> transports = loc.getTransports(); if (transports != null && transports.size() > 0) { for (Transport transport : transports) { if (transport.getTarget() != loc) { drawTransportLine(loc, transport.getTarget(), transport.getCost()); } } } locationNodes.attachChild(geom); } } }
private void displayOpenFarms() { Vector3f startPos = gm.getMapManager().getBoard().getFarmMarker(); List<Farm> farms = gm.getFarmManager().getOpenFarms(); float i = 0; for (Farm farm : farms) { Box b = new Box(Vector3f.ZERO, 1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); if (farm.getUsesResourceTypes().get(0) == Resource.CALF) { mat.setColor("Color", ColorRGBA.White); } else if (farm.getUsesResourceTypes().get(0) == Resource.CHICK) { mat.setColor("Color", ColorRGBA.Yellow); } else if (farm.getUsesResourceTypes().get(0) == Resource.LAMB) { mat.setColor("Color", ColorRGBA.Gray); } else if (farm.getUsesResourceTypes().get(0) == Resource.PIGLET) { mat.setColor("Color", ColorRGBA.Pink); } else if (farm.getUsesResourceTypes().get(0) == Resource.WILDLIFE) { mat.setColor("Color", ColorRGBA.Green); } else { mat.setColor("Color", ColorRGBA.Red); } geom.setMaterial(mat); geom.setLocalTranslation(startPos.x + i, 1, startPos.z + 10); String geomName = "FARM_" + farm.getCost().toString(); geom.setName(geomName); geom.setUserData(geomName, farm); openFarmNodes.attachChild(geom); displayLocationName( farm.getCost().toString(), new Vector3f(startPos.x + i, 1, startPos.z + 10)); i += 5; } }
private void displayResourceMarket() { Resource chickenRes = new Resource(Resource.CHICK); Resource lambRes = new Resource(Resource.LAMB); Resource pigRes = new Resource(Resource.PIGLET); Resource calfRes = new Resource(Resource.CALF); Vector3f startPos = gm.getMapManager().getBoard().getResourceMarker(); int currentStockChickens = gm.getResourceManager().getCurrentStockChickens(); for (int i = 0; i < currentStockChickens; i++) { Box b = new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Yellow); geom.setMaterial(mat); geom.setLocalTranslation(startPos.x + (i * 2), 1, startPos.z); String geomName = "RESOURCE_" + Resource.CHICK + "_" + (i + 1); geom.setName(geomName); geom.setUserData(geomName, chickenRes); resourceNodes.attachChild(geom); } int currentStockLambs = gm.getResourceManager().getCurrentStockLambs(); for (int i = 0; i < currentStockLambs; i++) { Box b = new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Gray); geom.setMaterial(mat); geom.setLocalTranslation(startPos.x + (i * 2), 1, startPos.z + 2); String geomName = "RESOURCE_" + Resource.LAMB + "_" + (i + 1); geom.setName(geomName); geom.setUserData(geomName, lambRes); resourceNodes.attachChild(geom); } int currentStockPiglets = gm.getResourceManager().getCurrentStockPiglets(); for (int i = 0; i < currentStockPiglets; i++) { Box b = new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Pink); geom.setMaterial(mat); geom.setLocalTranslation(startPos.x + (i * 2), 1, startPos.z + 4); String geomName = "RESOURCE_" + Resource.PIGLET + "_" + (i + 1); geom.setName(geomName); geom.setUserData(geomName, pigRes); resourceNodes.attachChild(geom); } int currentStockCalfs = gm.getResourceManager().getCurrentStockCalfs(); for (int i = 0; i < currentStockCalfs; i++) { Box b = new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.White); geom.setMaterial(mat); geom.setLocalTranslation(startPos.x + (i * 2), 1, startPos.z + 6); String geomName = "RESOURCE_" + Resource.CALF + "_" + (i + 1); geom.setName(geomName); geom.setUserData(geomName, calfRes); resourceNodes.attachChild(geom); } }