private void HandleLightShow(SimonButtons buttonIndex) { this.lightShowPresses.Remove(buttonIndex); this.lightShowPresses.Add(buttonIndex); switch (this.lightShowPresses.Count) { case 2: if ((buttonIndex ^ (SimonButtons)3) == this.lightShowPresses[0]) { this.coroutine = this.StartCoroutine(this.LightShowCoroutine(buttonIndex, this.LightShow2B)); } else { this.coroutine = this.StartCoroutine(this.LightShowCoroutine(buttonIndex, this.LightShow2A)); } break; case 3: this.coroutine = this.StartCoroutine(this.LightShowCoroutine(buttonIndex, this.LightShow3)); break; case 4: this.coroutine = this.StartCoroutine(this.LightShowCoroutine(buttonIndex, this.LightShow4)); break; default: this.coroutine = this.StartCoroutine(this.LightShowCoroutine(buttonIndex, this.LightShow1)); break; } }
private IEnumerator LightShowCoroutine(SimonButtons index, Func <IEnumerator> coroutine) { this.Connector.FlashLight(index); yield return(new WaitForSeconds(1.5f)); var enumerator = coroutine(); enumerator.MoveNext(); this.lightShowPresses.Clear(); this.coroutine = this.StartCoroutine(enumerator); }
public void FlashLight(SimonButtons button) { if (this.TestMode) { this.TestModelButtons[(int)button].Glow(); } #if (!DEBUG) else { this.buttons[(int)button].Glow(); } #endif }
public void TwitchPress(SimonButtons button) { if (this.TestMode) { TwitchExtensions.Click(this.TestModelButtons[(int)button]); } #if (!DEBUG) else { TwitchExtensions.Click(this.buttons[(int)button]); } #endif }
private static float GetTone(SimonButtons colour) { switch (colour) { case SimonButtons.Red: return(Cs5); case SimonButtons.Blue: return(E5); case SimonButtons.Green: return(G5); case SimonButtons.Yellow: return(B5); default: throw new ArgumentOutOfRangeException("colour"); } }
private IEnumerator LightShow3() { var indices = new SimonButtons[4]; this.lightShowPresses.CopyTo(indices); indices[3] = (SimonButtons)Enumerable.Range(0, 4).FirstOrDefault(i => !this.lightShowPresses.Contains((SimonButtons)i)); yield return(null); for (int i = 0; i < 16; ++i) { for (int j = 2; j >= 0; --j) { this.Connector.FlashLight(indices[j]); } yield return(new WaitForSeconds(0.5f)); var hold = indices[0]; for (int j = 0; j < 3; ++j) { indices[j] = indices[j + 1]; } indices[3] = hold; } }
private void CheckInput(SimonButtons correct) { if (!isGameSolved) { buttonSound.Play(); DisableButtons(); if (currentSol[currentIndex] != correct) { Failed(); } else { if (currentIndex < currentSol.Length - 1) { currentIndex++; } else { SolvedRound(); currentIndex = 0; } } } }
public IEnumerator TwitchHandleForcedSolve() { var directions = new SimonButtons[6, 6]; var x = this.x; var y = this.y; directions[x, y] = (SimonButtons)(-1); var queue = new Queue <Vector2Int>(); queue.Enqueue(new Vector2Int(x, y)); int count = 0; while (queue.Count > 0) { ++count; if (count > 2048) { throw new InvalidOperationException("Infinite loop in maze solver"); } var point = queue.Dequeue(); if (point.x == this.goalX && point.y == this.goalY) { var list = new List <SimonButtons>(); while (true) { var direction2 = directions[point.x, point.y]; if (direction2 < 0) { break; } list.Add(direction2); switch (direction2) { case SimonButtons.Green: --point.x; break; case SimonButtons.Red: --point.y; break; case SimonButtons.Blue: ++point.x; break; case SimonButtons.Yellow: ++point.y; break; } } for (int i = list.Count - 1; i >= 0; --i) { this.Connector.TwitchPress(list[i]); yield return(new WaitForSeconds(0.1f)); } yield break; } var direction = directions[point.x, point.y]; if (direction != SimonButtons.Blue && (mazes[this.mazeIndex, point.y, point.x] & MazeCell.WallEast) == 0) { queue.Enqueue(new Vector2Int(point.x + 1, point.y)); directions[point.x + 1, point.y] = SimonButtons.Green; } if (direction != SimonButtons.Yellow && (mazes[this.mazeIndex, point.y, point.x] & MazeCell.WallNorth) == 0) { queue.Enqueue(new Vector2Int(point.x, point.y + 1)); directions[point.x, point.y + 1] = SimonButtons.Red; } if (direction != SimonButtons.Green && point.x > 0 && (mazes[this.mazeIndex, point.y, point.x - 1] & MazeCell.WallEast) == 0) { queue.Enqueue(new Vector2Int(point.x - 1, point.y)); directions[point.x - 1, point.y] = SimonButtons.Blue; } if (direction != SimonButtons.Red && point.y > 0 && (mazes[this.mazeIndex, point.y - 1, point.x] & MazeCell.WallNorth) == 0) { queue.Enqueue(new Vector2Int(point.x, point.y - 1)); directions[point.x, point.y - 1] = SimonButtons.Yellow; } } throw new InvalidOperationException("Couldn't solve the maze?!"); }
public SimonButtonEventArgs(SimonButtons colour) { this.Colour = colour; }