Ejemplo n.º 1
0
 public Elevator(ElevatorShaft _currentlyAt, int _HTEPerSecond) : base(_HTEPerSecond)
 {
     Simtype = SimType.Elevator;
     ChangeLocation(_currentlyAt);
     state            = State.Waiting;
     elevatorCalls    = new List <ElevatorCall>();
     peopleInElevator = new List <Entity>();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// sets new location off the elevator
        /// </summary>
        /// <param name="_currentlyAt">new location of the elevator</param>
        private void ChangeLocation(ElevatorShaft _currentlyAt)
        {
            currentlyAt = _currentlyAt;
            location    = currentlyAt.location;

            if (peopleInElevator != null)
            {
                foreach (Entity person in peopleInElevator.ToList())
                {
                    person.currentArea = _currentlyAt;
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// will tell the elevator to go to a given floor
 /// </summary>
 /// <param name="floor">floor to go to</param>
 private void GoToFloor(ElevatorShaft floor)
 {
     if (currentlyAt.ID < floor.ID)
     {
         MoveUp();
     }
     else if (currentlyAt.ID > floor.ID)
     {
         MoveDown();
     }
     else
     {
         state = State.Unload;
     }
 }
Ejemplo n.º 4
0
        public static Area createArea(string criteria, int ID, Point location, Point arrayLocation, int width, int height, int capacity, Timer HTETimer = null, Area[,] hotelArray = null, int classification = 0, Hotel hotel = null)
        {
            Area output = null;

            // moet nog aangepast worden -> factory filmpje vincent uitbreidbaardheid???
            switch (criteria)
            {
            // in layout file
            case "Room":
                output = new Room(ID, location, arrayLocation, width, height, classification);
                break;

            case "Cinema":
                output         = new Cinema(ID, location, arrayLocation, width, height);
                HTETimer.Tick += new EventHandler((output as Cinema).HTEElapsed);
                break;

            case "Restaurant":
                output = new Restaurant(ID, location, arrayLocation, width, height, capacity);
                break;

            case "Fitness":
                output = new Gym(ID, location, arrayLocation, width, height);
                break;

            case "Pool":
                output = new Pool(ID, location, arrayLocation, width, height);
                break;

            // niet in layout file
            case "Reception":
                output = new Reception(ID, location, arrayLocation, width, height, hotelArray, hotel);
                break;

            case "Stairwell":
                output = new Stairwell(ID, location, arrayLocation);
                break;

            case "ElevatorShaft":
                output = new ElevatorShaft(ID, location, arrayLocation);
                break;

            default:
                MessageBox.Show(criteria + " criteria was not found in the AreaFactory! waarschuw uw IT-beheerder.");
                break;
            }
            return(output);
        } // end createobject()
Ejemplo n.º 5
0
        /// <summary>
        /// Will give each area in the hotel the needed neighbours
        /// </summary>
        /// <param name="hotelArray">give the filled in hotel array</param>
        /// <param name="stairDistance">distance between stairs</param>
        /// <param name="elevatorDistance">speed between elevatorshafts</param>
        /// <returns></returns>
        private Area[,] AssignNeighboursToHotel(Area[,] hotelArray, double stairDistance, double elevatorDistance)
        {
            for (int i = 0; i < hotelWidth; i++)
            {
                for (int j = 0; j < hotelHeight; j++)
                {
                    // add top and bottom to elevatorshaft and add elevator

                    if (hotelArray[i, j] is ElevatorShaft)
                    {
                        // add elevator to elevatorshaft
                        ElevatorShaft current = hotelArray[i, j] as ElevatorShaft;
                        current.elevator = elevator;

                        // top and bottom to elevator
                        if (j > 0)
                        {
                            (hotelArray[i, j] as ElevatorShaft).bottom = new Neighbour()
                            {
                                neighbour = (ElevatorShaft)hotelArray[i, j - 1],
                                distance  = elevatorDistance
                            };
                        }
                        if (j < hotelHeight - 1)
                        {
                            (hotelArray[i, j] as ElevatorShaft).top = new Neighbour()
                            {
                                neighbour = (ElevatorShaft)hotelArray[i, j + 1],
                                distance  = elevatorDistance
                            };
                        }
                    }
                    // bij trappen top en bottom toevoegen
                    if (hotelArray[i, j] is Stairwell)
                    {
                        if (j > 0)
                        {
                            (hotelArray[i, j] as Stairwell).bottom = new Neighbour()
                            {
                                neighbour = (Stairwell)hotelArray[i, j - 1],
                                distance  = stairDistance
                            };
                        }
                        if (j < hotelHeight - 1)
                        {
                            (hotelArray[i, j] as Stairwell).top = new Neighbour()
                            {
                                neighbour = (Stairwell)hotelArray[i, j + 1],
                                distance  = stairDistance
                            };
                        }
                    }
                    // bij alle kamers left toevoegen
                    if (i > 0 && hotelArray[i, j] != null)
                    {
                        int count = 1;
                        while (hotelArray[i, j].left == null)
                        {
                            if (hotelArray[i - count, j] != null)
                            {
                                //left aanmaken
                                hotelArray[i, j].left = new Neighbour
                                {
                                    neighbour = hotelArray[i - count, j],
                                    distance  = count
                                };
                            }
                            else
                            {
                                if (count > hotelWidth + 1) // om oneindige loop te voorkomen
                                {
                                    MessageBox.Show($"Kamer afstand naar links bij kamer \"{hotelArray[i, j]}\" is groter dan de hotel breedte. Waarschuw uw IT-Beheer!");
                                    Application.Exit();
                                    break; // niet nodig maar ja
                                }
                                count++;
                            }
                        }
                    }
                    // bij alle kamers right toevoegen
                    if (i < hotelHeight && hotelArray[i, j] != null)
                    {
                        int count = 1;
                        while (hotelArray[i, j].right == null)
                        {
                            if (hotelArray[i + count, j] != null)
                            {
                                // right aanmaken
                                hotelArray[i, j].right = new Neighbour
                                {
                                    neighbour = hotelArray[i + count, j],
                                    distance  = count
                                };
                            }
                            else
                            {
                                if (count > hotelWidth + 1) // om oneindige loop te voorkomen
                                {
                                    MessageBox.Show($"Kamer afstand naar rechts bij kamer \"{hotelArray[i, j]}\" is groter dan de hotel breedte. Waarschuw uw IT-Beheer!");
                                    Application.Exit();
                                    break; // niet nodig maar ja
                                }
                                count++;
                            }
                        }
                    }
                }
            }
            return(hotelArray);
        }
Ejemplo n.º 6
0
        public override void move(int millisSinceLastFrame)
        {
            if (currentArea is ElevatorShaft && next is ElevatorShaft)
            { // when guest is going to use the elevator
                ElevatorShaft elevatorShaft = currentArea as ElevatorShaft;

                shaftToGoTo = null;
                foreach (Area item in path)
                {
                    if (item is ElevatorShaft)
                    {
                        shaftToGoTo = item as ElevatorShaft;
                    }
                }
                if (shaftToGoTo == null)
                {
                    shaftToGoTo = next as ElevatorShaft;
                }

                // check if guest is already in queue
                if (elevatorShaft.queue.Contains(this))
                {
                    // remove guest from queue to be added again
                    elevatorShaft.queue.Remove(this);
                }
                // guest is going into the elevator queue
                elevatorShaft.queue.Add(this);

                // call elevator
                Elevator.Directions dir;
                if (shaftToGoTo.ID > elevatorShaft.ID)
                {
                    dir = Elevator.Directions.Up;
                }
                else
                {
                    dir = Elevator.Directions.Down;
                }
                elevatorShaft.elevator.CallToFloor(new ElevatorCall(this, elevatorShaft, dir));

                // stop guest from moving
                path        = null;
                next        = null;
                interacting = true;
            }
            else
            {
                if (eventLocation != null)
                {
                    ChangeDestination(eventLocation);
                    eventLocation = null;
                }
                if (!interacting)
                {
                    if (next == null || location == next.entrance)
                    {
                        if (next != null)
                        {
                            currentArea = next;
                        }
                        if (IsNullOrEmpty(path))
                        {
                            if (currentArea == destination)
                            {
                                Interact();
                            }
                        }
                        if (!IsNullOrEmpty(path))
                        {
                            next = path.First();
                            if ((currentArea is Stairwell && next is Stairwell))
                            {
                                timeLeftForRoom = vertilcalDuration;
                            }
                            else
                            {
                                if (currentArea.left != null && currentArea.left.neighbour == next)
                                {
                                    timeLeftForRoom = currentArea.left.distance * horizontalDuration;
                                    //timeLeftForRoom = horizontalDuration * next.width;
                                }
                                else
                                {
                                    timeLeftForRoom = currentArea.right.distance * horizontalDuration;
                                    //timeLeftForRoom = horizontalDuration * currentArea.width;
                                }
                            }
                            path.RemoveAt(0);
                        }
                    }
                    else
                    {
                        Walk(millisSinceLastFrame);
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public ElevatorCall(Entity _entity, ElevatorShaft _floor, Elevator.Directions _direction)
 {
     floor     = _floor;
     direction = _direction;
     person    = _entity;
 }
Ejemplo n.º 8
0
        public Entity CreateEntity(string criteria, string name, int requestedClassification = 0, ElevatorShaft currentlyAt = null)
        {
            Entity output = null;

            switch (criteria)
            {
            case "Maid":
                output = new Maid(name, hotelArray, (int)config.RoomCleaningHTE, (int)config.StairDistanceHTE, (int)config.HtesPerSecond);
                break;

            case "Guest":
                output = new Guest(name, hotelArray, requestedClassification, (int)config.StairDistanceHTE, (int)config.HtesPerSecond, config.EatHTE);
                break;

            default:
                MessageBox.Show(criteria + " criteria was not found in the EntityFactory! waarschuw uw IT-beheerder.");
                break;
            } // end switch

            return(output);
        }