Beispiel #1
0
 private void stopSystem()
 {
     timerRefresh.Enabled = false;
     timerLift.Enabled    = false;
     Invalidate();
     persons.Clear();
     floors.Clear();
     sumPersons = 0;
     lift       = Lift.newInstance();
 }
Beispiel #2
0
 private void createLiftInBuild()
 {
     int[] mass = new int[floors.Count];
     for (int i = 0; i < mass.Length; i++)
     {
         mass[i] = floors[i].PositionY;
     }
     lift = Lift.getInstance(numberOfFloor, positionX + 430, floors[0].PositionY, mass);
     g.DrawImage(Properties.Resources.lift, lift.PositionX, lift.PositionY);
 }
Beispiel #3
0
 public static Lift getInstance(int countButtons, int positionX, int positionY, int[] coordinate)
 {
     if (lift == null)
     {
         lock (syncRoot)
         {
             if (lift == null)
             {
                 lift = new Lift(countButtons, positionX, positionY, coordinate);
             }
         }
     }
     return(lift);
 }
Beispiel #4
0
        public bool NextMove()
        {
            Lift lift = Lift.getInstance(0, 0, 0, new int[] { 0, 0 });

            if (positionX < lengthFloor && !moveInLift && !exitFloor)
            {
                positionX_old = positionX;
                positionY_old = positionY;
                positionX    += speedX;
            }
            else if (!wait && !moveInLift && !exitFloor)
            {
                wait   = true;
                status = "Ждёт на этаже " + (numberFloor[0] + 1);
                lift.callTheElevator(numberFloor[0], numberFloor[1]);
            }
            else if (numberFloor[0] == lift.CurrentFloor && !moveInLift && !exitFloor && lift.Weight < 400)
            {
                enable         = false;
                moveInLift     = true;
                lift.Weight    = weight;
                lift.sumWeight = weight;
                lift.MoveUp    = false;
                status         = "Движется на нужный этаж";
                lift.moveTheElevator(numberFloor[0]);
            }
            else if (numberFloor[1] == lift.CurrentFloor && moveInLift && !exitFloor)
            {
                enable      = true;
                exitFloor   = true;
                positionY   = lift.PositionY + 15;
                lift.Weight = -weight;
                lift.MoveUp = false;
                status      = "Уходит на этаже " + (numberFloor[1] + 1);
                lift.exitTheElevator(numberFloor[1]);
            }
            else if (exitFloor)
            {
                positionX_old = positionX;
                positionY_old = positionY;
                positionX    -= speedX;
            }

            return(enable);
        }
Beispiel #5
0
        public bool NextMove()
        {
            Lift lift = Lift.getInstance(0, 0, 0, new int[] { 0, 0 });

            if (positionX < lengthFloor && !moveInLift && !exitFloor) //движется от двери к лифту
            {
                positionX_old = positionX;
                positionY_old = positionY;
                positionX    += speedX;
            }
            else if (!wait && !moveInLift && !exitFloor) //ожидает лифта на своем этаже
            {
                wait   = true;
                status = "Ждёт на этаже " + (numberFloor[0] + 1);
                lift.callTheElevator(numberFloor[0], numberFloor[1]);
            }
            else if (numberFloor[0] == lift.CurrentFloor && !moveInLift && !exitFloor && lift.Weight + weight < 400) //едет в лифте
            {
                enable         = false;
                moveInLift     = true;
                lift.Weight    = weight;
                lift.sumWeight = weight;
                lift.MoveUp    = false;
                status         = "Движется на нужный этаж";
                lift.moveTheElevator(numberFloor[0]);
            }
            else if (numberFloor[1] == lift.CurrentFloor && moveInLift && !exitFloor) //выходит из лифта
            {
                enable      = true;
                exitFloor   = true;
                positionY   = lift.PositionY + 15;
                lift.Weight = -weight;
                lift.MoveUp = false;
                status      = "Выходит на этаже " + (numberFloor[1] + 1);
                lift.exitTheElevator(numberFloor[1]);
            }
            else if (exitFloor)   //движется к двери после выхода из лифта
            {
                positionX_old = positionX;
                positionY_old = positionY;
                positionX    -= speedX;
            }
            return(enable);
        }
Beispiel #6
0
 public static Lift newInstance()
 {
     lift = null;
     return(lift);
 }