Пример #1
0
    public void Push(bool trigger)
    {
        Grabbable current = grabber.currentObject;

        GetComponent <TwoAxisMovement>().locked = trigger;
        if (current)
        {
            throwVis.SetActive(trigger);
            if (trigger)
            {
                if (!shakeSource.isPlaying)
                {
                    shakeSource.Play();
                }
            }
            else
            {
                if (shakeSource.isPlaying)
                {
                    shakeSource.Stop();
                }
            }
            if (trigger)
            {
                hasPressed = true;
                if (Mathf.Abs(current.magnitude) < current.maxMag)
                {
                    if (storedVelocity > 0)
                    {
                        current.ChangeVelocity(changeAmount);
                        storedVelocity -= changeAmount * Time.deltaTime;
                    }
                }
                storedVelocity = Mathf.Clamp(storedVelocity, 0, maxVelocity);
                GetComponent <Animator>().SetFloat("charge", storedVelocity / maxVelocity);
            }
            else
            {
                if (hasPressed)
                {
                    current.StopChange();
                    grabber.currentObject = null;
                    hasPressed            = false;
                    hasStopped            = false;
                    currentMode           = Mode.Pull;
                }
            }
        }
        else
        {
            hasPressed  = false;
            hasStopped  = false;
            currentMode = Mode.Pull;
        }
    }