Exemplo n.º 1
0
    public override void UpdateTimeline(float dt)
    {
        if (_trees != null)
        {
            for (int i = 0; i < _trees.Count; i++)
            {
                if (_trees[i] != null)
                {
                    _trees[i].rotation = Quaternion.Slerp(_trees[i].rotation, Quaternion.identity, dt * .25f);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Return) || Input.GetButtonDown("Submit"))
        {
            Timelines.DeactiveTimeline("epilogue");
            Timelines.ActivateTimeline("game");
        }
    }
Exemplo n.º 2
0
    public override void UpdateTimeline(float dt)
    {
        CheckForInputInvert();

        // dirty dirty movement easing
        // instead of using physics just gain speed with input and dampen speed when no input
        if (HasPlayerRotationInput())
        {
            float rotGainInverse = 1f / _rotationGain;
            _rotationInput += GetPlayerRotationInput() * dt * rotGainInverse;
        }
        else
        {
            float rotDampInverse = 1f / _rotationDampening;
            _rotationInput *= 1f - dt * rotDampInverse;
        }

        if (HasPlayerDilusionInput())
        {
            float dilGainInverse = 1f / _dilationGain;
            _dilationInput += GetPlayerDilusionInput() * dt * dilGainInverse;
        }
        else
        {
            float dilDampInverse = 1f / _dilationDampening;
            _dilationInput *= 1f - dt * dilDampInverse;
        }

        _dilationInput = Mathf.Clamp(_dilationInput, -1f, 1f);
        _rotationInput = Mathf.Clamp(_rotationInput, -1f, 1f);

        _dilationOffset += _dilationInput * dt * _dilationSpeed;
        _rotationOffset += _rotationInput * dt * TWO_PI * _rotationSpeed;

        _dilationOffset = Mathf.Clamp(_dilationOffset, MIN_DILATION_DISTANCE, MAX_DILATION_DISTANCE);

        // apply new offset
        // poll alive elements
        float count = 0f;

        for (int i = _elements.Count - 1; i >= 0f; i--)
        {
            if (!_elements[i].Dead)
            {
                count++;
            }
            else
            {
                _elements.RemoveAt(i);
            }
        }

        if (count <= 1)
        {
            // game over
            Timelines?.DeactiveTimeline("game");
            Timelines?.ActivateTimeline("epilogue");
        }

        //fade old count to new count to avoid teleporting the orbs
        _count = Mathf.Lerp(_count, count, dt * 1.5f);

        // make sure we don't divide by zero
        if (_count < 0.01f)
        {
            return;
        }

        for (int i = 0; i < _elements.Count; i++)
        {
            Vector3 pos = _elements[i].transform.localPosition;

            // fade old position to avoid teleporting the index of removed elements
            float radialpos = Mathf.Lerp(_elements[i].RadialPosition, i, dt * 1.5f);
            _elements[i].RadialPosition = radialpos;

            pos.x = Mathf.Sin(radialpos / _count * TWO_PI + _rotationOffset) * _dilationOffset;
            pos.y = Mathf.Cos(radialpos / _count * TWO_PI + _rotationOffset) * _dilationOffset;

            _elements[i].transform.localPosition = pos;
        }
    }