Ejemplo n.º 1
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;
            }
        }