public Elevator(Building Mybuilding, int HorizontalPosition, Floor StartingFloor) { this.myBuilding = Mybuilding; this.currentFloor = StartingFloor; this.listOfFloorsToVisit = new List <Floor>(); this.elevatorDirection = Direction.None; this.elevatorStatus = ElevatorStatus.Idle; this.maximumPeopleInside = 2; this.listOfPeopleInside = new List <Passenger>(); this.IsFull = false; this.elevatorPosition = new Point(HorizontalPosition, currentFloor.GetFloorLevelInPixels()); currentFrameNumber = 0; elevatorFrames = new Bitmap[] { Properties.Resources.LiftDoors_Open, Properties.Resources.LiftDoors_4, Properties.Resources.LiftDoors_3, Properties.Resources.LiftDoors_2, Properties.Resources.LiftDoors_1, Properties.Resources.LiftDoors_Closed }; this.elevatorAnimationDelay = 8; this.elevatorTimer = new System.Timers.Timer(5000); //set timer to 5 seconds this.elevatorTimer.Elapsed += new ElapsedEventHandler(this.Elevator_ElevatorTimerElapsed); this.PassengerEnteredTheElevator += new EventHandler(this.Elevator_PassengerEnteredTheElevator); //Add new elevator to floor's list currentFloor.AddRemoveElevatorToTheListOfElevatorsWaitingHere(this, true); }
public Elevator(Building myBuilding, int horizontalPosition, Floor startingFloor, Mediator mediator) : base(mediator) { _myBuilding = myBuilding; _currentFloor = startingFloor; _listOfFloorsToVisit = new List <Floor>(); _elevatorDirection = Direction.stop; _elevatorStatus = ElevatorStatus.Idle; _maximumPeopleInside = 2; _listOfPeopleInside = new List <Passenger>(); _isFull = false; _elevatorPosition = new Point(horizontalPosition, _currentFloor.GetFloorLevelInPixels()); _currentFrameNumber = 0; _elevatorFrames = new[] { Properties.Resources.LiftDoors_Open, Properties.Resources.LiftDoors_4, Properties.Resources.LiftDoors_3, Properties.Resources.LiftDoors_2, Properties.Resources.LiftDoors_1, Properties.Resources.LiftDoors_Closed }; _elevatorAnimationDelay = 8; _elevatorTimer = new System.Timers.Timer(6000); //set timer to 6 seconds _elevatorTimer.Elapsed += Elevator_ElevatorTimerElapsed; PassengerEnteredTheElevator += Elevator_PassengerEnteredTheElevator; //Add new elevator to floor's list _currentFloor.AddRemoveElevatorToTheListOfElevatorsWaitingHere(this, true); }
public Elevator(Building Mybuilding, int HorizontalPosition, Floor StartingFloor) { this.myBuilding = Mybuilding; this.currentFloor = StartingFloor; this.listOfFloorsToVisit = new List<Floor>(); this.elevatorDirection = Direction.None; this.elevatorStatus = ElevatorStatus.Idle; this.maximumPeopleInside = 2; this.listOfPeopleInside = new List<Passenger>(); this.IsFull = false; this.elevatorPosition = new Point(HorizontalPosition, currentFloor.GetFloorLevelInPixels()); currentFrameNumber = 0; elevatorFrames = new Bitmap[] { Properties.Resources.LiftDoors_Open, Properties.Resources.LiftDoors_4, Properties.Resources.LiftDoors_3, Properties.Resources.LiftDoors_2, Properties.Resources.LiftDoors_1, Properties.Resources.LiftDoors_Closed }; this.elevatorAnimationDelay = 8; this.elevatorTimer = new System.Timers.Timer(5000); //set timer to 5 seconds this.elevatorTimer.Elapsed += new ElapsedEventHandler(this.Elevator_ElevatorTimerElapsed); this.PassengerEnteredTheElevator += new EventHandler(this.Elevator_PassengerEnteredTheElevator); //Add new elevator to floor's list currentFloor.AddRemoveElevatorToTheListOfElevatorsWaitingHere(this, true); }
public void PrepareElevatorToGoToNextFloorOnTheList() { //Method can be invoked from ElevatorManager thread (SendAnElevator()) or elevator's timer thread (Elevator_ElevatorTimerElapsed()) //Update elevator's status SetElevatorStatus(ElevatorStatus.PreparingForJob); //Disable the timer this.elevatorTimer.Stop(); //Remove this elevator from current floor's list currentFloor.AddRemoveElevatorToTheListOfElevatorsWaitingHere(this, false); //Close the door this.CloseTheDoor(); //Go! GoToNextFloorOnTheList(); }