Esempio n. 1
0
    void OnTriggerStay(Collider collider)
    {
        if (Input.GetKeyUp(KeyCode.Space))
        {
            var ball = collider.gameObject;
            var rb   = ball.GetComponent <Rigidbody>();
            rb.AddForce(new Vector3(0, launchSpeed, 0), ForceMode.Impulse);
            soundsManager.PlayLauncher();
        }

        if (Input.GetKey(KeyCode.Space) && _lastUpdate + LightTimeStep < Time.time)
        {
            _lastUpdate = Time.time;
            launchSpeed = launchSpeed + step > maxLaunchSpeed ? maxLaunchSpeed : launchSpeed + step;
            var lightStep = maxLaunchSpeed / NumberOfLights;
            var lightsOn  = (int)(launchSpeed / lightStep);
            lightsManager.SwitchLauncherLights(lightsOn);
        }
    }