// метод, отвечающий за старт игры private void StartGame() { currentLevel = GetCurrentLevel(); LoadCurrentLevel(currentLevel); Cursor.Position = GetStartPosition(currentLevel); AddEventsMouseEnter(currentLevel); PlaySound.PlayMusic(Sound.start); }
private void restartGame() { PlaySound.PlayMusic(Sound.fail); if (MessageBox.Show("Вы проиграли! Ещё разок?", "Неудача...", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { StartGame(); } else { this.Close(); } }
private void finishGame() { numberCurrentLevel++; if (numberCurrentLevel == listLevelType.Count) { PlaySound.PlayMusic(Sound.victory); MessageBox.Show("Вы прошли лабиринт! Поздравляю!!!"); this.Close(); } else { PlaySound.PlayMusic(Sound.finish); MessageBox.Show("Уровень пройден!"); StartGame(); } }
private void checkKey(object sender) { Key _key = (Key)(from key in currentLevel.Controls.Cast <UserControl>() where key is Key && key.BackColor == (sender as Door).BackColor select key).FirstOrDefault(); if (_key.Visible) { restartGame(); } else { PlaySound.PlayMusic(Sound.key); (sender as Door).Visible = false; } }
private void control_MouseEnter(object sender, EventArgs e) { if (sender is Wall || sender is Flashing_wall) { restartGame(); } if (sender is Finish) { finishGame(); } if (sender is Key) { (sender as Key).Visible = false; PlaySound.PlayMusic(Sound.key); } if (sender is Door) { checkKey(sender); } if (sender is Ice) { DanceMouse(); } }