Пример #1
0
        /// <summary>
        /// Hide the information window.
        /// </summary>
        public void HideInformation()
        {
            // Unred the target room
            if (_objectToDisplay is Guest)
            {
                Guest person = (Guest)_objectToDisplay;

                if (person.TargetRoom != null)
                {
                    person.TargetRoom.Sprite.Color = Color.White;
                }
            }

            // Set the showing on false.
            IsShowingInfo = false;

            // Remove the object that is displayed.
            _objectToDisplay = null;
        }
Пример #2
0
        /// <summary>
        /// Remove a object.
        /// </summary>
        /// <param name="object">The object to remove.</param>
        public void RemoveObject(object sender, EventArgs e)
        {
            HotelObject hotelObject = (HotelObject)sender;

            if (hotelObject is Person)
            {
                // Remove guest from the hotel.
                if (hotelObject is Guest)
                {
                    string item  = Guests.First(x => x.Value == hotelObject).Key;
                    Guest  guest = (Guest)hotelObject;

                    if (guest.Room != null)
                    {
                        if (guest.Room.State != RoomState.Emergency && guest.Room.State != RoomState.InCleaning)
                        {
                            guest.Room.State = RoomState.Dirty;
                        }
                        guest.Room = null;
                    }

                    //Remove the guest from a checkin/out queue where applicable.
                    if (guest.CurrentRoom is Lobby)
                    {
                        (guest.CurrentRoom as Lobby).RemoveFromQueues(guest);
                    }

                    Guests.Remove(item);
                }
                // Remove receptionist from hotel.
                else if (hotelObject is Receptionist)
                {
                    Lobby lobby = Rooms.Where(x => x is Lobby && (x as Lobby).Receptionist == hotelObject) as Lobby;
                    if (lobby != null)
                    {
                        lobby.Receptionist = null;
                    }
                    Staff.Remove(hotelObject as Person);
                }
                // Remove cleaner from the hotel.
                else if (hotelObject is Cleaner)
                {
                    Cleaner cleaner = (Cleaner)hotelObject;
                    Staff.Remove(cleaner);

                    // Spawn a ghost
                    CleanerGhost cGhost = new CleanerGhost(cleaner.CurrentRoom);
                    cGhost.RemoveObjectEvent += RemoveObject;
                    Staff.Add(cGhost);
                }
                else if (hotelObject is CleanerGhost)
                {
                    CleanerGhost cleanerGhost = (CleanerGhost)hotelObject;

                    // Spawn a new cleaner
                    Cleaner cleaner = new Cleaner(cleanerGhost.CurrentRoom);
                    cleaner.RemoveObjectEvent += RemoveObject;
                    Staff.Add(cleaner);
                    // Make it walk indoors
                    cleaner.FindAndTargetRoom(x => (x is Lobby && (x as Lobby).Receptionist != null));

                    Staff.Remove(cleanerGhost);
                }

                hotelObject.RemoveObjectEvent -= RemoveObject;
            }
        }
Пример #3
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();
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Show the information window with text from a specific object.
        /// </summary>
        /// <param name="objectToDisplay">The object to display information about.</param>
        public void ShowInformation(HotelObject objectToDisplay)
        {
            _objectToDisplay = objectToDisplay;

            IsShowingInfo = true;
        }