Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        // sets up scripts
        autoScrollCameraScript = FindObjectOfType <AutoScrollCameraScript>();
        cameraShakeScript      = FindObjectOfType <CameraShakeScript>();
        cameraZoomScript       = FindObjectOfType <CameraZoomScript>();
        lockedCameraScript     = FindObjectOfType <LockedCameraScript>();
        cameraSmoothingScript  = FindObjectOfType <CameraSmoothingScript>();

        dataManagerScript = FindObjectOfType <DataManagerScript>();

        //stores the player's Rigidbody2D
        rb = GetComponent <Rigidbody2D>();
    }
    // Start is called before the first frame update
    void Start()
    {
        // initialises scripts
        autoScrollCameraScript = FindObjectOfType <AutoScrollCameraScript>();
        lockedCameraScript     = FindObjectOfType <LockedCameraScript>();
        cameraSmoothingScript  = FindObjectOfType <CameraSmoothingScript>();
        cameraShakeScript      = FindObjectOfType <CameraShakeScript>();
        cameraZoomScript       = FindObjectOfType <CameraZoomScript>();

        playerMovementScript = FindObjectOfType <PlayerMovementScript>();

        // adds listeners to toggles
        autoScrollCameraToggle.onValueChanged.AddListener(delegate { SelectAutoScrollCamera(autoScrollCameraToggle); });
        lockedCameraToggle.onValueChanged.AddListener(delegate { SelectLockedCamera(lockedCameraToggle); });
        cameraSmoothingToggle.onValueChanged.AddListener(delegate { SelectCameraSmoothing(cameraSmoothingToggle); });
        cameraShakeToggle.onValueChanged.AddListener(delegate { SelectCameraShake(cameraShakeToggle); });
        cameraZoomToggle.onValueChanged.AddListener(delegate { SelectCameraZoom(cameraZoomToggle); });

        // adds listeners to input fields
        stepInputField.onEndEdit.AddListener(SetStepAmount);
        speedInputField.onEndEdit.AddListener(SetStepAmount);

        lockedXOffsetInputField.onEndEdit.AddListener(SetXOffset);
        lockedYOffsetInputField.onEndEdit.AddListener(SetYOffset);
        smoothingXOffsetInputField.onEndEdit.AddListener(SetXOffset);
        smoothingYOffsetInputField.onEndEdit.AddListener(SetYOffset);

        shakeLengthInputField.onEndEdit.AddListener(SetShakeLength);
        shakeMagnitudeInputField.onEndEdit.AddListener(SetShakeMagnitude);
        dampingSpeedInputField.onEndEdit.AddListener(SetDampingSpeed);

        zoomFactorInputField.onEndEdit.AddListener(SetZoomFactor);
        zoomSpeedInputField.onEndEdit.AddListener(SetZoomSpeed);

        playButton.onClick.AddListener(StartGame);
        quitButton.onClick.AddListener(QuitApplication);
    }