Exemplo n.º 1
0
        private void Update()
        {
            this._container.transform.localScale = (this.rotationDirection == RotationDirection.CLOCKWISE) ? new Vector3(1.0f, 1.0f, 1.0f) : new Vector3(-1.0f, 1.0f, 1.0f);

            foreach (KeyValuePair <RhythmSequenceKeyframe, RhythmSequenceKeyframeVisualizer> pair in this._visualizerMap)
            {
                RhythmSequenceKeyframe           keyframe           = pair.Key;
                RhythmSequenceKeyframeVisualizer keyframeVisualizer = pair.Value;

                float timePassed    = this._sequence.GetTimePassed();
                float timeRemaining = keyframe.timePassed - timePassed;

                float angle = 180.0f * Mathf.Clamp(1.0f - timeRemaining, 0.0f, 1.2f);

                Vector3 computedPosition = this._radius * (Quaternion.AngleAxis(angle, -Vector3.forward) * new Vector3(-1.0f, 0.0f, 0.0f));
                keyframeVisualizer.transform.localPosition = computedPosition;

                Color visualColor = Color.red;
                if (Mathf.Abs(timeRemaining) <= GameConstants.Instance.kPerfectTimingThreshold)
                {
                    visualColor = Color.green;
                }
                else if (Mathf.Abs(timeRemaining) <= GameConstants.Instance.kGoodTimingThreshold)
                {
                    visualColor = Color.yellow;
                }
                visualColor = new Color(visualColor.r, visualColor.g, visualColor.b, 0.8f);
                keyframeVisualizer.SetColor(visualColor);

                // keyframeVisualizer.UpdateWithTimeRemaining(timeRemaining);
            }
        }
Exemplo n.º 2
0
        private void HandleSequenceKeyframesChanged()
        {
            this._visualizerMap.Clear();
            this._container.SetActive(true);

            foreach (RhythmSequenceKeyframe keyframe in this._sequence.Keyframes)
            {
                GameObject keyframeVisualizerObject = Toolbox.GetInstance <ObjectPoolManager>().Instantiate("RhythmSequenceKeyframeVisualizer");
                keyframeVisualizerObject.transform.SetParent(this._container.transform, worldPositionStays: false);

                RhythmSequenceKeyframeVisualizer keyframeVisualizer = keyframeVisualizerObject.GetComponent <RhythmSequenceKeyframeVisualizer>();
                this._visualizerMap[keyframe] = keyframeVisualizer;
            }
        }