[virtualcommons-svn] SF.net SVN: virtualcommons:[495] foraging/trunk/src/main/java/edu/asu/ commons
Status: Beta
Brought to you by:
alllee
From: <db...@us...> - 2010-03-26 23:42:35
|
Revision: 495 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=495&view=rev Author: dbarge Date: 2010-03-26 23:42:28 +0000 (Fri, 26 Mar 2010) Log Message: ----------- This code version has following improvement Earlier the token statistics and artifacts were displayed at the top right corner of the screen for all the players. The present changes consider the field of vision and display the token statistics of only those players seen within the field of vision while the statistics of other players is not displayed Modified Paths: -------------- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java foraging/trunk/src/main/java/edu/asu/commons/foraging/model/TreatmentType.java Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2010-03-25 21:22:19 UTC (rev 494) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/client/GameWindow2D.java 2010-03-26 23:42:28 UTC (rev 495) @@ -400,16 +400,37 @@ StringBuilder builder = new StringBuilder("Tokens collected:"); // XXX: use this method so that we get the proper ordering of client ids/assigned numbers.. Map<Identifier, ClientData> clientDataMap = dataModel.getClientDataMap(); + + // To display the token artifacts only if the player lies in the + // field of vision + + Point clientPosition = dataModel.getCurrentPosition(); + for (Identifier id: dataModel.getAllClientIdentifiers()) { ClientData clientData = clientDataMap.get(id); String formatString = ""; if (id.equals(dataModel.getId())) { formatString = " [%d (you) : %d] "; + builder.append(String.format(formatString, clientData.getAssignedNumber(), clientData.getCurrentTokens())); } - else { - formatString = " [%d : %d] "; + else { + if(!dataModel.getRoundConfiguration().isFieldOfVisionEnabled()){ + formatString = " [%d : %d] "; + builder.append(String.format(formatString, clientData.getAssignedNumber(), clientData.getCurrentTokens())); + } + else { + double radius = dataModel.getRoundConfiguration().getViewSubjectsRadius(); + Circle fieldOfVision = new Circle(clientPosition, radius); + if(fieldOfVision.contains(clientData.getPosition())) { + formatString = " [%d : %d] "; + builder.append(String.format(formatString, clientData.getAssignedNumber(), clientData.getCurrentTokens())); + } + else { + formatString = " [%d : XX] "; + builder.append(String.format(formatString, clientData.getAssignedNumber())); + } + } } - builder.append(String.format(formatString, clientData.getAssignedNumber(), clientData.getCurrentTokens())); } return builder.toString(); } Modified: foraging/trunk/src/main/java/edu/asu/commons/foraging/model/TreatmentType.java =================================================================== --- foraging/trunk/src/main/java/edu/asu/commons/foraging/model/TreatmentType.java 2010-03-25 21:22:19 UTC (rev 494) +++ foraging/trunk/src/main/java/edu/asu/commons/foraging/model/TreatmentType.java 2010-03-26 23:42:28 UTC (rev 495) @@ -22,8 +22,8 @@ if (index < values().length && index >= 0) { return values()[index]; } - System.err.println("Returning LIMITEDVISION."); - return LIMITEDVISION; + System.err.println("Returning FULLVISION as default."); + return FULLVISION; // throw new IllegalArgumentException("No enforcement mechanism for index: " + index); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |