Beispiel #1
0
    // Update is called once per frame
    private void Update()
    {
        if (m_pauseMenu != null && m_pauseMenu.isActiveAndEnabled)
        {
            return;
        }

        float   deltaTime  = Time.deltaTime;
        Vector3 pos        = transform.position;
        float   cameraSize = m_camera.orthographicSize;

        if (Sinput.GetButtonRaw("Left"))
        {
            pos.x -= m_moveSensitivity * deltaTime;
        }
        if (Sinput.GetButtonRaw("Right"))
        {
            pos.x += m_moveSensitivity * deltaTime;
        }
        if (Sinput.GetButtonRaw("Up"))
        {
            pos.y += m_moveSensitivity * deltaTime;
        }
        if (Sinput.GetButtonRaw("Down"))
        {
            pos.y -= m_moveSensitivity * deltaTime;
        }
        if (Sinput.GetButtonRaw("ZoomIn"))
        {
            cameraSize -= m_zoomSensitivity * deltaTime;
        }
        if (Sinput.GetButtonRaw("ZoomOut"))
        {
            cameraSize += m_zoomSensitivity * deltaTime;
        }

        cameraSize = Mathf.Clamp(cameraSize, 10, 75);
        pos.x      = Mathf.Clamp(pos.x, -m_cameraBounds + cameraSize, m_cameraBounds - cameraSize);
        pos.y      = Mathf.Clamp(pos.y, -m_cameraBounds + cameraSize, m_cameraBounds - cameraSize);

        transform.position        = pos;
        m_camera.orthographicSize = cameraSize;
    }
Beispiel #2
0
    // Update is called once per frame
    private void Update()
    {
        if (m_pauseMenu != null && m_pauseMenu.isActiveAndEnabled)
        {
            return;
        }

        bool    lastMoving    = moving;
        Vector3 deltaPosition = Vector3.zero;

        if (moving)
        {
            currentSpeed += increaseSpeed * Time.deltaTime;
        }

        moving = false;

        if (Sinput.GetButtonRaw("Up"))
        {
            DoMove(ref deltaPosition, transform.forward);
        }

        if (Sinput.GetButtonRaw("Down"))
        {
            DoMove(ref deltaPosition, -transform.forward);
        }

        if (Sinput.GetButtonRaw("Right"))
        {
            DoMove(ref deltaPosition, transform.right);
        }

        if (Sinput.GetButtonRaw("Left"))
        {
            DoMove(ref deltaPosition, -transform.right);
        }

        if (Sinput.GetButtonRaw("FlyUp"))
        {
            DoMove(ref deltaPosition, transform.up);
        }

        if (Sinput.GetButtonRaw("FlyDown"))
        {
            DoMove(ref deltaPosition, -transform.up);
        }


        if (moving)
        {
            if (moving != lastMoving)
            {
                currentSpeed = initialSpeed;
            }

            transform.position += deltaPosition * currentSpeed * Time.deltaTime;
        }
        else
        {
            currentSpeed = 0f;
        }

        Vector3 pos = transform.position;

        pos.x = Mathf.Clamp(pos.x, -30f, 30f);
        pos.y = Mathf.Clamp(pos.y, 1f, 15f);
        pos.z = Mathf.Clamp(pos.z, -20f, 60f);
        transform.position = pos;

        if (Sinput.GetButtonRaw("Fire2"))
        {
            Vector3 eulerAngles = transform.eulerAngles;
            eulerAngles.x        += -Sinput.GetAxis("Look Vertical") * m_cursorSensitivity;
            eulerAngles.y        += Sinput.GetAxis("Look Horizontal") * m_cursorSensitivity;
            transform.eulerAngles = eulerAngles;
        }
    }