示例#1
0
    void Start()
    {
        setupCamera();
        _cameraSpeed = 5f;
        _mouseWeelZoomSensitivity = 20f;
        _acceleration             = 0f;
        _defaultLerpTime          = 2f;
        lerpTime = 2f;
        isManualControlEnabled = true;
        isLerping         = false;
        map1bounds.maxxyz = new Vector3(870f, 250.34f, 1067f);
        map1bounds.minxyz = new Vector3(-63f, 250.34f, 130f);

        actual_state = CameraInteractionState.STOPPED;
        last_state   = CameraInteractionState.STOPPED;
        setCameraZoom(40f);
        setCameraSpeed(40f);
        lookAtPoint(new Vector3(896.4047f, 90.51f, 581.8263f));

        if (mode == Cameramode.Campaign)
        {
            map1bounds.maxxyz = new Vector3(250f, 250.34f, 528f);
            map1bounds.minxyz = new Vector3(-63f, 250.34f, 147f);
            lookAtPoint(new Vector3(246f, 90.51f, -60));
            CAMERA_MAX_ZOOM = 5f;
            CAMERA_MIN_ZOOM = 50f;
        }
    }
示例#2
0
    /// <summary>
    /// Internal Camera method used to handle player input.
    /// </summary>
    private void handlePlayerInput()
    {
        last_state   = actual_state;
        actual_state = CameraInteractionState.STOPPED;

        if (Input.GetKey(KeyCode.UpArrow) || Input.mousePosition.y >= Screen.height - MOUSE_BOUNDS)
        {
            _internalDisplacement = Vector3.forward * Time.deltaTime * (_cameraSpeed + _acceleration);
            cameraContainer.transform.Translate(_internalDisplacement);
            actual_state = CameraInteractionState.MOVING;
        }

        if (Input.GetKey(KeyCode.LeftArrow) || Input.mousePosition.x <= MOUSE_BOUNDS)
        {
            _internalDisplacement = Vector3.left * Time.deltaTime * (_cameraSpeed + _acceleration);
            cameraContainer.transform.Translate(_internalDisplacement);
            actual_state = CameraInteractionState.MOVING;
        }

        if (Input.GetKey(KeyCode.DownArrow) || Input.mousePosition.y <= MOUSE_BOUNDS)
        {
            _internalDisplacement = Vector3.back * Time.deltaTime * (_cameraSpeed + _acceleration);
            Vector3 nextFramePosition = cameraContainer.transform.position + _internalDisplacement;
            cameraContainer.transform.Translate(_internalDisplacement);
            actual_state = CameraInteractionState.MOVING;
        }

        if (Input.GetKey(KeyCode.RightArrow) || Input.mousePosition.x >= Screen.width - MOUSE_BOUNDS)
        {
            _internalDisplacement = Vector3.right * Time.deltaTime * (_cameraSpeed + _acceleration);
            cameraContainer.transform.Translate(_internalDisplacement);
            actual_state = CameraInteractionState.MOVING;
        }

        if (actual_state == CameraInteractionState.MOVING)
        {
            _acceleration += BASE_ACCELERATION * Time.deltaTime;
            if (_acceleration > MAX_ACCELERATION)
            {
                _acceleration = MAX_ACCELERATION;
            }
        }
        else
        {
            _acceleration = 0f;
        }

        handleZoom();
    }
示例#3
0
    void Start()
    {
        setupCamera();
        _cameraSpeed = 5f;
        _mouseWeelZoomSensitivity = 20f;
        _acceleration = 0f;
        _defaultLerpTime = 2f;
        lerpTime = 2f;
        isManualControlEnabled = true;
        isLerping = false;
        map1bounds.maxxyz = new Vector3(870f, 250.34f, 1067f);
        map1bounds.minxyz = new Vector3(-63f, 250.34f, 130f);

        actual_state = CameraInteractionState.STOPPED;
        last_state = CameraInteractionState.STOPPED;
        setCameraZoom(40f);
        setCameraSpeed(40f);
        lookAtPoint(new Vector3(896.4047f, 90.51f, 581.8263f));

        if (mode == Cameramode.Campaign)
        {
            map1bounds.maxxyz = new Vector3(250f, 250.34f, 528f);
            map1bounds.minxyz = new Vector3(-63f, 250.34f, 147f);
            lookAtPoint(new Vector3(246f, 90.51f, -60));
            CAMERA_MAX_ZOOM = 5f;
            CAMERA_MIN_ZOOM = 50f;
        }
    }
示例#4
0
    /// <summary>
    /// Internal Camera method used to handle player input.
    /// </summary>
    private void handlePlayerInput()
    {
        last_state = actual_state;
        actual_state = CameraInteractionState.STOPPED;

        if ( Input.GetKey(KeyCode.UpArrow) || Input.mousePosition.y >= Screen.height - MOUSE_BOUNDS )
        {
            _internalDisplacement = Vector3.forward * Time.deltaTime * (_cameraSpeed + _acceleration);
            cameraContainer.transform.Translate(_internalDisplacement); 
            actual_state = CameraInteractionState.MOVING;
        }

        if ( Input.GetKey(KeyCode.LeftArrow) || Input.mousePosition.x <= MOUSE_BOUNDS )
        {
            _internalDisplacement = Vector3.left * Time.deltaTime * (_cameraSpeed + _acceleration);
            cameraContainer.transform.Translate(_internalDisplacement);
            actual_state = CameraInteractionState.MOVING;
        }

        if ( Input.GetKey(KeyCode.DownArrow) || Input.mousePosition.y <= MOUSE_BOUNDS )
        {
            _internalDisplacement = Vector3.back * Time.deltaTime * (_cameraSpeed + _acceleration);
            Vector3 nextFramePosition = cameraContainer.transform.position + _internalDisplacement;
            cameraContainer.transform.Translate(_internalDisplacement);          
            actual_state = CameraInteractionState.MOVING;
        }

        if ( Input.GetKey(KeyCode.RightArrow) || Input.mousePosition.x >= Screen.width - MOUSE_BOUNDS )
        {
            _internalDisplacement = Vector3.right * Time.deltaTime * (_cameraSpeed + _acceleration);
            cameraContainer.transform.Translate(_internalDisplacement); 
            actual_state = CameraInteractionState.MOVING;
        }

        if(actual_state == CameraInteractionState.MOVING)
        {
            _acceleration += BASE_ACCELERATION * Time.deltaTime;
            if (_acceleration > MAX_ACCELERATION) _acceleration = MAX_ACCELERATION;
        }
        else
        {
            _acceleration = 0f;
        }

        handleZoom();
    }
示例#5
0
        void HandleInput_MouseOrGamepad()
        {
            // update mouse/gamepad cursor
            MouseController.Update();

            // have to do this after cursor update in case hotkey uses mouse position
            HandleKeyboardInput();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_MouseGamepad(this);
            lastInputState = input;

            CameraInteractionState eCamState = (MouseCameraController != null)
                ? MouseCameraController.CheckCameraControls(input) : CameraInteractionState.Ignore;

            if (eCamState == CameraInteractionState.BeginCameraAction)
            {
                TerminateHovers(input);

                bInCameraControl = true;
                ActiveCamera.SetTargetVisible(true);
            }
            else if (eCamState == CameraInteractionState.EndCameraAction)
            {
                bInCameraControl = false;
                ActiveCamera.SetTargetVisible(false);
            }
            else if (bInCameraControl)
            {
                ActiveCamera.SetTargetVisible(true);
                MouseCameraController.DoCameraControl(Scene, ActiveCamera, input);
            }
            else
            {
                // run override behaviors
                overrideBehaviors.SendOverrideInputs(input);

                input.MouseGamepadCaptureActive = (captureMouse != null);

                if (InCaptureMouse)
                {
                    Capture cap = captureMouse.element.UpdateCapture(input, captureMouse.data);
                    if (cap.state == CaptureState.Continue)
                    {
                        // (carry on)
                    }
                    else if (cap.state == CaptureState.End)
                    {
                        captureMouse = null;
                    }
                }
                else
                {
                    // this is very simplistic...needs to be rewritten like space controllers

                    List <CaptureRequest> vRequests = new List <CaptureRequest>();
                    inputBehaviors.CollectWantsCapture(input, vRequests);
                    if (vRequests.Count > 0)
                    {
                        // end outstanding hovers
                        TerminateHovers(input);

                        // select one of the capture requests. technically we could end
                        //  up with none successfully Begin'ing, but behaviors should be
                        //  doing those checks in WantCapture, not BeginCapture !!
                        vRequests.OrderBy(x => x.element.Priority);
                        Capture capReq = null;
                        for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                        {
                            if (vRequests[i].side != CaptureSide.Any)
                            {
                                continue;       // not possible in mouse paths...
                            }
                            // before we actually begin capture we will complete any text editing
                            // [RMS] perhaps this should be configurable for behavior? Some behaviors
                            // do not require this (eg view controls...)
                            completeTextEntryOnFocusChange();

                            Capture c = vRequests[i].element.BeginCapture(input, vRequests[i].side);
                            if (c.state == CaptureState.Begin)
                            {
                                capReq = c;
                            }
                        }

                        captureMouse = capReq;
                    }
                }

                // if we don't have a capture, do hover
                if (captureMouse == null)
                {
                    inputBehaviors.UpdateHover(input);
                }
            }
        }