public Entity ReplaceShake(ShakeProperties newProperties)
 {
     var component = CreateComponent<ShakeComponent>(ComponentIds.Shake);
     component.properties = newProperties;
     ReplaceComponent(ComponentIds.Shake, component);
     return this;
 }
Exemplo n.º 2
0
    public void StartShake(ShakeProperties properties)
    {
        if (currentShakeCoroutine != null)
        {
            StopCoroutine(currentShakeCoroutine);
        }

        currentShakeCoroutine = Shaking(properties);
        StartCoroutine(currentShakeCoroutine);
    }
Exemplo n.º 3
0
    private IEnumerator shake_camera_action(ShakeProperties shake_properties)
    {
        var   cPos      = m_test_cam.transform.position;
        float xInc      = shake_properties.IncrementVectorMap.x;
        float yInc      = shake_properties.IncrementVectorMap.y;
        float shakeTime = shake_properties.Duration;

        cPos = new Vector3(cPos.x - xInc, cPos.y - yInc, cPos.z);
        m_test_cam.transform.position = cPos;

        yield return(new WaitForSeconds(shakeTime));

        cPos = new Vector3(cPos.x + xInc, cPos.y + yInc, cPos.z);
        m_test_cam.transform.position = cPos;
        yield break;
    }
Exemplo n.º 4
0
        public void Shake(ShakeProperties properties)
        {
            if (Mathf.Approximately(properties.duration, 0))
            {
                return;
            }
            maximumStrength   = properties.maximumStrength;
            frequency         = properties.frequency;
            fallOffSmoothness = properties.smoothness;
            recoveryRate      = 1 / properties.duration;
            stopTime          = JuicyUtils.Time(properties.ignoreTimeScale) + properties.duration;

            ease            = properties.falloffCurve;
            ignoreTimeScale = properties.ignoreTimeScale;
            recoverySpeed   = Mathf.Max(0.1f, properties.recoverySpeed);

            fallOff = properties.power;
            seed    = Random.value;

            shaking = true;
        }
Exemplo n.º 5
0
    IEnumerator Shaking(ShakeProperties properties)
    {
        float completionPercent = 0;
        float movePercent       = 0;
        float angleRadians      = properties.angle * Mathf.Deg2Rad - Mathf.PI;
        float moveDistance      = 0;

        Vector3 previousWaypoint = Vector3.zero;
        Vector3 currentWaypoint  = Vector3.zero;

        Quaternion targetRotation   = Quaternion.identity;
        Quaternion previousRotation = Quaternion.identity;


        do
        {
            if (movePercent >= 1 || completionPercent == 0)
            {
                float dampingFactor = DampingCurve(completionPercent, properties.dampingPercent);
                float noiseAngle    = (Random.value - 0.5f) * Mathf.PI;

                angleRadians    += Mathf.PI + noiseAngle * properties.noisePercent;
                previousWaypoint = transform.localPosition;
                currentWaypoint  = new Vector3(Mathf.Cos(angleRadians), Mathf.Sin(angleRadians)) * properties.strength * dampingFactor;

                moveDistance = Vector3.Distance(previousWaypoint, currentWaypoint);
                movePercent  = 0;

                targetRotation   = Quaternion.Euler(new Vector3(currentWaypoint.x, currentWaypoint.y).normalized *properties.rotationPercent *dampingFactor *maxAngle);
                previousRotation = transform.localRotation;
            }

            completionPercent      += Time.deltaTime / properties.duration;
            movePercent            += Time.deltaTime / moveDistance * properties.speed;
            transform.localPosition = Vector3.Lerp(previousWaypoint, currentWaypoint, movePercent);
            transform.localRotation = Quaternion.Lerp(previousRotation, targetRotation, movePercent);
            yield return(null);
        }  while (moveDistance > 0);
    }
 public Entity AddShake(ShakeProperties newProperties)
 {
     var component = CreateComponent<ShakeComponent>(ComponentIds.Shake);
     component.properties = newProperties;
     return AddComponent(ComponentIds.Shake, component);
 }
Exemplo n.º 7
0
 public void ShakeCamera(ShakeProperties shake_properties)
 {
     Debug.Log(shake_properties);
     StartCoroutine(shake_camera_action(shake_properties));
 }