//Handle special collisions between a TeamPin and another pin internal override bool HandleSpecialCollisions(Pin fixedPin) { //SpecialCollision: Team is dropped on intervention, add team to intervention if (fixedPin.IsOfType("InterventionPin") && SufficientOverlap(fixedPin)) { interventionPin = (InterventionPin)fixedPin; interventionPin.getIntervention().AddInterveningTeam(team); if (parentPin != null) //Making sure that the intervention count of the parent team accounts for the interventions that the team fragment intervenes on { parentPin.getTeam().incrementInterventionCount(); } return(true); } //SpecialCollision: Collision detection between team and intervention container if (fixedPin.IsOfType("InterventionContainer")) { if (interventionPin != null && interventionPin.getInterveningTeamsPin().Contains(this)) { return(true); } } //If none of the conditions are true, return false return(false); }
//Handles special collisions between a Equipment and another pin internal override bool HandleSpecialCollisions(Pin fixedPin) { //SpecialCollision: Equipment is dropped on a team with sufficient overlap, add the equipment to the team if (fixedPin.IsOfType("TeamPin") && SufficientOverlap(fixedPin)) { TeamPin teamPin = (TeamPin)fixedPin; teamPin.getTeam().AddEquipment(equipment); equipment.setAssigned(true); return(true); } //If there are no special conditions return false return(false); }
//Places all the pins appropriately relatively to the InterventionPin public void PlaceAll() { //Determine the number of rows that the border is going to have with the interventionPin on top and then 2 teams per row int teamRows = 0; double height = ((double)interventionPin.getInterveningTeamsPin().Count) / 2; teamRows += (int)Math.Ceiling(height); this.Height = interventionPin.Height + (teamRows * TeamPin.size); //Determine the number of columns that the border is going to have, if more than one team than there will be two columns int columns = 1; if (interventionPin.getInterveningTeamsPin().Count() > 1) { columns = 2; } this.Width = columns * TeamPin.size; //Places a border around the intervention pin setBorderPosition(interventionPin.getX(), interventionPin.getY()); double Y = interventionPin.getY() + (InterventionPin.size / 2) + (TeamPin.size / 2); for (int i = 0; i < interventionPin.getInterveningTeamsPin().Count; i++) { TeamPin teamPin = interventionPin.getInterveningTeamsPin()[i]; if ((i % 2) == 0) //First item on line { if ((i + 1) == interventionPin.getInterveningTeamsPin().Count) //Single on the line { if (teamPin.gpsLocation != null && !teamPin.getTeam().getStatus().ToString().Equals("intervening") && destinationArrowDictionnary.ContainsKey(teamPin.getTeam()) && GPSLocation.gpsConfigured == true && GPSServices.connectedToServer && teamPin.gpsLocation.PhoneOnline()) { if (destinationArrowDictionnary[teamPin.getTeam()] != null) { destinationArrowDictionnary[teamPin.getTeam()].ChangeEnd(interventionPin.getX(), Y); } } else { teamPin.setPinPosition(interventionPin.getX(), Y); } } else //There's another item on the line { if (teamPin.gpsLocation != null && !teamPin.getTeam().getStatus().ToString().Equals("intervening") && destinationArrowDictionnary.ContainsKey(teamPin.getTeam()) && GPSLocation.gpsConfigured == true && GPSServices.connectedToServer && teamPin.gpsLocation.PhoneOnline()) { if (destinationArrowDictionnary[teamPin.getTeam()] != null) { destinationArrowDictionnary[teamPin.getTeam()].ChangeEnd(interventionPin.getX() - (TeamPin.size / 2), Y); } } else { teamPin.setPinPosition(interventionPin.getX() - (TeamPin.size / 2), Y); } } } else //Second item on the line { if (teamPin.gpsLocation != null && !teamPin.getTeam().getStatus().ToString().Equals("intervening") && destinationArrowDictionnary.ContainsKey(teamPin.getTeam()) && GPSLocation.gpsConfigured == true && GPSServices.connectedToServer && teamPin.gpsLocation.PhoneOnline()) { if (destinationArrowDictionnary[teamPin.getTeam()] != null) { destinationArrowDictionnary[teamPin.getTeam()].ChangeEnd(interventionPin.getX() + (TeamPin.size / 2), Y); } } else { teamPin.setPinPosition(interventionPin.getX() + (TeamPin.size / 2), Y); } Y += TeamPin.size; } } }