Inheritance: MonoBehaviour
        static void Main(string[] args)
        {
            var elevatorController = new ElevatorController(84, 5);
            var selectedElevator   = elevatorController.requestElevator(1, "up");

            elevatorController.requestFloor(selectedElevator, 84);
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     _spawnPositions              = GetComponentsInChildren <SpawnPosition>();
     _waitPositions               = _waitPositionsRef.GetComponentsInChildren <WaitPosition>();
     _elevator                    = FindObjectOfType <ElevatorController>();
     _elevator.OnElevatorCleared += HandleClearFloor;
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            IElevatorMotor      motor      = new ElevatorMotor();
            IElevatorController controller = new ElevatorController(motor, _floorCount);

            TakeInput(controller);
        }
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     if (ElevatorObject != null)
     {
         elevatorController = ElevatorObject.GetComponent <ElevatorController>();
     }
 }
Ejemplo n.º 5
0
        private void OnElevatorReachGoalFloor(ElevatorController.Request request, ElevatorController elevator)
        {
            if (this.elevator != elevator)
            {
                return;
            }

            visitedFloors.Add(request.FloorNum);
        }
Ejemplo n.º 6
0
        public void Initialize(ElevatorController elevator)
        {
            this.elevator = elevator;

            elevator.FloorChanged                    += OnFloorChanged;
            elevator.CabinFloorRequested             += OnCabinFloorRequested;
            ElevatorController.GoalFloorReached      += OnGoalFloorReached;
            ElevatorController.RequestNoLongerActual += OnRequestNoLongerActual;
        }
Ejemplo n.º 7
0
        public void OnGoalFloorReached(ElevatorController.Request request, ElevatorController elevator)
        {
            if (this.elevator != elevator)
            {
                return;
            }

            DisactivateBtn(request.FloorNum);
        }
Ejemplo n.º 8
0
        private void OnRequestNoLongerActual(ElevatorController.Request request, ElevatorController elevator)
        {
            if (this.elevator != elevator)
            {
                return;
            }

            DisactivateBtn(request.FloorNum);
        }
Ejemplo n.º 9
0
    public void AddRequest(int desiredFloorNum, ElevatorDirection desiredDirection, ElevatorController elevator)
    {
        var request         = new ElevatorController.Request(desiredDirection, desiredFloorNum);
        var closestElevator = GetClosestElevator(request, elevator);

        if (closestElevator == null)
        {
            return;
        }

        closestElevator.AddRequest(desiredFloorNum, desiredDirection);
    }
Ejemplo n.º 10
0
 private void Start()
 {
     m_Controller = GetComponent <ElevatorController>();
     foreach (var sound in elevatorSounds)
     {
         sound.source              = gameObject.AddComponent <AudioSource>();
         sound.source.clip         = sound.clip;
         sound.source.volume       = sound.volume;
         sound.source.pitch        = sound.pitch;
         sound.source.loop         = sound.loop;
         sound.source.spatialBlend = 0.8f;
     }
 }
Ejemplo n.º 11
0
 void Awake()
 {
     if (_instance != null)
     {
         Debug.LogWarning("ElevatorController:: Duplicate instance of ElevatorController, deleting second one.");
         Destroy(this.gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        if (mainElevator == null)
        {
            mainElevator = this;
        }

        if (this != mainElevator)
        {
            StartCoroutine(OpenDoors(true));
            notMain = true;
        }
    }
Ejemplo n.º 13
0
        public void Initialize(int num, ElevatorController elevator, BasementController basement)
        {
            Num           = num;
            Position      = transform.position;
            this.elevator = elevator;
            this.basement = basement;

            elevator.FloorChanged     += OnFloorChanged;
            elevator.EnteredIdle      += OnEnteredIdle;
            elevator.DirectionChanged += OnDirectionChanged;

            ElevatorController.GoalFloorReached      += OnGoalFloorReached;
            ElevatorController.RequestNoLongerActual += OnRequestNoLongerActual;
        }
Ejemplo n.º 14
0
    public void SendCall(string Call)
    {
        ElevatorController Elevator = m_ElevatorController.GetComponent <ElevatorController>();

        ElevatorMoving = Elevator.ElevatorMoving;
        if (Call == "ElevatorUp" && !ElevatorMoving)
        {
            Elevator.ElevatorGO("ElevatorUp");
        }

        if (Call == "ElevatorDown" && !ElevatorMoving)
        {
            Elevator.ElevatorGO("ElevatorDown");
        }
    }
Ejemplo n.º 15
0
 private void Move(ElevatorController elevator)
 {
     elevator.elevator.transform.localPosition = Vector3.MoveTowards(elevator.elevator.transform.localPosition, elevator.nextPos, elevator.speed * Time.deltaTime);
     if (Vector3.Distance(elevator.elevator.transform.localPosition, elevator.nextPos) >= 0)
     {
         if (elevator.currentPosition > 0)
         {
             elevator.currentPosition -= 1;
             elevator.nextPos          = elevator.positions[elevator.currentPosition];
         }
         else
         {
             elevator.nextState = elevator.MovingUpState;
         }
         elevator.TransitionToState(elevator.StoppedState);
     }
 }
Ejemplo n.º 16
0
    public override void Spawn(FloorData currentFloor, FloorData desiredFloor, ElevatorController elevator, Material material, GameManager gm)
    {
        gm.OnElevatorStoped      += ElevatorStoped;
        gm.OnFloorChanged        += ElevatorMoved;
        gm.OnFailedToGetPosition += HandleCrowdedFloor;
        _gameManager              = gm;

        _elevator                     = elevator;
        _currentFloor                 = currentFloor;
        DesiredFloor                  = desiredFloor;
        MeshRenderer.material         = material;
        _meshRendererRagDoll.material = material;
        _animator                     = GetComponent <UserAnimator>();
        _rigidbody                    = GetComponent <Rigidbody>();
        _uiColorChanger               = FindObjectOfType <UICcolorsChanger>();
        _animator.Run();
        RunToDeath();
    }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            //Added LowerBasement, Basement, GroundFloor, 10 Floors
            IBuilding building = new Building(); //Instance of Building

            //Added Extra Floor to the building, Now total Floor is 11
            //---> building.AddFloor(FloorFactory.CreateFloor(FloorType.Floor));

            //When a person presses up / down button on the floo
            //we can initiate multiple request
            var requests = new ElevatorRequests();
            var button   = new FloorButton(requests, Direction.Down, 3);

            button.PlaceRequest();

            // button = new FloorButton(requests, Direction.Up, 9);
            //button.PlaceRequest();

            //Elevator controller which control all the elevators
            //we can add addition elevator as well
            ElevatorController controller = new ElevatorController(requests, building);

            controller.AttachElevator(new Elevator.Elevator("EL1", 7, ElevatorStatus.UP));                            //Attached 1 Elevator
            controller.AttachElevator(new Elevator.Elevator("EL2", 4, ElevatorStatus.DOOR_OPEN));                     //Attached 2 Elevator
            controller.AttachElevator(new Elevator.Elevator("EL3", (int)FloorType.LowerBasement, ElevatorStatus.UP)); // //Attached 3 Elevator
            //---> controller.AttachElevator(new Elevator.Elevator("EL4", (int)FloorType.GroundFloor, ElevatorStatus.UP)); // //Attached 4 Elevator

            while (true)
            {
                var request = controller.GetNextRequestToProcesses();
                if (request != null && !request.IsProcesed)
                {
                    Console.WriteLine("Processing Request Id :- {0}, Floor No. :- {1}", request.RequestId, (request.FloorNo - 2));
                    controller.Notify(request);
                    controller.StratElevator(request);

                    if (request.IsProcesed)
                    {
                        requests.RemoveReqest(request);
                        Console.WriteLine("Processing Completed ");
                    }
                }
            }
        }
        public void Intialize()
        {
            loggerMock = new Mock <ILogger <ElevatorController> >();

            elevatorRouteServiceMock = new Mock <IElevatorRouteService>();

            elevatorPoolServiceMock = new Mock <IElevatorPoolService>();

            elevatorEventLogServiceMock = new Mock <IElevatorEventLogService>();

            elevatorStatusServiceMock = new Mock <IElevatorStatusService>();

            sut = new ElevatorController(
                loggerMock.Object,
                elevatorRouteServiceMock.Object,
                elevatorPoolServiceMock.Object,
                elevatorEventLogServiceMock.Object,
                elevatorStatusServiceMock.Object);
        }
    void OnTriggerEnter(Collider collider)
    {
        if( objects.Length < 2 )
            return;

        if (objects[1] != null) {
        if(objects[1].gameObject.tag == "Death")
        {
            if(objects[1].activeSelf)
            {
                objects[1].SetActive(false);
            }
            else if(!objects[1].activeSelf)
            {
                objects[1].SetActive(true);
            }
        }
        }

        if (collider.gameObject.tag == "Player") {
            anim.SetBool("Pressed", true);
            //Debug.Log ("Player");
            //switches = true;
            foreach (GameObject item in objects) {
                if (item != null) {
                    if (item.tag == "Elevator") {
                        elevatorScript = item.GetComponent<ElevatorController>();
                        if (elevatorScript != null && elevatorScript.inactive == true) {
                            elevatorScript.inactive = false;
                        }
                    } else {
                        itemScript = item.GetComponent<MultiTriggerReceivers>();
                        if ( itemScript != null && itemScript.activate == false) {
                            itemScript.activate = true;
                            itemScript.inactive = false;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 20
0
    void Start()
    {
        Elevator = this;

        isSceneTransitioning = false;

        //Ray added this line
        //animator = GetComponent<Animator>();

        if (SceneOrder.Count <= 0)
        {
            return;
        }

        DontDestroyOnLoad(gameObject);

        //SceneManager.LoadSceneAsync(SceneOrder[Level]);

        animator.SetTrigger("Open_trigger");

        //Play the door open sound
    }
Ejemplo n.º 21
0
        static void Main(string[] args)
        {
            var floorListBuilder = new FloorListBuilder(new FloorFactory());

            IFloorList floorList = new FloorList(floorListBuilder, 2);

            var floors = floorList.Floors;

            floors[0].Panel.Up.Press();
            floors[0].Panel.Down.Press();
            floors[1].Panel.Down.Press();

            var callPanelListButtonStates = new CallPanelListButtonStates();

            floorList.Accept(callPanelListButtonStates);

            Console.WriteLine($"Engaged Down: {string.Join(", ", callPanelListButtonStates.EngagedDownButtons)}");
            Console.WriteLine($"Engaged Up: {string.Join(", ", callPanelListButtonStates.EngagedUpButtons)}");

            ElevatorPanel elevatorPanel = new ElevatorPanel(35);

            elevatorPanel.FloorButtons[0].Press();
            elevatorPanel.FloorButtons[12].Press();
            elevatorPanel.FloorButtons[17].Press();
            elevatorPanel.FloorButtons[30].Press();

            Console.WriteLine($"SelectedFloors: {string.Join(", ", elevatorPanel.SelectedFloors())}");

            var moveable = new Elevator.Elevator("Elevator 1", new ElevatorPanel(35), new StandardMovementSpeed());

            var controller = new ElevatorController();

            controller.AddMoveable(moveable);

            moveable.MoveTo(10);


            Console.ReadLine();
        }
Ejemplo n.º 22
0
 // Use this for initialization
 void OnEnable()
 {
     elevator = GameObject.Find("Elevator");
     elevatorController = elevator.GetComponent<ElevatorController>();
     mainCam = GetComponentInChildren<Camera> ();
 }
Ejemplo n.º 23
0
 public virtual void Spawn(FloorData spawnedFloor, FloorData desiredFloor, ElevatorController elevator, Material material, GameManager gameManager)
 {
 }
Ejemplo n.º 24
0
 public override void EnterState(ElevatorController elevator)
 {
     elevator.DelayedTransition(elevator.StateController());
     //elevator.DelayedTransition(elevator.MovingUpState);
     Debug.Log("Stopped");
 }
Ejemplo n.º 25
0
 private void Start()
 {
     _elevatorController = GetComponentInParent <ElevatorController>();
 }
Ejemplo n.º 26
0
 private void SetElevator()
 {
     gameController.OnRestartClicked();
     elevator = gameController.GetComponentInChildren <ElevatorController>();
     ElevatorController.GoalFloorReached += OnElevatorReachGoalFloor;
 }
Ejemplo n.º 27
0
 void Start()
 {
     elevatorController = elevatorController ?? GetComponentInParent <ElevatorController>();
 }
Ejemplo n.º 28
0
 public IdleState(ElevatorController elevator) : base(elevator)
 {
 }
Ejemplo n.º 29
0
 protected State(ElevatorController elevator)
 {
     this.elevator = elevator;
 }
Ejemplo n.º 30
0
 public override void OnCollisionEnter2D(ElevatorController elevator, Collision2D collision)
 {
 }
Ejemplo n.º 31
0
    private ElevatorController GetClosestElevator(ElevatorController.Request request, ElevatorController elevator)
    {
        sameDirAndIdleElevators.Clear();
        otherElevators.Clear();

        for (int i = 0; i < elevators.Length; i++)
        {
            var el = elevators[i];

            if (el.IsRequestExists(request))
            {
                return(null);
            }

            if (el.IsIdle || el.MovingDirection == request.Direction)
            {
                sameDirAndIdleElevators.Add(el);
                continue;
            }

            otherElevators.Add(el);
        }

        if (sameDirAndIdleElevators.Count > 0)
        {
            sameDirAndIdleElevators.Sort((a, b) => Mathf.Abs(a.CurrFloorNum - request.FloorNum).CompareTo(Mathf.Abs(b.CurrFloorNum - request.FloorNum)));

            var bestElevator = sameDirAndIdleElevators[0];
            var minDist      = int.MaxValue;

            for (int i = 0; i < sameDirAndIdleElevators.Count; ++i)
            {
                var el = sameDirAndIdleElevators[i];

                if (el.CurrFloorNum != bestElevator.CurrFloorNum)
                {
                    break;
                }

                var dist = Mathf.Abs(el.Id - elevator.Id);

                if (dist < minDist)
                {
                    minDist      = dist;
                    bestElevator = el;
                }
            }

            return(bestElevator);
        }

        otherElevators.Sort((a, b) => a.RequestsCount.CompareTo(b.RequestsCount));
        return(otherElevators[0]);
    }
Ejemplo n.º 32
0
 public override void Update(ElevatorController elevator)
 {
 }