public void showAlert() { ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(3000); Log.v("Zomdroid", "Notification: " + GameEngine.getInstance().notifications); Intent i = new Intent(this, Notifications.class); i.putExtra("notifcations", GameEngine.getInstance().notifications); startActivity(i); GameEngine.getInstance().notifications = ""; GameEngine.getInstance().stateChanged = false; }
/** Updates the map view with all zombies and humans */ public void run() { Log.d(ZomDroid.TAG, "Running VicinityTask"); UsersOverlay humanOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.humanmark)); UsersOverlay infectedOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.infectedmark)); UsersOverlay zombieOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.zombiemark)); UsersOverlay medicOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.medicmark)); UsersOverlay hospitalOverlay = new UsersOverlay( VicinityMap.this, getApplicationContext().getResources().getDrawable(R.drawable.hospitalmark)); for (Player player : GameEngine.getInstance().getPlayers()) { Double gpx = Double.valueOf(Location.convert(player.gpx, Location.FORMAT_DEGREES)) * 1E6; Double gpy = Double.valueOf(Location.convert(player.gpy, Location.FORMAT_DEGREES)) * 1E6; Log.d(ZomDroid.TAG, "gpx=" + gpx.intValue() + ", gpy=" + gpy.intValue()); OverlayItem item = new OverlayItem( new GeoPoint(gpx.intValue(), (gpy.intValue())), player.id, player.zhType); if (player.zhType.equals(GameEngine.HUMAN)) humanOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.INFECTED)) infectedOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.ZOMBIE)) zombieOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.MEDIC)) medicOverlay.addOverlay(item); else if (player.zhType.equals(GameEngine.HOSPITAL)) hospitalOverlay.addOverlay(item); if (GameEngine.getInstance().stateChanged) showAlert(); } synchronized (GameEngine.getInstance()) { List<Overlay> overlays = map.getOverlays(); overlays.clear(); if (humanOverlay.size() > 0) overlays.add(humanOverlay); if (infectedOverlay.size() > 0) overlays.add(infectedOverlay); if (zombieOverlay.size() > 0) overlays.add(zombieOverlay); if (medicOverlay.size() > 0) overlays.add(medicOverlay); map.postInvalidate(); } }