示例#1
0
        public Area GetClosestAreaOfType(SimType type, Area notThisArea = null)
        {
            Area        returnValue    = null;
            List <Area> availebleAreas = new List <Area>();

            foreach (Area area in hotelArray)
            {
                if (area != null && area.Simtype == type && area != notThisArea)
                {
                    availebleAreas.Add(area);
                }
            }
            if (!IsNullOrEmpty(availebleAreas))
            {
                Dijkstra ds = new Dijkstra();
                double   shortestDistance = double.MaxValue;
                foreach (Area area in availebleAreas)
                {
                    double distance = ds.GetDistance(this.currentArea, area);
                    if (distance < shortestDistance)
                    {
                        shortestDistance = distance;
                        returnValue      = area;
                    }
                }
            }

            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// gives a guest a requested room
        /// </summary>
        /// <param name="_guest">guest at the reception</param>
        /// <param name="_requestedClassification">stars of the room the guest wants</param>
        /// <returns>the given room</returns>
        public Room CheckIn(Guest _guest, int _requestedClassification)
        {
            List <Area> availableRooms = new List <Area>();
            Room        returnValue    = null;

            foreach (Area room in hotelArray)
            {
                if (room != null && room.Simtype == SimType.Room)
                {
                    if ((room as Room).classification == _requestedClassification && !(room as Room).occupied)
                    {
                        availableRooms.Add(room);
                    }
                }
            }
            if (!IsNullOrEmpty(availableRooms))
            {
                Dijkstra ds = new Dijkstra();
                double   shortestDistance = double.MaxValue;
                foreach (Room room in availableRooms)
                {
                    double distance = ds.GetDistance(this, room);
                    if (distance < shortestDistance)
                    {
                        shortestDistance = distance;
                        returnValue      = room;
                    }
                }
            }
            returnValue.guests.Add(_guest);
            returnValue.occupied = true;
            return(returnValue);
        }
示例#3
0
        public void Interact()
        {
            interacting = true;

            switch (currentArea.Simtype)
            {
            case SimType.Reception:
                #region reception check-in/check-out
                if (bedroom == null)
                {
                    //check-in
                    bedroom = (currentArea as Reception).CheckIn(this, requestedClassification);
                    if (bedroom != null)
                    {
                        ChangeDestination(bedroom);
                    }
                }
                else
                {
                    //check-out
                    (currentArea as Reception).CheckOut(this);
                    bedroom = null;
                    ChangeDestination(hotelArray[0, 0]);
                }
                #endregion
                break;

            case SimType.Room:
                break;

            case SimType.Gym:

                //enter Gym
                drawMe = false;
                currentArea.guests.Add(this);
                actionTimer = gymTime;

                break;

            case SimType.Cinema:
                if ((currentArea as Cinema).moviePlaying)
                {
                    //go back to room
                    ChangeDestination(bedroom);
                }
                else
                {
                    //enter cinema
                    drawMe = false;
                    currentArea.guests.Add(this);
                }
                break;

            case SimType.Restaurant:
                if (currentArea.capacity > currentArea.guests.Count)
                {
                    //enter restaurant
                    drawMe = false;
                    currentArea.guests.Add(this);
                    actionTimer = eatTime;
                }
                else
                {
                    //wait or go to other restaurant
                    int waitTime = int.MaxValue;
                    // TODO: include other guests waiting in line
                    foreach (Guest guest in currentArea.guests)
                    {
                        if (guest.actionTimer < waitTime)
                        {
                            waitTime = guest.actionTimer;
                        }
                    }


                    Area     nextRestaurant = GetClosestAreaOfType(SimType.Restaurant, currentArea);
                    Dijkstra ds             = new Dijkstra();
                    if (ds.GetDistance(currentArea, nextRestaurant) < waitTime)
                    {
                        eventLocation = nextRestaurant;
                    }
                    else
                    {
                        (currentArea as Restaurant).queue.Add(this);
                    }
                }
                break;

            case SimType.Stairwell:
                break;

            case SimType.ElevatorShaft:

                break;

            default:
                break;
            }
        }