public Form1() { InitializeComponent(); //Initialize Building object MyBuilding = new Building(); }
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); }
private int widthOfSlotForSinglePassenger; //ammount of pixels reserved for single passenger; depends on passenger graphic #endregion Fields #region Constructors public Floor(Building myBuilding, int floorNumber, int floorLevel) { this.myBuilding = myBuilding; maximumAmmountOfPeopleInTheQueue = 8; //only 8 passengers at once can be visible in current layout this.arrayOfPeopleWaitingForElevator = new Passenger[maximumAmmountOfPeopleInTheQueue]; this.floorIndex = floorNumber; listOfElevatorsWaitingHere = new List<Elevator>(); //Initialize variables, which depend on graphics: this.floorLevel = floorLevel; beginOfTheQueue = 367; widthOfSlotForSinglePassenger = 46; //Turn off both lamps LampUp = false; LampDown = false; }
public Passenger(Building MyBuilding, Floor CurrentFloor, int TargetFloorIndex) { this.myBuilding = MyBuilding; this.currentFloor = CurrentFloor; this.currentFloorIndex = CurrentFloor.FloorIndex; this.passengerStatus = PassengerStatus.WaitingForAnElevator; this.targetFloor = MyBuilding.ArrayOfAllFloors[TargetFloorIndex]; this.targetFloorIndex = TargetFloorIndex; this.PassengerPosition = new Point(); Random random = new Random(); this.thisPassengerGraphic = new Bitmap(Passenger.ArrayOfAllPassengerGraphics[random.Next(ArrayOfAllPassengerGraphics.Length)]); this.visible = true; this.passengerAnimationDelay = 8; //Subscribe to events this.currentFloor.NewPassengerAppeared += new EventHandler(currentFloor.Floor_NewPassengerAppeared); this.currentFloor.NewPassengerAppeared += new EventHandler(this.Passenger_NewPassengerAppeared); this.currentFloor.ElevatorHasArrivedOrIsNotFullAnymore += new EventHandler(this.Passenger_ElevatorHasArrivedOrIsNoteFullAnymore); }