Exemplo n.º 1
0
        private void InitializeDigits()
        {
            digits_ = new KeyValuePair <Image, VisualCountdownDigit> [4];

            foreach (GameObject digitObject in Prefab.GetChildren())
            {
                // Child object names are "NR-3" "NR-2" "NR-1" and "NR-Rush"

                Image image = digitObject.GetComponent <Image>();
                VisualCountdownDigit digit;

                int number = 0;

                if (digitObject.name.Length >= 4 && int.TryParse(digitObject.name.Substring(3), out number))
                {
                    digit = new VisualCountdownDigit(-number, 0.75f);
                }
                else
                {
                    digit = new VisualCountdownDigit(0, 1.0f);
                }

                digits_[number] = new KeyValuePair <Image, VisualCountdownDigit>(image, digit);
            }
        }
Exemplo n.º 2
0
        public float GetInterpolation(float time, VisualCountdownDigit data)
        {
            float peak  = data.start + (data.duration / 2);
            float diff  = peak - data.start;
            float curve = (1 / diff * (-Mathf.Abs(time - data.start - diff))) + 1;

            return(Mathf.Max(0, curve));
        }