//Method stop the timmers couses game elements movement, change grids visibilty, //plane and obstacles position and etc. after game losing. private void gameLoss() { planeTimer.Stop(); birdTimer.Stop(); cloudTimer.Stop(); distanceTimer.Stop(); GamePlayGrid.Visibility = Visibility.Hidden; FinalScoreLabel.Content = UserPlane.Distance.ToString() + " m"; GameOver.Visibility = Visibility.Visible; UserPlane.SetStartPosition(); ObstacleBird.SetStartPosition(); ObstacleCloud.SetStartPosition(); UserPlane.DrawImage(); ObstacleBird.DrawImage(); ObstacleCloud.DrawImage(); User.Nick = this.NickTextBox.Text; User.Score = UserPlane.Distance; BoxScorses.Add(User); ListToXmlFile(); UserPlane.Distance = 0; gameStatus = Status.mainManu; }
//Method couses plane falling. On every timer tick, plane image //falls down. private void PlaneTimer_Tick(object sender, EventArgs e) { if (UserPlane.OnCanvasMax() == true) { UserPlane.Falling(); } }
//Method causes the float plane by pressing space key. private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Space && gameStatus == Status.gamePlay) { if (UserPlane.OnCanvasMin() == true) { UserPlane.Flying(); } } }
private void CloudTimer_Tick(object sender, EventArgs e) { if (ObstacleCloud.OnCanvas() == true) { ObstacleCloud.Flying(UserPlane.Distance); if (UserPlane.Collison(ObstacleCloud.PositionX, ObstacleCloud.PositionY, ObstacleCloud.Width, ObstacleCloud.Height) == true) { gameLoss(); } } else { ObstacleCloud.SetStartPosition(); } }