Esempio n. 1
0
        public Form1(float hte, int cleaners, int cleaningTime, int movieDuration, int eatDuration, int elevatorDelay)
        {
            InitializeComponent();
            hotelStatus_label.Text = "Running";
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            _Hotel = Hotel.GetInstance();
            _Hotel.CreateElevator(elevatorDelay);
            _Hotel.SetCleaners(cleaners, cleaningTime);
            _Hotel.SetScreeningTime(movieDuration);
            _Hotel.EatDuration = eatDuration;
            var hel = new HEListener();

            Paint += DrawHotel;

            HotelEventManager.Register(hel);
            HTE_Factor = hte;
            HotelEventManager.HTE_Factor = HTE_Factor;


            Timer = new System.Timers.Timer(1000 / HotelEventManager.HTE_Factor)
            {
                Enabled = true
            };
            Timer.Start();
            Stopwatch = new Stopwatch();
            Stopwatch.Start();

            HotelEventManager.Start();

            Timer.Elapsed += TimerHandler;
            Console.WriteLine(Timer.Interval);

            KeyUp += SpacePress;
        }
Esempio n. 2
0
        }                                 // Currently timeing is handeld in guest, it should be moved to Cinema

        // This can be used to cap the cinema on its capicity

        /// <summary>
        /// The Amount of Viewers in the cinema
        /// </summary>
        // public List<IMovable> MovablesInCinema { get; set; } = new List<IMovable>();
        #endregion

        /// <summary>
        /// The AreaFactory creation method.
        /// This creates and initilizes a new IArea.
        /// </summary>
        /// <returns>A new Cinema</returns>
        public IArea CreateArea()
        {
            Cinema newCinema = new Cinema();

            HotelEventManager.Register(newCinema);
            return(newCinema);
        }
Esempio n. 3
0
 /// <summary>
 /// Register as an eventlistener
 /// </summary>
 public void RegisterAs()
 {
     if (!Registerd)
     {
         HotelEventManager.Register(this);
         Registerd = true;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Creates an receptionist that can work with the hotel
 /// </summary>
 /// <param name="position">The position of the receptionist</param>
 /// <param name="hotel">The hotel in which the receptionist is located</param>
 public Receptionist(Point position, Hotel hotel)
 {
     Position = position;
     Hotel    = hotel;
     Area     = hotel.GetArea(typeof(Reception));
     Status   = MovableStatus.IDLE;
     HotelEventManager.Register(this);
 }
Esempio n. 5
0
        /// <summary>
        /// Creates an instance of Reception with the given Parameters
        /// </summary>
        /// <param name="ID">ID of the Area</param>
        /// <param name="areaType">Type of Area</param>
        /// <param name="capacity">How many Humans can be in the Area at the same time</param>
        /// <param name="classification">The Classification of the Area</param>
        /// <param name="positionX">The horizontal point in the grid</param>
        /// <param name="positionY">The vertical point in the grid</param>
        /// <param name="width">The width of the Area</param>
        /// <param name="height">The height of the Area</param>
        public void Create(int ID, EAreaType areaType, int capacity, int classification, int positionX, int positionY, int width, int height)
        {
            this.ID   = ID;
            AreaType  = areaType;
            PositionX = positionX;
            PositionY = positionY;
            Width     = width;
            Height    = height;

            HotelEventManager.Register(this);
        }
Esempio n. 6
0
        public Simulation(List <LayoutJsonModel> layout, ConfigJsonModel ConfigJson)
        {
            InitializeComponent();
            // Setting form to fullscreen
            Rectangle resolution = Screen.PrimaryScreen.Bounds;

            this.Size        = resolution.Size;
            this.WindowState = FormWindowState.Maximized;

            // Placing Pauze panel on right location and hiding it
            panelPauze.Visible = false;
            double PauzeWidth  = resolution.Width * 0.20;
            double PauzeHeight = resolution.Height * 0.75;

            this.panelPauze.Size       = new Size((int)PauzeWidth, (int)PauzeHeight);
            this.panelPauze.Top        = (this.ClientSize.Height - panelPauze.Height) / 2;
            this.panelPauze.Left       = 10;
            this.labelGamePauzed.Width = this.panelPauze.Width;
            this.labelInfo.Width       = this.panelPauze.Width;
            this.labelInfo.Height      = this.panelPauze.Height - this.labelGamePauzed.Height;

            // initialize timer for hte
            timer.Tick += new EventHandler(OnTimedEvent);
            double MilisecondsPerHte = 1.0 / ConfigJson.HtesPerSecond;
            int    intervalOne       = Convert.ToInt32(MilisecondsPerHte * 1000); // van seconde milisecondes maken

            timer.Interval = (intervalOne >= 1) ? (int)intervalOne : 1;


            // initialize timer for frame updates
            frameTimer.Tick += new EventHandler(OnFrameTimerUpdate);
            int    FPS       = 60; // fps instelbaar
            double interval2 = (double)1000 / FPS;

            frameTimer.Interval = (interval2 >= 1) ? (int)interval2 : 1;

            // create hotel
            hotel = new Hotel(layout, ConfigJson, timer);
            hotel.Display(MainSimDisplay);
            hotel.hotelPB.Click += HotelPB_Click;
            hotel.AddMaid((int)ConfigJson.RoomCleaningHTE);
            hotel.AddMaid((int)ConfigJson.RoomCleaningHTE);

            // create eventmanager
            HotelEventManager.Register(new myEventListener(hotel));
            HotelEventManager.HTE_Factor = (int)ConfigJson.HtesPerSecond;

            // start simulation
            timer.Start();
            frameTimer.Start();
            sw.Start();
            HotelEventManager.Start();
        }
Esempio n. 7
0
        public Manager(IRoom[,] coordinates, int amountOfMaids, MainForm main)
        {
            HotelEventManager.HTE_Factor = 1.5f;
            this.main          = main;
            this.amountOfMaids = amountOfMaids;
            this.coordinates   = coordinates;
            GenerateMaids();

            HotelEventManager.Register(this);
            dijkstra.CreateGraph(coordinates);

            TempPerson temp     = new TempPerson();
            Customer   customer = new Customer(temp);
        }
Esempio n. 8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Exit the simulation if there is no layout path.
            if (ServiceLocator.Get <ConfigLoader>().GetConfig().LayoutPath == null)
            {
                Environment.Exit(0);
            }

            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Create new information window
            _informationWindow = new InformationWindow();

            // Make a new hotel.
            _hotel = new Hotel();

            // Register components to the roomfactory
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Room", new GuestRoomFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Empty", new EmptyRoomFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Lobby", new LobbyFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Cinema", new CinemaFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Restaurant", new CafeFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("ElevatorShaft", new ElevatorShaftFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Staircase", new StaircaseFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Fitness", new FitnessFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Pool", new PoolFactoryComponent());

            _hotel.BuildHotel();

            // Create other things.
            _camera             = new Camera(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
            _camera.Controlable = true;
            _closeUpCamera      = new Camera(200, 200);

            // Create the handlers and managers and start throwing events.
            HotelEventManager.Start();
            HotelEventHandler hotelEventHandler = new HotelEventHandler(_hotel);

            _listener = new EventListener(hotelEventHandler);
            HotelEventManager.Register(_listener);

            // Create a background.
            _background = new Sprite();
            _background.LoadSprite("Background");
            _background.SetPosition(new Point(0, 0));
            _background.SetSize(new Point(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight));
        }
Esempio n. 9
0
        /// <summary>
        /// Creating a maid to use in the hotel
        /// </summary>
        /// <param name="startLocation">The location in the hotel the maid is first put on after creation</param>
        /// <param name="hotel">The hotel the maid works in</param>
        public Maid(Point startLocation, Hotel hotel)
        {
            Hotel    = hotel;
            Position = startLocation;
            Area     = Hotel.GetArea(Position);

            Status = MovableStatus.IDLE;

            HotelEventManager.Register(this);

            Actions.Add(MovableStatus.IDLE, _IsSomthingInQueue);
            Actions.Add(MovableStatus.GOING_TO_ROOM, _GoToRoom);
            Actions.Add(MovableStatus.CLEANING, _Cleaning);
            Actions.Add(MovableStatus.ELEVATOR_REQUEST, _CallElevator);
            Actions.Add(MovableStatus.LEAVING_ELEVATOR, _LeavingElevator);
            Actions.Add(MovableStatus.WAITING_FOR_ELEVATOR, Idle);
            Actions.Add(MovableStatus.EVACUATING, _Evacuate);
            Actions.Add(MovableStatus.IN_ELEVATOR, null);
        }
Esempio n. 10
0
 /// <summary>
 /// imitialize hotelsimulation
 /// </summary>
 public HotelSimulation()
 {
     _roomQueue     = new Queue <Room>();
     _eventChecker  = new EventChecker();
     _huidigeCinema = new Cinema();
     _customers     = new List <Customer>();
     _reception     = new Reception();
     _hotel         = new Hotel();
     _simplePath    = new SimplePath();
     listener       = new EventListener();
     HotelEventManager.Register(listener);
     HotelEventManager.HTE_Factor = 4;
     HotelEventManager.Start();
     graphics = new GraphicsDeviceManager(this);
     //uncomment for fullscreen
     //graphics.IsFullScreen = true;
     //graphics.HardwareModeSwitch = false;
     _isPaused             = false;
     Content.RootDirectory = "Content";
 }
Esempio n. 11
0
        /// <summary>
        ///     Allows the game to perform any initialization it needs to before starting to run.
        ///     This is where it can query for any required services and load any non-graphic
        ///     related content.  Calling base.Initialize will enumerate through any components
        ///     and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            //add/create a new hotel
            hotel = new Hotel();

            //instantiate new listeners
            _checkInListener  = new CheckInListener(ref hotel);
            _checkOutListener = new CheckOutListener(ref hotel);

            //register listeners to HotelEventManager
            HotelEventManager.Register(_checkInListener);
            HotelEventManager.Register(_checkOutListener);

            //start HotelEventManager
            HotelEventManager.Start();

            this.IsMouseVisible = true;

            base.Initialize();
        }
Esempio n. 12
0
        /// <summary>
        /// Creates a function hotel
        /// </summary>
        /// <param name="layout">A file which contains a functioning layout</param>
        /// <param name="settings">The Settings for the simulation</param>
        /// <param name="TypeOfBuilder">A type of builder that can handle the provided file</param>
        public Hotel(List <JsonModel> layout, SettingsModel settings, IHotelBuilder TypeOfBuilder)
        {
            // Hotel will handle the CheckIn_events so it can add them to its list
            // making it possible to keep the list private
            HotelEventManager.Register(this);

            _hotelBuilder = TypeOfBuilder;

            // Build the hotel
            HotelAreas    = _hotelBuilder.BuildHotel(layout, settings);
            HotelMovables = _hotelBuilder.BuildMovable(settings, this);

            // Set calculation properties
            HotelWidth  = HotelAreas.OrderBy(X => X.Position.X).Last().Position.X;
            HotelHeight = HotelAreas.OrderBy(Y => Y.Position.Y).Last().Position.Y;

            _elevatorCart = (ElevatorCart)HotelMovables.Find(X => X is ElevatorCart);

            // Methods for final initialization
            Dijkstra.IntilazeDijkstra(this);
            HotelEventManager.Start();
        }
Esempio n. 13
0
        /// <summary>
        /// This is the constructor off the hotel
        /// </summary>
        /// <param name="file"></param>
        public Hotel(string file, Settings hte)
        {
            // Setting the settingsfile of this class
            this.hte = hte;

            // Definitions
            HotelTimer = new Stopwatch();
            Facilities = new List <LocationType>();

            // Methods
            CreateFactory();
            CreateFactoryObjects(file);
            LinkLocationTypes();
            CreateCleaners();

            // We add this class to the listener list so it can be updated
            HotelEventManager.Register(this);
            // Setting the HTE on how fast the events should come in
            HotelEventManager.HTE_Factor = hte.Hte;
            // Start the events
            HotelEventManager.Start();
            // Start the timer
            HotelTimer.Start();
        }
 /// <summary>
 /// Creates a GlobalEventManager and registers it to the HotelEventManager
 /// </summary>
 public GlobalEventManager()
 {
     HotelEventManager.Register(this);
 }
Esempio n. 15
0
        /// <summary>
        /// Moves the Cleaner depending on what Task is enqueued and what their Status is.
        /// </summary>
        public void Move()
        {
            //Since the applications is Multi-Threaded (runs on multiple threads due to the HotelEventManager)
            //This can't be added to the HotelEventManager when created through an Event
            //That's why it's called on the Main Application thread and not on the HotelEventManger thread
            if (!IsRegistered)
            {
                HotelEventManager.Register(this);
                IsRegistered = true;
            }

            #region Task Assignment
            //Gives the Cleaner a task if they don't have one and if there's a Queue of CleanerTasks
            if (CurrentTask == null && CleanerTasks.Count > 0)
            {
                CurrentTask = CleanerTasks.Dequeue();
            }
            //If the Cleaner has nothing to do they need to move to their Optimal Position
            else if (CurrentTask == null && Destination == null && CleanerTasks.Count == 0)
            {
                MoveToOptimalPosition();
            }
            #endregion

            #region Pathfinding to Cleaning Task
            //If the Cleaner has a Task and the Destination is null (or the current Position of the Cleaner)
            //The Path will be set for the Cleaner
            if (CurrentTask != null && (Destination == null || Destination == Hotel.Floors[PositionY].Areas[PositionX].Node))
            {
                Destination = CurrentTask.RoomToClean;
                Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);
            }
            #endregion

            #region Performing Cleaning Task
            //If the Cleaner is standing on the Room Node that needs to be cleaned
            //Then the Room's IsDirty state will change to true and the Room will be cleaned
            if (CurrentTask != null && Hotel.Floors[PositionY].Areas[PositionX].Node == CurrentTask.RoomToClean)
            {
                //If the Room isn't being cleaned yet, the Room's IsDirty state will change to true and the cleaning time will be equal to the one set in the Task
                if (((Room)CurrentTask.RoomToClean.Area).CleaningTime == 0 && ((Room)CurrentTask.RoomToClean.Area).IsDirty == true)
                {
                    ((Room)CurrentTask.RoomToClean.Area).CleaningTime = CurrentTask.TimeToClean;
                    IsVisible = false;
                }
                else
                {
                    //If the Room is currently being cleaned then the CleaningTime should go down with 1 (since this method is called every 1 HTE)
                    if (((Room)CurrentTask.RoomToClean.Area).CleaningTime > 0)
                    {
                        ((Room)CurrentTask.RoomToClean.Area).CleaningTime--;
                        //If the Room is done being cleaned, then the Cleaner needs to be visible again and the CurrentTask is done
                        //The Room's IsDirty state will change to false and the room is able to be used again
                        if (((Room)CurrentTask.RoomToClean.Area).CleaningTime == 0)
                        {
                            ((Room)CurrentTask.RoomToClean.Area).IsDirty = false;
                            IsVisible   = true;
                            CurrentTask = null;
                            Destination = null;
                        }
                    }
                }
            }
            #endregion

            //There's a better explenation about the PathFinding in the References folder (a document called "Project Hotel - Documentatie.docx")
            if (Path != null)
            {
                #region ToElevator
                //If the Cleaner is in front of the Elevator we will check if it's still efficient to use the Elevator or the Stairs
                if (Path.RouteType == ERouteType.ToElevator && Hotel.Floors[PositionY].Areas[PositionX - 1].AreaType == EAreaType.ElevatorShaft)
                {
                    GetRoute();
                }
                //If the Cleaner is not in front of the Elevator yet, they will walk towards the Elevator by Dequeueing Nodes
                else if (Path.RouteType == ERouteType.ToElevator && Path.PathToElevator.Count != 0)
                {
                    //The Node contains all the info for the Cleaner to move forward (an X and Y co-ordinate)
                    Node moveNode = Path.PathToElevator.Dequeue();
                    PositionX = moveNode.Area.PositionX;
                    PositionY = moveNode.Area.PositionY;
                }
                #endregion

                #region Elevator
                //If the Cleaner has decided to take the Elevator then we're going to try and enter the Elevator
                if (Path.RouteType == ERouteType.Elevator)
                {
                    //If the Cleaner isn't in the Elevator we're going to try and request it
                    if (!IsInElevator)
                    {
                        //If the Cleaner is in front of the Elevator they will enter the Elevator and request the floor (int) that they need to go too
                        if (Hotel.Elevator.GetElevatorInfo().Item2 == PositionY && Hotel.Floors[PositionY].Areas[PositionX - 1].AreaType == EAreaType.ElevatorShaft && !IsInElevator)
                        {
                            //Cleaner Requests the Elevator with their desired Floor
                            Hotel.Elevator.RequestElevator(Destination.Floor);
                            //If the Elevator is on their left side, all they have to do is step to the left (meaning X - 1)
                            PositionX--;

                            IsInElevator = true;
                            //Reset RequestedElevator so that the Cleaner can request the Elevator again
                            RequestedElevator = false;

                            //Add the Cleaner to the Elevator so the Cleaner's position is updated with every HTE with the position of the Elevator
                            Hotel.Elevator.InElevator.Add(this);
                        }
                        //If the Cleaner is in front of the ElevatorShaft they request the Elevator to their current position
                        else if (Hotel.Floors[PositionY].Areas[PositionX - 1].AreaType == EAreaType.ElevatorShaft && !IsInElevator)
                        {
                            if (!RequestedElevator)
                            {
                                Hotel.Elevator.RequestElevator(PositionY);
                                RequestedElevator = true;
                            }
                        }
                    }
                    //If the Cleaner is in the Elevator then we need to check if they need to get out the Elevator or not
                    else
                    {
                        //If the Cleaner is on the Floor (int) that they need to be then she will step out of the Elevator and set their path to FromElevator
                        if (PositionY == Destination.Floor)
                        {
                            Hotel.Elevator.InElevator.Remove(this);
                            Path.RouteType = ERouteType.FromElevator;

                            IsInElevator = false;
                        }
                    }
                }
                #endregion

                #region FromElevator
                //If the Cleaner has stepped out of the Elevator, they need to continue their Path to their Destination
                else if (Path.RouteType == ERouteType.FromElevator && Path.PathFromElevator.Count != 0)
                {
                    //This is done by Dequeueing Node's and setting the Cleaner's current position to that of the Node
                    Node moveNode = Path.PathFromElevator.Dequeue();
                    PositionX = moveNode.Area.PositionX;
                    PositionY = moveNode.Area.PositionY;
                }
                #endregion

                #region Stairs
                //If the Cleaner has decided to take the Stairs instead of the Elevator
                if (Path.RouteType == ERouteType.Stairs)
                {
                    //If the Cleaner needs to wait (due to the StairTime) she will not move
                    if (WaitingTime > 0)
                    {
                        WaitingTime--;
                    }
                    //If the Cleaner doesn't need to wait
                    else
                    {
                        //And the Stair Path is still filled with Node's
                        if (Path.Path.Count != 0)
                        {
                            //By Dequeueing a Node, the Cleaner can move by making their X and Y co-ordinate the same as the Node's
                            Node moveNode = Path.Path.Dequeue();
                            PositionX = moveNode.Area.PositionX;
                            PositionY = moveNode.Area.PositionY;

                            //If the Cleaner moves into a Node, their waiting time should be set to the StairTime (in Settings class)
                            if (moveNode.Area.AreaType == EAreaType.Staircase)
                            {
                                WaitingTime = WaitingTime + Hotel.Settings.StairCase - 1;
                            }
                        }
                    }
                }
                #endregion
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Moves the Customer depending on what their Status is.
        /// </summary>
        public void Move()
        {
            //Since the applications is Multi-Threaded (runs on multiple threads due to the HotelEventManager)
            //This can't be added to the HotelEventManager when created through an Event
            //That's why it's called on the Main Application thread and not on the HotelEventManger thread
            if (!IsRegistered)
            {
                HotelEventManager.Register(this);
                IsRegistered = true;
            }

            //Since the Customer can Die, we check if the Customer is waiting and if their DeathTimer does not exceed the given TimeBeforeDeath
            if (IsWaiting == true && DeathTimer >= Hotel.Settings.TimeBeforeDeath)
            {
                //If the Customer needs to die we can remove all instances of him in the Lists
                //That way the C# Garbage Collector will collect it's poor soul
                GlobalStatistics.Customers.Remove(this);
                HotelEventManager.Deregister(this);
            }

            //If the Customer needs to wait for something (Eating, Fitnessing, Taking the Stairs) they will not move until this task is completed (WaitingTime = 0)
            if (WaitingTime > 0)
            {
                WaitingTime--;
            }
            //If the Customer doesn't need to wait for anything to finish
            else if (WaitingTime == 0)
            {
                if (Path != null)
                {
                    #region ToElevator
                    //If the Customer is in front of the Elevator we will check if it's still efficient to use the Elevator or the Stairs
                    if (Path.RouteType == ERouteType.ToElevator && Hotel.Floors[PositionY].Areas[PositionX - 1].AreaType == EAreaType.ElevatorShaft)
                    {
                        GetRoute();
                    }
                    //If the Customer is not in front of the Elevator yet, they will walk towards the Elevator by Dequeueing Nodes
                    else if (Path.RouteType == ERouteType.ToElevator && Path.PathToElevator.Count != 0)
                    {
                        //The Node contains all the info for the Customer to move forward (an X and Y co-ordinate)
                        Node moveNode = Path.PathToElevator.Dequeue();
                        PositionX = moveNode.Area.PositionX;
                        PositionY = moveNode.Area.PositionY;
                    }
                    #endregion

                    #region Elevator
                    if (Path.RouteType == ERouteType.Elevator)
                    {
                        //If the Customer isn't in the Elevator we're going to try and request it
                        if (!IsInElevator)
                        {
                            //If the Customer is in front of the Elevator they will enter the Elevator and request the floor (int) that they need to go too
                            if (Hotel.Elevator.GetElevatorInfo().Item2 == PositionY && Hotel.Floors[PositionY].Areas[PositionX - 1].AreaType == EAreaType.ElevatorShaft && !IsInElevator)
                            {
                                //Customer Requests the Elevator with their desired Floor
                                Hotel.Elevator.RequestElevator(Destination.Floor);
                                //If the Elevator is on their left side, all they have to do is step to the left (meaning X - 1)
                                PositionX--;

                                IsInElevator = true;
                                //Reset RequestedElevator so that the Customer can request the Elevator again
                                RequestedElevator = false;

                                //Add the Customer to the Elevator so the Customer's position is updated with every HTE with the position of the Elevator
                                Hotel.Elevator.InElevator.Add(this);
                            }
                            //If the Customer is in front of the ElevatorShaft they request the Elevator to their current position
                            else if (Hotel.Floors[PositionY].Areas[PositionX - 1].AreaType == EAreaType.ElevatorShaft && !IsInElevator)
                            {
                                if (!RequestedElevator)
                                {
                                    Hotel.Elevator.RequestElevator(PositionY);
                                    RequestedElevator = true;
                                }
                            }
                        }
                        //If the Customer is in the Elevator then we need to check if they need to get out the Elevator or not
                        else
                        {
                            //If the Customer is on the Floor (int) that they need to be then she will step out of the Elevator and set their path to FromElevator
                            if (PositionY == Destination.Floor)
                            {
                                Hotel.Elevator.InElevator.Remove(this);
                                Path.RouteType = ERouteType.FromElevator;

                                IsInElevator = false;
                            }
                        }
                    }
                    #endregion

                    #region FromElevator
                    //If the Customer has stepped out of the Elevator, they need to continue their Path to their Destination
                    else if (Path.RouteType == ERouteType.FromElevator && Path.PathFromElevator.Count != 0)
                    {
                        //This is done by Dequeueing Node's and setting the Customer's current position to that of the Node
                        Node moveNode = Path.PathFromElevator.Dequeue();
                        PositionX = moveNode.Area.PositionX;
                        PositionY = moveNode.Area.PositionY;
                    }
                    #endregion

                    #region Stairs
                    //If the Customer has decided to take the Stairs instead of the Elevator
                    if (Path.RouteType == ERouteType.Stairs)
                    {
                        //And the Stair Path is still filled with Node's
                        if (Path.Path.Count != 0)
                        {
                            //By Dequeueing a Node, the Customer can move by making their X and Y co-ordinate the same as the Node's
                            Node moveNode = Path.Path.Dequeue();
                            PositionX = moveNode.Area.PositionX;
                            PositionY = moveNode.Area.PositionY;

                            //If the Customer moves into a Node, their waiting time should be set to the StairTime (StairTime can be set in the ReceptionScreen)
                            if (moveNode.Area.AreaType == EAreaType.Staircase)
                            {
                                WaitingTime = WaitingTime + Hotel.Settings.StairCase - 1;
                            }
                        }
                    }
                    #endregion
                }
                //If the Path is null (for some reason) the Customer goes back to their Room
                else
                {
                    Path = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, AssignedRoom.Node, true, true);
                }

                //If the Customer doesn't have anywhere to go, they will get their QuickestRoute to their Room
                if (Destination == null)
                {
                    Path = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, AssignedRoom.Node, true, true);
                }
            }

            //If the Customer is not in an IArea then it should be drawn
            if (InArea == null)
            {
                IsVisible = true;
            }
            //If the Customer isn't in an IArea then it shouldn't be drawn
            else
            {
                IsVisible = false;
            }

            //If the Customer has arrived on their Destination
            if (Hotel.Floors[PositionY].Areas[PositionX].Node == Destination)
            {
                //If the Destination is a Restaurant
                if (Destination.Area.AreaType == EAreaType.Restaurant)
                {
                    //They will enter the Area and set their WaitingTime to the Restaurant's EatingTime (EatingTime can be changed for every restaurant)
                    WaitingTime = ((Restaurant)Destination.Area).EatingTime;
                    InArea      = Destination.Area;

                    //Their Destination is set to their Room
                    //If the Customer is done Eating they will automatically go back to their Room
                    Destination = AssignedRoom.Node;
                    Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);
                }
                //If the Destination is a Cinema
                else if (Destination.Area.AreaType == EAreaType.Cinema)
                {
                    //The Customer will check if the Movie has started or not
                    if (!((Cinema)Destination.Area).MovieStarted)
                    {
                        //If the Movie hasn't started it will put itself in the WaitingLine of the Cinema
                        ((Cinema)Destination.Area).WaitingLine.Add(this);
                        //The IsWaiting will be set to true (Customers can die if they wait too long)
                        IsWaiting = true;
                    }
                    //If the Movie has already started, poor Customer :(
                    else
                    {
                        //Their Destination will be set to their Room and they'll travel back to it
                        Destination = AssignedRoom.Node;
                        Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);
                    }
                }
                //If the Destination is a Fitness
                else if (Destination.Area.AreaType == EAreaType.Fitness)
                {
                    //Their WaitingTime will be set to their FitnessTime and they'll enter the Area
                    //FitnessTime is given with the GOTO_FITNESS HotelEvent
                    WaitingTime = FitnessTime;
                    InArea      = Destination.Area;

                    //Their Destination is set to their Room
                    //If the Customer is done Fitnessing they will automatically go back to their Room
                    Destination = AssignedRoom.Node;
                    Path        = Graph.QuickestRoute(Hotel.Floors[PositionY].Areas[PositionX].Node, Destination, true, true);
                }
                //If the Destination is their AssignedRoom
                else if (Hotel.Floors[PositionY].Areas[PositionX] == AssignedRoom)
                {
                    //It will enter their Room
                    InArea = AssignedRoom;
                }
            }
            else if (WaitingTime == 0)
            {
                InArea = null;
            }

            //If the Customer's status is CHECK_OUT (meaning they want to check out) and they're standing on the Reception
            if (Status == HotelEventType.CHECK_OUT && Hotel.Floors[PositionY].Areas[PositionX] == Hotel.Reception)
            {
                //They'll remove themselves from any Lists reffering to them and the Garbage Collector will delete them from existence
                GlobalStatistics.Customers.Remove(this);
                HotelEventManager.Deregister(this);
            }

            #region DeathTimer
            //We check if their current position is the same as their last one
            //If that's true and their not inside an Area
            if (LastLocation == Hotel.Floors[PositionY].Areas[PositionX].Node && InArea == null)
            {
                //The IsWaiting will be set to true and the DeathTimer increases
                IsWaiting = true;
                DeathTimer++;
            }
            //If this is false
            else
            {
                //The IsWaiting will be set to false and their DeathTimer will be reset
                IsWaiting  = false;
                DeathTimer = 0;
            }
            //And their LastLocation will be saved
            LastLocation = Hotel.Floors[PositionY].Areas[PositionX].Node;
            #endregion
        }
Esempio n. 17
0
 /// <summary>
 /// Adaptor Method that calls HotelEvent.Manager.Register();, Registers a HotelEventListener class to the HotelEventManager.
 /// </summary>
 /// <param name="newGuest">HotelEventListener class</param>
 public void Register(Eventadapter newGuest)
 {
     HotelEventManager.Register(newGuest);
 }