/// <summary> /// Plays a series of beeps. /// </summary> /// <param name="beeper"></param> /// <param name="beeps">List of beeps to play.</param> /// <param name="amplitude">How loud to play. (100% defined as 255)</param> public static void PlayBeeps(this IBeeper beeper, List <Beep> beeps, uint amplitude = 255) { foreach (var beep in beeps) { beeper.PlayBeep(beep, amplitude); } }
public void SetUp() { _beeperMock = new Mock <IBeeper>(); _configMock = new Mock <IConfiguration>(); _timer = new TestTimer(); _beeper = _beeperMock.Object; _config = _configMock.Object; }
public BeepingWriter( Stream stream, IBeeper beeper, IBeepStreamWriter beepWriter ) { _stream = stream; _beeper = beeper; _beepWriter = beepWriter; }
public BeepingReader( Stream stream, IBeeper beeper, IBeepStreamReader beepReader ) { _beeper = beeper; _beepReader = beepReader; _stream = stream; _stream.Position = 0; }
//--------------------------------------------------------------------- public CountDownViewModel(ITimer timer, IConfiguration config, IBeeper beeper) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _startSeconds = config.StartSeconds; _secondsForYellow = config.SecondsForYellow; this.FontSize = config.FontSize; _timer = timer ?? throw new ArgumentNullException(nameof(timer)); _beeper = beeper ?? throw new ArgumentNullException(nameof(beeper)); }
/// <summary> /// Plays a scale /// </summary> /// <param name="startFrequency">Starting pitch.</param> /// <param name="endFrequency">Ending pitch.</param> /// <param name="totalDuration">Total duration for scales playback.</param> /// <param name="steps">Amount of notes to play.</param> public static void PlayScale(this IBeeper beeper, uint startFrequency, uint endFrequency, uint totalDuration, uint steps, uint amplitude = 255) { if (steps < 1) { return; } int i; uint f; uint d = (uint)(totalDuration / steps); float fs = (endFrequency - startFrequency) / (float)steps; for (i = 0; i < steps; i++) { f = (uint)(startFrequency + (fs * i)); beeper.PlayBeep(f, d, amplitude); } }
/// <summary> /// /// </summary> /// <param name="beeper"></param> /// <param name="beep">Note to play.</param> /// <param name="amplitude">How loud to play. (100% defined as 255)</param> public static void PlayBeep(this IBeeper beeper, Beep beep, uint amplitude = 255) { beeper.PlayBeep(beep.Freq, beep.Duration, amplitude); }
private static void Main(string[] args) { Debug = args.Contains("debug"); #endif Beeper = new Beeper(); BackgroundColor = ConsoleColor.Red; ForegroundColor = ConsoleColor.Yellow; _soundManager = new SoundManager(); _soundManager.Init(new Dictionary <string, string> { { "Intro", "testexetrisathlon.Intro.mp3" }, { "InGame1", "testexetrisathlon.InGame1.mp3" }, { "InGame2", "testexetrisathlon.InGame2.mp3" }, { "GameOver", "testexetrisathlon.GameOver.mp3" } }); SizeSetter.SetWindowSize(42, 29); if (Debug) { SizeSetter.SetWindowSize(50, 40); } SetCursorPosition(0, 0); bool playing = true; GameState state = GameState.Menu; try { while (playing) { switch (state) { case GameState.Menu: Clear(); _soundManager.SetCurrent(Intro); DrawSymbol(); SetCursorPosition(12, 18); Write("HighScore: " + SettingsMan.HighScore); SetCursorPosition(12, 20); Write("Controls: Space"); SetCursorPosition(13, 21); Write("Up, Down, Right"); SetCursorPosition(13, 22); Write("Left"); SetCursorPosition(12, 24); Write("Press s to start"); SetCursorPosition(12, 25); Write("Press x to exit"); SetCursorPosition(12, 26); Write("Press v for settings"); SetCursorPosition(0, 28); Write("Icon made by Freepik from www.flaticon.com"); string tmp = ReadKey(true).KeyChar.ToString().ToLower(); switch (tmp) { case "s": state = GameState.Game; Clear(); DrawBorder(); break; case "x": state = GameState.Exit; break; case "v": SettingsMenu(); break; } break; case GameState.Game: _soundManager.SetCurrent(InGame); _dropTimer.Start(); SetCursorPosition(25, 0); WriteLine("Level " + _level); SetCursorPosition(25, 1); WriteLine("Score " + _score + "/" + (Math.Pow(_level, 2) * 100)); SetCursorPosition(25, 2); WriteLine("LinesCleared " + _linesCleared); SetCursorPosition(25, 4); WriteLine("HighScore " + SettingsMan.HighScore); _nextTet = new Tetrominoe(); _tet = _nextTet; _tet.Spawn(); _nextTet = new Tetrominoe(); Update(); state = GameState.GameOver; break; case GameState.GameOver: SettingsMan.HighScore = _score; _soundManager.SetCurrent(GameOver); string input = ""; while (input != "y" && input != "n") { Clear(); DrawBorder(); Draw(); SetCursorPosition(0, 0); WriteLine("┌───────────────────┐"); WriteLine("│ Game Over │"); WriteLine("│ Replay? (Y/N) │"); WriteLine("├───────────────────┤"); input = ReadKey().KeyChar.ToString().ToLower(); } Grid = new int[23, 10]; DroppedTetrominoeLocationGrid = new int[23, 10]; _dropTimer = new Stopwatch(); _dropRate = 300; IsDropped = false; _isKeyPressed = false; _linesCleared = 0; _score = 0; _level = 1; GC.Collect(); Clear(); DrawBorder(); state = input == "y" ? GameState.Game : GameState.Menu; break; case GameState.Exit: playing = false; break; default: throw new ArgumentOutOfRangeException(); } } } finally { _soundManager.Dispose(); } BackgroundColor = Colors[0]; ForegroundColor = Colors[1]; SetCursorPosition(0, 0); Clear(); Beeper.Dispose(); }
public DoorControl(ICardDB cardDB, IDoor door, IBeeper beeper ) { _CardDB = cardDB; _Door = door; _Beeper = beeper; }