示例#1
0
 /// <summary>
 /// Hotel is getting updated and is updating in it's updating method, the update methode of all locationtypes
 /// </summary>
 /// <param name="drawUpdateTime"></param>
 public void Update(double drawUpdateTime)
 {
     for (int i = 0; i < Facilities.Count; i++)
     {
         Facilities[i].Update(drawUpdateTime);
     }
     if (elevator != null)
     {
         elevator.Update(drawUpdateTime);
     }
 }
        /// <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();
                }
            }
        }