//Change the status to what the user has chosen private void ChangeStatus_Click(object sender, RoutedEventArgs e) { MenuItem menuItem = (MenuItem)sender; team.setStatus(getMenuItemStatus(menuItem)); //Clearing the arrow if the team got to where they are going if (getMenuItemStatus(menuItem).Equals("available") || getMenuItemStatus(menuItem).Equals("intervening")) { RemoveArrow(); } //Handling the case when the user sets the status of a team to intervening if (getMenuItemStatus(menuItem).Equals("intervening")) { //Handling the case of when the user sets a team to intervening but it is not assigned to an intervention yet. Create the new intervention and assign the team to it. if (interventionPin == null) { Intervention intervention = new Intervention(); //Getting references to the new team and intervention pins TeamPin teamPin = null; //Need to get a reference to the new teamPin and not use "this" because the map has been redrawn upon the intervention creation, i.e. this TeamPin is outdated InterventionPin relatedInterventionPin = null; foreach (Pin pin in pinList) { if (pin.relatedObject == team) { teamPin = (TeamPin)pin; } if (pin.relatedObject == intervention) { relatedInterventionPin = (InterventionPin)pin; break; } } //Setting the position of the intervention to be the position of the team and calling collision detection on the teamPin for the team to be added to the intervention relatedInterventionPin.setPinPosition(teamPin.getX(), teamPin.getY()); teamPin.CollisionDetectionAndResolution(false); relatedInterventionPin.getIntervention().InterveningTeamArrived(team); } else { //Set team as "In position" on the intervention interventionPin.getIntervention().InterveningTeamArrived(team); } } }
//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); }