Exemplo n.º 1
0
        private void HotelPB_Click(object sender, EventArgs e)
        {
            Point pos = new Point(Cursor.Position.X, Cursor.Position.Y);

            if (hotel.DidIClickOnTheReception(pos))
            {
                if (timer.Enabled) // if timer is enabled then stop timer
                {
                    timer.Stop();
                    frameTimer.Stop();
                    sw.Stop();
                    HotelEventManager.Pauze();
                    Console.WriteLine("Timer gestopt");
                    panelPauze.Visible = true;
                    panelPauze.BringToFront();
                    labelInfo.Text = hotel.Info();
                }
                else // if timer is disabled then start timer
                {
                    timer.Start();
                    frameTimer.Start();
                    sw.Start();
                    HotelEventManager.Start();
                    Console.WriteLine("Timer gestart");
                    panelPauze.Visible = false;
                    labelInfo.Text     = null;
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Pauses the simulation
 /// </summary>
 private void Pause()
 {
     HotelEventManager.Pauze();
     if (HotelEventManager.Pauzed)
     {
         hotelStatus_label.Text = "Pauzed";
     }
     else
     {
         hotelStatus_label.Text = "Running";
     }
     Timer.Enabled = !HotelEventManager.Pauzed;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Pause the simulation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PauseButton_Click(object sender, EventArgs e)
 {
     if (buttonCounter % 2 == 0 || buttonCounter == 0)
     {
         HotelEventManager.Pauze();
         timer.Stop();
         pauseButton.Text = "Hervat";
         buttonCounter++;
     }
     else
     {
         HotelEventManager.Start();
         timer.Start();
         pauseButton.Text = "Pauze";
         buttonCounter++;
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// When pressed on the pause button the simulation goes into pause state and once pressed again it resumes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     if (!_pauseResume)
     {
         _pauseResume  = true;
         pauseBtn.Text = "Resume";
         label1.Text   = "Simulation has been paused";
         _timer.Stop();
         HotelEventManager.Pauze();
     }
     else
     {
         _pauseResume  = false;
         pauseBtn.Text = "Pause";
         label1.Text   = "Simulation is running on " + HotelEventManager.HTE_Factor + "Events per " + _timer.Interval + "milisecond";
         _timer.Start();
         HotelEventManager.Pauze();
     }
 }
Exemplo n.º 5
0
 private void CloseOnClick(object sender, EventArgs e)
 {
     this.Hide();
     if (cmbHTE_Time.Text != "")
     {
         HotelEventManager.HTE_Factor = (float)Math.Pow(2, Convert.ToInt32(cmbHTE_Time.Text) - 1);
     }
     if (cmbStairsSpeed.Text != "")
     {
         Stairs.Weight = -(Convert.ToInt32(cmbStairsSpeed.Text) - 6);
     }
     if (cmbStairsSpeed.Text != "")
     {
         SimplePath = new SimplePath();
         Hotel.AddToGraph(SimplePath);
     }
     if (Movie_Runtime_TXT.Text != "")
     {
         int parsedValue;
         if (int.TryParse(Movie_Runtime_TXT.Text, out parsedValue))
         {
             MovieTime = Convert.ToInt32(string.Join(null, System.Text.RegularExpressions.Regex.Split(Movie_Runtime_TXT.Text, "[^\\d]")));
             foreach (Cinema cinema in Hotel.Areas.Where(r => r.AreaType == "Cinema"))
             {
                 Cinema TempCin = (Cinema)cinema;
                 TempCin.RunTime = MovieTime;
             }
         }
     }
     if (Eating_Speed_TXT.Text != "")
     {
         int parsedValue;
         if (int.TryParse(Eating_Speed_TXT.Text, out parsedValue))
         {
             EatingSpeed = Convert.ToInt32(string.Join(null, System.Text.RegularExpressions.Regex.Split(Eating_Speed_TXT.Text, "[^\\d]")));
             foreach (Restaurant restaurant in Hotel.Areas.Where(r => r.AreaType == "Restaurant"))
             {
                 Restaurant TempRes = (Restaurant)restaurant;
                 TempRes.EatSpeed = EatingSpeed;
             }
         }
     }
     if (Cleaning_Speed_TXT.Text != "")
     {
         int parsedValue;
         if (int.TryParse(Cleaning_Speed_TXT.Text, out parsedValue))
         {
             CleanSpeed = Convert.ToInt32(string.Join(null, System.Text.RegularExpressions.Regex.Split(Cleaning_Speed_TXT.Text, "[^\\d]")));
             foreach (Cleaner cleaner in Cleaners)
             {
                 cleaner.CleaningSpeed = CleanSpeed;
             }
         }
     }
     foreach (IPerson person in Persons)
     {
         person.RoundPosition();
     }
     if (!HotelEventManager.Running)
     {
         HotelEventManager.Pauze();
     }
 }
Exemplo n.º 6
0
        private void UserControlls()
        {
            // Reset the color of the object that was being hovered over
            if (_mouseIsOver != null)
            {
                _mouseIsOver.Sprite.Color = Color.White;
            }

            // Get the object the mouse is hovering.
            _mouseIsOver = _hotel.GetObject(_camera.ScreenToWorld(Input.Instance.GetMousePos()));

            if (_wasSelected != null)
            {
                _closeUpCamera.CamPosition = new Vector2(-_wasSelected.Position.X - _wasSelected.Sprite.DrawDestination.Width / 2, _wasSelected.Position.Y - _wasSelected.Sprite.DrawDestination.Height / 2);
            }

            // If a mouseover object is found
            if (_mouseIsOver != null)
            {
                // Highlight the sprite.
                _mouseIsOver.Sprite.Color = Color.LightGreen;

                // When the left mouse is clicked
                if (Input.Instance.OnLeftMouseButtonRelease())
                {
                    if (_mouseIsOver is Lobby)
                    {
                        Paused = !Paused;
                        HotelEventManager.Pauze();
                    }

                    // Check if the information window is already showing some data.
                    if (!_informationWindow.IsShowingInfo)
                    {
                        // Set the object as selected and show its information
                        _wasSelected = _mouseIsOver;
                        _informationWindow.ShowInformation(_mouseIsOver);
                    }
                    else
                    {
                        // Hide the information window
                        if (_wasSelected.Equals(_mouseIsOver))
                        {
                            _informationWindow.HideInformation();
                        }
                        else
                        {
                            // Update the information window
                            _wasSelected = _mouseIsOver;
                            _informationWindow.HideInformation();
                            _informationWindow.ShowInformation(_mouseIsOver);
                        }
                    }
                }
            }
            else
            {
                // Hide the information window
                if (Input.Instance.OnLeftMouseButtonRelease())
                {
                    _informationWindow.HideInformation();
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            if (Keyboard.GetState().IsKeyDown(Keys.U))
            {
                _isPaused         = false;
                _menuForm.Visible = false;
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.P) && !_isPaused)
            {
                _isPaused         = true;
                _menuForm.Visible = true;
                _menuForm.ReInitListboxes();
                if (HotelEventManager.Running)
                {
                    HotelEventManager.Pauze();
                }
            }
            if (_isPaused)
            {
                _isPaused = _menuForm.Visible;
            }
            else
            {
                if (HotelEventManager.Running)
                {
                    HotelEventManager.Pauze();
                }
                ReloadAfterForm();

                _menuForm.Visible = false;
                _eventChecker.CheckEvents(_simplePath, _hotel, _persons, _reception, _customers, listener, _lobby, _elevator, _cleaner, _cleaners, gameTime, _roomQueue);

                _cleaner.SearchRoom(_hotel, _roomQueue);
                _cleaner2.SearchRoom(_hotel, _roomQueue);

                _cleaner.GetRoom(gameTime, _simplePath, _roomQueue);
                _cleaner2.GetRoom(gameTime, _simplePath, _roomQueue);

                _roomQueue.Clear();

                foreach (IPerson person in _persons)
                {
                    if (person.Sprite == null)
                    {
                        person.LoadContent(Content);
                    }
                    person.Update(gameTime);
                }
                _reception.HelpQueue(_hotel, _simplePath);
                _elevator.InitWaitingFloors();
                _elevator.Update(gameTime);

                _huidigeCinema.CheckCinema(gameTime, _hotel, _huidigeCinema, _simplePath, _customers);

                if (_customers.Count != 0)
                {
                    foreach (Customer customer in _customers)
                    {
                        customer.ReturnToRoom(gameTime, _simplePath, _hotel);
                        customer.CheckCinema(_simplePath, _huidigeCinema);
                    }
                }
                foreach (Person person in _persons)
                {
                    if (person.Position != null && person.Destination != null && person.Route != null)
                    {
                        if (person.Position != person.Destination && person.Route.Count == 0)
                        {
                            person.Route = _simplePath.GetRoute(new Vector2((float)Math.Round(person.Position.X, 0), (float)Math.Round(person.Position.Y, 0)), person.Destination);
                        }
                    }
                }
                base.Update(gameTime);
                if (!HotelEventManager.Running)
                {
                    HotelEventManager.Pauze();
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Adaptor Method that calls HotelEvent.Manager.Pause();
 /// </summary>
 public void Pause_Events()
 {
     HotelEventManager.Pauze();
 }