// Update is called once per frame void Update() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } }
public void OnCheckedLianLianButton(object sender, RoutedEventArgs e) { LianLianKanButton button = sender as LianLianKanButton; if (_pairButton[0] != null) { _pairButton[1] = button; _pairButton[0].IsChecked = false; _pairButton[1].IsChecked = false; //判断是否是一对 bool success = false; if (_pairButton[0].PairID == _pairButton[1].PairID) { //只有是一对时,才去找路径。 var path = this.FindPathByRecursion(_mapReflex[_pairButton[0].Row, _pairButton[0].Col], _mapReflex[_pairButton[1].Row, _pairButton[1].Col]); if (path != null) { _pairButton[0].Checked -= OnCheckedLianLianButton; _pairButton[1].Checked -= OnCheckedLianLianButton; mapGrid.Children.Remove(_pairButton[0]); mapGrid.Children.Remove(_pairButton[1]); _mapReflex[_pairButton[0].Row, _pairButton[0].Col].HasButton = false; _mapReflex[_pairButton[1].Row, _pairButton[1].Col].HasButton = false; _remainNumberOfButton -= 2; if (_remainNumberOfButton == 0) { GameOverSound.Play(); RaiseEvent(new RoutedEventArgs(GameOverEvent)); } else { succeedToMatchSound.Play(); } success = true; } } _pairButton[0] = null; _pairButton[1] = null; //播放声音 if (success == false) { failToMatchSound.Play(); } } else { _pairButton[0] = button; } }
static public void PlayGameOverSound() { GameOverSound.Play(); }