コード例 #1
0
    private void Awake()
    {
        FloorButton.AddButtonPressedListener(ButtonHandler);

        _startPosition = transform.position;
        _endPosition   = _startPosition + _travelDirection * _maxDistance;
    }
コード例 #2
0
    void Start()
    {
        managementButtonText = managementButton.GetComponentInChildren <Text>();

        buttonAnim = managementButton.GetComponent <Animator>();
        paneAnim   = managementPane.GetComponent <Animator>();

        GameObject newButton;

        for (int i = OfficeGenerator.instance.floorCount - 1; i >= 0; i--)
        {
            FloorButton newFloor = Instantiate(floorsButtonPrefab, floorsContent).GetComponent <FloorButton>();
            newFloor.floorNo = i;
            floorButtons.Add(newFloor);
        }
        for (int i = 0; i < Director.Instance.employeePoolCount; i++)
        {
            newButton = Instantiate(employeesButtonPrefab, employeesContent);
            newButton.SetActive(false);
            employeeButtons.Add(newButton.GetComponent <EmployeeButton>());
        }
        for (int i = 0; i < OfficeGenerator.instance.floorCount * OfficeGenerator.instance.workspaceCount; i++)
        {
            newButton = Instantiate(facilitiesButtonPrefab, facilitiesContent);
            newButton.SetActive(false);
            facilityButtons.Add(newButton.GetComponent <FacilityButton>());
        }
        for (int i = 0; i < Businesses.instance.ListOfBusinesses.Count; i++)
        {
            newButton = Instantiate(businessesButtonPrefab, businessesContent);
            newButton.SetActive(false);
            businessButtons.Add(newButton.GetComponent <BusinessButton>());
        }
    }
コード例 #3
0
    private void Awake()
    {
        FloorButton.AddButtonPressedListener(ButtonPressedHandler);

        // do not need to bounding 'volume' of the renderer more so the direct size
        _moveStart = transform.position;
        _moveEnd   = _moveStart + (Vector3)_directionToMove.normalized * _distanceToTravel;
        _originalArrowDirection = transform.up;
        _collider = GetComponent <Collider2D>();
    }
コード例 #4
0
    public void BuildElevator()
    {
        int floorsNumber = 2;

        if (floorsNumberInput.text != "")
        {
            floorsNumber = System.Convert.ToInt32(floorsNumberInput.text);
        }
        if (floorsNumber < 2)
        {
            floorsNumber = 2;
        }
        if (floorsNumber > 100)
        {
            floorsNumber = 100;
        }

        MaximumFloor = floorsNumber;
        CurrentFloor = 1;
        Interfloor   = 1f;
        currentState = new WaitOnFloor();

        GameObject floorButtonPrefab = (GameObject)Resources.Load("floorButton");
        GameObject floorPrefab       = (GameObject)Resources.Load("Floor");


        for (int i = 1; i <= floorsNumber; i++)
        {
            GameObject  floorButtonObj = Instantiate(floorButtonPrefab, elevatorPanelButtonsTransform);
            FloorButton floorButton    = floorButtonObj.GetComponent <FloorButton> ();
            floorButton.SetFloor(i);
            floorButton.IsActive = false;

            GameObject floorObj = Instantiate(floorPrefab, floorsTransform);
            Floor      floor    = floorObj.GetComponent <Floor> ();
            onFloorChanged += floor.SetCurrentElevatorFloorNumber;
            floor.SetFloor(floorsNumber + 1 - i);
            floor.SetCurrentElevatorFloorNumber(CurrentFloor);

            floors.Add(floor.FloorNumber, floor);
        }
        elevatorPanelUpdater.UpdateRect();
        floorsUpdater.UpdateRect();



        startPage.SetActive(false);
    }
コード例 #5
0
ファイル: Program.cs プロジェクト: bikerpro47/dragoncode
        static void Main(string[] args)
        {
            // Create 3 elevators
            var el1 = new Elevator
            {
                Name         = "Elevator No 1",
                CurrentFloor = 1
            };
            var el2 = new Elevator
            {
                Name         = "Elevator No 2",
                CurrentFloor = 5
            };
            var el3 = new Elevator
            {
                Name         = "Elevator No 3",
                CurrentFloor = 10
            };

            // Create elevator buttons on some floors
            var fb1 = new FloorButton {
                FloorNo = 1, Direction = RequestDir.NOT_PRESSED
            };
            var fb2 = new FloorButton {
                FloorNo = 2, Direction = RequestDir.NOT_PRESSED
            };
            var fb7 = new FloorButton {
                FloorNo = 7, Direction = RequestDir.NOT_PRESSED
            };
            var fb9 = new FloorButton {
                FloorNo = 9, Direction = RequestDir.NOT_PRESSED
            };

            // People press some buttons to summon an elevator
            WhichElevator.
            fb1.Direction = RequestDir.UP;
            fb9.Direction = RequestDir.DOWN;
            fb2.Direction = RequestDir.DOWN;
            fb7.Direction = RequestDir.UP;


            Console.WriteLine($"{el1.Name} is on Floor Number {el1.CurrentFloor}");

            Console.ReadLine();
        }
コード例 #6
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 ");
                    }
                }
            }
        }