private IEnumerator MoveToScale(Vector3 _target, BEAT_TYPE beatType)
    {
        if (beatType != type)
        {
            yield break;
        }

        Vector3 _curr    = transform.localScale;
        Vector3 _initial = _curr;
        float   _timer   = 0;

        while (_curr != _target)
        {
            switch (type)
            {
            case BEAT_TYPE.FULL:
                _curr = Vector3.Lerp(_initial, _target, _timer / timeToBeat);
                break;

            case BEAT_TYPE.HALF:
                _curr = Vector3.Lerp(_initial, _target, _timer / timeToBeatHalf);
                break;

            case BEAT_TYPE.QUARTER:
                _curr = Vector3.Lerp(_initial, _target, _timer / timeToBeatQuarter);
                break;
            }
            _timer += Time.deltaTime;
            transform.localScale = _curr;
            yield return(null);
        }

        m_isBeat = false;
    }
    public override void OnBeat(float val, BEAT_TYPE beatType)
    {
        base.OnBeat(val, beatType);

        StopCoroutine("MoveToScale");
        StartCoroutine(MoveToScale(beatScale, beatType));
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Notifies us when beat has occured
 /// </summary>
 /// <param name="value">Current spectrum value</param>
 public virtual void OnBeat(float value, BEAT_TYPE beatType)
 {
     // Debug.Log("beat " + beatType);
     timer    = 0;
     m_isBeat = true;
 }