Esempio n. 1
0
 //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);
 }
Esempio n. 2
0
        //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);
                }
            }
        }
Esempio n. 3
0
 public TeamPin(Team team, MapSectionPage mapSection, TeamPin parentPin) : this(team, mapSection)
 {
     this.parentPin = parentPin;
 }
Esempio n. 4
0
        //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;
                }
            }
        }