Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Merge pull request #14 into master #15

Merged
merged 1 commit into from

1 participant

Kyle Rogers
Kyle Rogers
Owner

No description provided.

Kyle Rogers rogerskw merged commit 100f358 into from
Kyle Rogers rogerskw deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 6, 2014
  1. Merged pull request #14

    authored
This page is out of date. Refresh to see the latest.
27 CoDLaserTag/nb-configuration.xml
View
@@ -1,23 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-shared-configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--->
- <spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
- <word>config</word>
- </spellchecker-wordlist>
- <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
+-->
+ <spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
+ <word>config</word>
+ </spellchecker-wordlist>
+ <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
--->
- <netbeans.hint.j2eeVersion>1.7-web</netbeans.hint.j2eeVersion>
- <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
- <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
- </properties>
-</project-shared-configuration>
+-->
+ <netbeans.hint.j2eeVersion>1.7-web</netbeans.hint.j2eeVersion>
+ <org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
+ <org-netbeans-modules-projectapi.jsf_2e_language>Facelets</org-netbeans-modules-projectapi.jsf_2e_language>
+ <netbeans.hint.jdkPlatform>JDK_1.7</netbeans.hint.jdkPlatform>
+ </properties>
+</project-shared-configuration>
110 CoDLaserTag/src/main/java/edu/miamioh/ece/codlasertag/game/Team.java
View
@@ -1,54 +1,56 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package edu.miamioh.ece.codlasertag.game;
-
-import java.util.Set;
-import java.util.Collection;
-import edu.miamioh.ece.codlasertag.player.Player;
-import java.util.HashSet;
-
-/**
- *
- * @author kylerogers
- */
-public class Team {
- private final Set<Player> players;
- private String name;
-
- public Team(String name) {
- this.name = name;
- players = new HashSet<>();
- }
-
- public Team(String name, Collection<Player> initialPlayers) {
- this.name = name;
- this.players = new HashSet<>();
- for (Player player : initialPlayers) {
- this.players.add(player);
- }
- }
-
- public int size() {
- return players.size();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void addPlayer(Player p) {
- players.add(p);
- }
-
- public void removePlayer(Player p) {
- players.remove(p);
- }
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package edu.miamioh.ece.codlasertag.game;
+
+import java.util.Set;
+import java.util.Collection;
+import edu.miamioh.ece.codlasertag.player.Player;
+import java.util.HashSet;
+
+/**
+ *
+ * @author kylerogers
+ */
+public class Team {
+ //For now set to public,
+ public Set<Player> players;
+ private String name;
+
+ public Team(String name) {
+ this.name = name;
+ players = new HashSet<>();
+ }
+
+ public Team(String name, Collection<Player> initialPlayers) {
+ this.name = name;
+ this.players = new HashSet<>();
+ for (Player player : initialPlayers) {
+ this.players.add(player);
+ }
+ }
+
+ public int size() {
+ return players.size();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void addPlayer(Player p) {
+ players.add(p);
+ }
+
+ public void removePlayer(Player p) {
+ players.remove(p);
+ }
+
+}
149 CoDLaserTag/src/main/java/edu/miamioh/ece/codlasertag/game/gametypes/HumansVsZombiesGame.java
View
@@ -1,43 +1,106 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package edu.miamioh.ece.codlasertag.game.gametypes;
-
-import edu.miamioh.ece.codlasertag.game.Game;
-import edu.miamioh.ece.codlasertag.game.Team;
-
-/**
- *
- * @author kylerogers
- */
-public class HumansVsZombiesGame extends Game {
-
- public static final String ZOMBIES = "zombies";
- public static final String HUMANS = "humans";
- public static final String GAME_TYPE = "Humans Vs Zombies";
-
- public HumansVsZombiesGame(String gameName) {
- this.teams.put(ZOMBIES, new Team(ZOMBIES));
- this.teams.put(HUMANS, new Team(HUMANS));
- super.gameName = gameName;
- }
-
- @Override
- protected void updateGame() {
-
- }
-
- @Override
- protected String getGameTypeName() {
- return GAME_TYPE;
- }
-
- @Override
- protected String getName() {
- return gameName;
- }
-
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+
+package edu.miamioh.ece.codlasertag.game.gametypes;
+
+import java.util.*;
+import edu.miamioh.ece.codlasertag.game.Game;
+import edu.miamioh.ece.codlasertag.game.Team;
+import edu.miamioh.ece.codlasertag.player.Player;
+import edu.miamioh.ece.codlasertag.player.Coordinates;
+
+/**
+ *
+ * @author kylerogers
+ */
+public class HumansVsZombiesGame extends Game {
+
+ public static final String ZOMBIES = "zombies";
+ public static final String HUMANS = "humans";
+ public static final int RATIO = 1/6;
+ public static final double CHECK_DISTANCE = 10.0; //In Meters
+ public static final String GAME_TYPE = "Humans vs Zombies";
+
+ public HumansVsZombiesGame(String gameName) {
+ this.teams.put(ZOMBIES, new Team(ZOMBIES));
+ this.teams.put(HUMANS, new Team(HUMANS));
+ super.gameName = gameName;
+ }
+
+ @Override
+ protected void updateGame() {
+ if(gameOver()){
+ //DO SOMETHING HERE TO STOP GAME
+ }
+ checkDistance();
+ }
+
+ void checkDistance(){
+ for(Iterator it = teams.get(ZOMBIES).players.iterator(); it.hasNext(); ){
+ Player tempZombie = (Player)it.next();
+ Coordinates tempZombieCoor = tempZombie.getCoord();
+ for(Iterator it2 = teams.get(HUMANS).players.iterator(); it2.hasNext();){
+ Player tempHuman = (Player)it.next();
+ Coordinates tempHumanCoor = tempHuman.getCoord();
+ double distanceAway = gps2m(tempZombieCoor.getLatitude(),tempZombieCoor.getLongitude(),
+ tempHumanCoor.getLatitude(),tempHumanCoor.getLongitude());
+ if(distanceAway < CHECK_DISTANCE){
+ teams.get(ZOMBIES).addPlayer(tempHuman);
+ teams.get(HUMANS).removePlayer(tempHuman);
+ }
+ }
+ }
+ }
+
+ boolean gameOver(){
+ if(teams.get(HUMANS).players.isEmpty()){
+ return true;
+ }else{
+ return false;
+ }
+ }
+
+ private double gps2m(double lat_a, double lng_a, double lat_b, double lng_b) {
+ double pk = (double) (180/3.14169);
+
+ double a1 = lat_a / pk;
+ double a2 = lng_a / pk;
+ double b1 = lat_b / pk;
+ double b2 = lng_b / pk;
+
+ double t1 = Math.cos(a1)*Math.cos(a2)*Math.cos(b1)*Math.cos(b2);
+ double t2 = Math.cos(a1)*Math.sin(a2)*Math.cos(b1)*Math.sin(b2);
+ double t3 = Math.sin(a1)*Math.sin(b1);
+ double tt = Math.acos(t1 + t2 + t3);
+
+ return 6366000*tt;
+}
+// see http://androidsnippets.com/distance-between-two-gps-coordinates-in-meter
+
+ //Fow now uses a simple ratio defined as a constant above, RATIO.
+ @Override
+ protected void assignTeam(edu.miamioh.ece.codlasertag.player.Player player){
+ if(teams.get(HUMANS).size() != 0 && (double)teams.get(ZOMBIES).size()/(double)teams.get(HUMANS).size() < RATIO){
+ player.setTeam(ZOMBIES);
+ teams.get(ZOMBIES).addPlayer(player);
+ }else{
+ player.setTeam(HUMANS);
+ teams.get(HUMANS).addPlayer(player);
+ }
+ }
+
+ @Override
+ protected String getGameTypeName() {
+ return GAME_TYPE;
+ }
+
+ @Override
+ protected String getName() {
+ return gameName;
+ }
+}
Something went wrong with that request. Please try again.