Exemple #1
0
 /// <summary>
 /// Randomizes the colors of all <see cref="Ball"/> children attached
 /// to this script's game object.
 /// </summary>
 private void RandomizeBallColors()
 {
     foreach (Transform child in transform)
     {
         Ball ball = child.GetComponent <Ball>();
         ball.Color = NamedColors.GetRandom();
     }
 }
Exemple #2
0
        public static Color FromNamedColor(NamedColors namedColor)
        {
            var namedColorValue = (uint)namedColor;
            var b = namedColorValue & 0xFF;
            var g = (namedColorValue >> 8) & 0xFF;
            var r = (namedColorValue >> 16) & 0xFF;

            return(FromRgb((byte)r, (byte)g, (byte)b));
        }
Exemple #3
0
        public static Color?GetColor(string name)
        {
            Color color;

            if (NamedColors.TryGetValue(name, out color))
            {
                return(color);
            }

            return(null);
        }
Exemple #4
0
 /// <summary>
 /// Resets all disabled <see cref="Ball"/> children attached to this
 /// script's game object. To be called when a player's combo ends.
 /// </summary>
 public void ResetDisabledBalls()
 {
     foreach (Transform child in transform)
     {
         Ball ball = child.GetComponent <Ball>();
         if (!ball.enabled)
         {
             ball.Reset(NamedColors.GetRandom());
         }
     }
 }
Exemple #5
0
        private Settings()
        {
            Locales = new ObservableCollection <LocaleInfo>(JsonDeserializer.LoadFromJsonByFileName <LocaleInfo>(LocaleFileName));
            LoadColors();
            FontSizes = new ObservableCollection <double>()
            {
                13, 14, 15, 16
            };
            CurrentLocale         = Locales.First();
            CurrentNamedFontColor = NamedColors.Skip(1).First();
            CurrentFontSize       = FontSizes.First();

            PropertyChanged += Settings_PropertyChanged;
        }
Exemple #6
0
    /// <summary>
    /// Resets the combo count, target color, and balls in between combos.
    /// </summary>
    public void ResetCombo()
    {
        //award the player for maxing out their combo
        if (!Balls.ContainsAnyBallsWithColor(CurrentColor))
        {
            audio.pitch = 1 + ((currentCombo + 1) * 0.1f);
            audio.PlayOneShot(GoodClickSound);
            CurrentScore += currentCombo;
        }
        else
        {
            audio.PlayOneShot(BadClickSound);
        }

        currentCombo = 0;
        CurrentColor = NamedColors.GetRandomExcept(CurrentColor);
        Balls.ResetDisabledBalls();
    }
Exemple #7
0
    /// <summary>
    /// Called once, when this script is enabled.
    /// </summary>
    public void Start()
    {
        if (Balls == null)
        {
            Balls = FindObjectOfType <BallManager>();
        }
        Balls.LoadLevel(3, 5, NamedColors.Colors);

        if (UntilNextColorSlider != null)
        {
            UntilNextColorSlider.minValue = 0;
            UntilNextColorSlider.maxValue = ComboTimerMax;
            sliderFillImage = UntilNextColorSlider.GetComponentsInChildren <Image>().FirstOrDefault(c => c.name == "Fill");
        }

        CurrentColor   = NamedColors.GetRandom();
        CurrentScore   = 0;
        untilNextColor = ComboTimerMax;

        audio = GetComponent <AudioSource>();
    }