Beispiel #1
0
    private void Update()
    {
        if (Input.GetKeyDown(speedUp))
        {
            OnSpeedChange?.Invoke(_move.GetSpeedStep);
        }
        else if (Input.GetKeyDown(speedDown))
        {
            OnSpeedChange?.Invoke(-_move.GetSpeedStep);
        }

        if (Input.GetKeyDown(startPlane))
        {
            OnPlaneStart?.Invoke(_ship);
        }

        if (Input.GetKeyDown(startHunt))
        {
            OnHuntBegin?.Invoke();
        }

        if (Input.GetKeyDown(showPlaneInfo))
        {
            OnShowInfo?.Invoke();
        }
    }
Beispiel #2
0
 private void Move(Vector2 steering, float maxForce)
 {
     steering     = Truncate(steering, maxForce);
     steering    /= _rb.mass;
     _rb.velocity = Truncate(_rb.velocity + steering, _maxMoveSpeed);
     FollowTo();
     OnSpeedChange?.Invoke(_rb.velocity.magnitude);
 }
Beispiel #3
0
 private void ChangeSpeed(float value)
 {
     moveSpeed += value;
     if (moveSpeed > maxMoveSpeed)
     {
         moveSpeed = maxMoveSpeed;
     }
     else if (moveSpeed < minMoveSpeed)
     {
         moveSpeed = minMoveSpeed;
     }
     OnSpeedChange?.Invoke(moveSpeed);
 }
Beispiel #4
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (timeSlow)
            {
                timeSlow            = false;
                Time.timeScale      = 1f;
                Time.fixedDeltaTime = 0.02f;
            }
            else
            {
                timeSlow            = true;
                Time.timeScale      = slowTimeSpeed;
                Time.fixedDeltaTime = 0.02f * slowTimeSpeed;
            }
        }
        if (transform.position.y < -10 || Input.GetKeyDown(KeyCode.R))
        {
            transform.rotation = Quaternion.identity;
            sphereRB.velocity  = Vector3.zero;
            sphereRB.drag      = normalDrag;

            sphereRB.gameObject.transform.position = startPos;
            transform.position = startPos;

            OnGameOver?.Invoke();
            Debug.Log("GAME OVER!");
        }

        if (isGrounded && Time.timeScale == 1)
        {
            speed += speedIncrement;
            OnSpeedChange?.Invoke(speed);
            //speedText.text = speed.ToString("F2") + "\nkm/hr";
        }

        isDrifting = Input.GetButton("Jump");

        if (Input.GetKey(KeyCode.X) && nitrousAmt > 0f)
        {
            nitrousAmt            -= .06f;
            nitrousSpeedMultiplier = 2f;
            OnNitrousPickup?.Invoke(-.06f);

            // activate exhaust flames
            foreach (var n in nitrousFX)
            {
                n.gameObject.SetActive(true);
                n.Play();
            }
        }
        else
        {
            nitrousSpeedMultiplier = 1f;

            // deactivate exhaust flames
            foreach (var n in nitrousFX)
            {
                n.Pause();
                n.gameObject.SetActive(false);
            }
        }
    }