public void AddColor() { SimonColor color = (SimonColor)_random.Next(3); _sequence[_sequenceLength] = color; _sequenceLength++; }
private void BlinkColor(SimonColor color) { for (int i = 0; i < 5; i++) { PlayColor(color, 200); Thread.Sleep(100); } }
public void PlaySequence() { for (int index = 0; index < _sequenceLength; index++) { SimonColor color = _sequence[index]; PlayColor(color, 1000); Thread.Sleep(150); } }
protected void AddRules(SimonRuleSet ruleSet, string key, int num) { ruleSet.RuleList.Add(key, new List <SimonColor[]>()); for (var i = 0; i <= num; i++) { var array = new SimonColor[Enum.GetNames(typeof(SimonColor)).Length]; for (var j = 0; j < Enum.GetNames(typeof(SimonColor)).Length; j++) { array[j] = (SimonColor)rand.Next(Enum.GetNames(typeof(SimonColor)).Length); } if (CommonReflectedTypeInfo.IsModdedSeed) { while (array.Distinct().Count() == 1) { array[rand.Next(Enum.GetNames(typeof(SimonColor)).Length)] = (SimonColor)rand.Next(Enum.GetNames(typeof(SimonColor)).Length); } } ruleSet.RuleList[key].Add(array); } }
private void PlayColor(SimonColor color, int milliseconds) { switch (color) { case SimonColor.Blue: HighlightButton(btnBlue, Color.DeepSkyBlue, milliseconds); break; case SimonColor.Red: HighlightButton(btnRed, Color.OrangeRed, milliseconds); break; case SimonColor.Green: HighlightButton(btnGreen, Color.LimeGreen, milliseconds); break; case SimonColor.Yellow: HighlightButton(btnYellow, Color.Yellow, milliseconds); break; } }
private void ColorPressed(SimonColor color) { EndUserInput(); if (color != _sequence[_playerSequencePosition]) { BlinkColor(_sequence[_playerSequencePosition]); GameOver(); return; } PlayColor(color, 700); _playerSequencePosition++; if (_playerSequencePosition >= _sequenceLength) { Thread.Sleep(700); _playerSequencePosition = 0; AddColor(); PlaySequence(); StartUserInput(); } }
public void PressButton(SimonColor color) { bombSequence.Add(color); CalculateSolution(); }
public SimonColor GetButtonToPress(SimonColor color) { // Serial number contains a vowel if (serialContainsVowel.HasValue && serialContainsVowel.Value) { if (numStrikes == 0) { if (color == SimonColor.Red) { return(SimonColor.Blue); } else if (color == SimonColor.Blue) { return(SimonColor.Red); } else if (color == SimonColor.Green) { return(SimonColor.Yellow); } else if (color == SimonColor.Yellow) { return(SimonColor.Green); } } else if (numStrikes == 1) { if (color == SimonColor.Red) { return(SimonColor.Yellow); } else if (color == SimonColor.Blue) { return(SimonColor.Green); } else if (color == SimonColor.Green) { return(SimonColor.Blue); } else if (color == SimonColor.Yellow) { return(SimonColor.Red); } } else if (numStrikes == 2) { if (color == SimonColor.Red) { return(SimonColor.Green); } else if (color == SimonColor.Blue) { return(SimonColor.Red); } else if (color == SimonColor.Green) { return(SimonColor.Yellow); } else if (color == SimonColor.Yellow) { return(SimonColor.Blue); } } } // Serial number does NOT contain a vowel else { if (numStrikes == 0) { if (color == SimonColor.Red) { return(SimonColor.Blue); } else if (color == SimonColor.Blue) { return(SimonColor.Yellow); } else if (color == SimonColor.Green) { return(SimonColor.Green); } else if (color == SimonColor.Yellow) { return(SimonColor.Red); } } else if (numStrikes == 1) { if (color == SimonColor.Red) { return(SimonColor.Red); } else if (color == SimonColor.Blue) { return(SimonColor.Blue); } else if (color == SimonColor.Green) { return(SimonColor.Yellow); } else if (color == SimonColor.Yellow) { return(SimonColor.Green); } } else if (numStrikes == 2) { if (color == SimonColor.Red) { return(SimonColor.Yellow); } else if (color == SimonColor.Blue) { return(SimonColor.Green); } else if (color == SimonColor.Green) { return(SimonColor.Blue); } else if (color == SimonColor.Yellow) { return(SimonColor.Red); } } } return(SimonColor.Invalid); }
private void button_Click(object sender, EventArgs e) { SimonColor color = GetColorFromButton((Button)sender); ColorPressed(color); }