Example #1
0
        /// <summary>
        /// Checks how long it will take to use the Elevator and if it's more efficient to take the stairs instead.
        /// </summary>
        private void GetRoute()
        {
            //Has a better explenation in the "Project Hotel - Documentatie.docx" document
            Tuple <ElevatorDirection, int> ElevatorInfo = Hotel.Elevator.GetElevatorInfo().ToTuple();
            int ElevatorTime = 0;

            if (ElevatorInfo.Item1 == ElevatorDirection.IDLE)
            {
                if (ElevatorInfo.Item2 < PositionY)
                {
                    ElevatorTime += PositionY - ElevatorInfo.Item2;
                }
                else
                {
                    ElevatorTime += ElevatorInfo.Item2 - PositionY;
                }
            }
            else if (ElevatorInfo.Item1 == ElevatorDirection.UP)
            {
                if (ElevatorInfo.Item2 < PositionY)
                {
                    ElevatorTime += PositionY - ElevatorInfo.Item2;
                }
                else if (ElevatorInfo.Item2 > PositionY)
                {
                    ElevatorTime += Hotel.Floors.Length - ElevatorInfo.Item2;
                    ElevatorTime += Hotel.Floors.Length - PositionY;
                }
            }
            else if (ElevatorInfo.Item1 == ElevatorDirection.DOWN)
            {
                if (ElevatorInfo.Item2 < PositionY)
                {
                    ElevatorTime += ElevatorInfo.Item2;
                    ElevatorTime += PositionY;
                }
                else if (ElevatorInfo.Item2 > PositionY)
                {
                    ElevatorTime += ElevatorInfo.Item2 - PositionY;
                }
            }

            if (Destination != null)
            {
                if (Path.PathToElevatorLength + Path.PathFromElevatorLength + ElevatorTime < Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, false, true).PathLength)
                {
                    Path           = Graph.QuickestRoute(Graph.SearchNode(Hotel.Floors[PositionY].Areas[PositionX]), Destination, true, false);
                    Path.RouteType = ERouteType.Elevator;
                }
                else
                {
                    Path           = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, false, true);
                    Path.RouteType = ERouteType.Stairs;
                }
            }
        }
Example #2
0
        /// <summary>
        /// An event that's called everytime the HotelEventManager pushes out an HotelEvent.
        /// </summary>
        /// <param name="Event">The HotelEvent containing event information.</param>
        public void Notify(HotelEvent Event)
        {
            //If the Customer is currently Evacuating they shouldn't listen to any other Events
            if (Status != HotelEventType.EVACUATE)
            {
                //If the Customer needs to Evacuate
                if (Event.EventType == HotelEventType.EVACUATE)
                {
                    //The Customer's WaitingTime is set to 0 (they need to abandon all current tasks)
                    WaitingTime = 0;
                    //The Customer's Status is set to EVACUATE so other Events won't be triggered
                    Status = HotelEventType.EVACUATE;

                    //And they'll EVACUATE to the Reception
                    Destination = Hotel.Reception.Node;
                    Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);
                }
                //If the Customer needs to hit the gym
                else if (Event.EventType == HotelEventType.GOTO_FITNESS)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //The Customer's FitnessTime will be set to the one given inside the HotelEvent
                            FitnessTime = Data[1];

                            //The Customer's Destination is set to the nearest Gym
                            Destination = Graph.NearestFacility(Hotel.Floors[PositionY].Areas[PositionX].Node, EAreaType.Fitness);
                            Path        = Graph.QuickestRoute(Graph.SearchNode(Hotel.Floors[PositionY].Areas[PositionX]), Destination, true, true);

                            //The Customer's Status is set to GOTO_FITNESS
                            Status = HotelEventType.GOTO_FITNESS;
                        }
                    }
                }
                //If the Customer needs to check out
                else if (Event.EventType == HotelEventType.CHECK_OUT)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //If the Customer checks out, their Room will be Dirty and needs to be cleaned
                            AssignedRoom.Dirty();
                            //Their Room will be set to Avaiable (by saying that the Room doesn't have an owner)
                            AssignedRoom.RoomOwner = null;

                            //The Customer will go to the Reception (the Reception won't do anything with the Customer, they'll dissapear if they arrive)
                            Destination = Hotel.Reception.Node;
                            Path        = Graph.QuickestRoute(Graph.SearchNode(Hotel.Floors[PositionY].Areas[PositionX]), Destination, true, true);

                            //The Customer's Status is set to CHECK_OUT
                            Status = HotelEventType.CHECK_OUT;
                        }
                    }
                }
                //If the Customer wants to go to a Cinema to catch the new Shrek Movie
                else if (Event.EventType == HotelEventType.GOTO_CINEMA)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //The Customer will move to the nearest Cinema (relative to their Position)
                            Destination = Graph.NearestFacility(Hotel.Floors[PositionY].Areas[PositionX].Node, EAreaType.Cinema);
                            Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);

                            //The Customer's Status is set to GOTO_CINEMA
                            Status = HotelEventType.GOTO_CINEMA;
                        }
                    }
                }
                //If the Customer needs food
                else if (Event.EventType == HotelEventType.NEED_FOOD)
                {
                    //We will perform an extra check to see if it's aimed at a "Gast" (Customer)
                    if (Event.Data.Keys.First() == "Gast")
                    {
                        //If that's true, we will pull the int's from the HotelEvent Data Dictionairy
                        int[] Data = PullIntsFromString(Event.Data.Values.ToList());
                        //If the given ID is the same as the Customer's ID
                        if (ID == Data[0])
                        {
                            //The Customer will move to the nearest Cinema (relative to their Position)
                            Destination = Graph.NearestFacility(Hotel.Floors[PositionY].Areas[PositionX].Node, EAreaType.Restaurant);
                            Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);

                            //The Customer's Status is set to NEED_FOOD
                            Status = HotelEventType.NEED_FOOD;
                        }
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// The Customer gets a Path to certain location
 /// </summary>
 /// <param name="CurrentLocation">The Location from where the Customer must calculate the Quickest Route</param>
 public void MoveToLocation(IArea CurrentLocation)
 {
     Path = Graph.QuickestRoute(Graph.SearchNode(CurrentLocation), Graph.SearchNode(Destination.Area), true, true);
 }
Example #4
0
 /// <summary>
 /// Moves the Cleaner to their optimal position inside the Hotel.
 /// </summary>
 private void MoveToOptimalPosition()
 {
     Destination = Graph.SearchNode(Hotel.Floors[Hotel.Floors.Length / GlobalStatistics.Cleaners.Count * CleanerID].Areas[Hotel.Floors[0].Areas.Length / 2]);
     Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Graph.SearchNode(Hotel.Floors[Hotel.Floors.Length / GlobalStatistics.Cleaners.Count * CleanerID].Areas[Hotel.Floors[0].Areas.Length / 2]), true, true);
 }