예제 #1
0
        /// <summary>
        /// Handles <see cref="GameController.WinConditionMet"/> event.
        /// </summary>
        /// <param name="sender">Event source.</param>
        /// <param name="e">A <see cref="WinConditionMetEventArgs"/> containing event data.</param>
        private void Controller_WinConditionMet(object sender, WinConditionMetEventArgs e)
        {
            controller.Timing?.Stop();
            WinningAnimation winningAnimation = new WinningAnimation(mapView, e)
            {
                Interval          = 100,
                AnimationTime     = 1500,
                CombinationLength = controller.WinningCombinationCount
            };

            mapView.MapViewClick      -= MapView_MapViewClick;
            mapView.ShowLastMarkedTile = false;

            Point middleTile = new Point();

            switch (e.Direction)
            {
            case WinningCombinationDirection.Horizontal:
                middleTile = new Point(e.CombinationStartingPoint.X + controller.WinningCombinationCount / 2,
                                       e.CombinationStartingPoint.Y);
                break;

            case WinningCombinationDirection.Diagonal:
                middleTile = new Point(e.CombinationStartingPoint.X + controller.WinningCombinationCount / 2,
                                       e.CombinationStartingPoint.Y + controller.WinningCombinationCount / 2);
                break;

            case WinningCombinationDirection.Vertical:
                middleTile = new Point(e.CombinationStartingPoint.X,
                                       e.CombinationStartingPoint.Y + controller.WinningCombinationCount / 2);
                break;

            case WinningCombinationDirection.AntiDiagonal:
                middleTile = new Point(e.CombinationStartingPoint.X - controller.WinningCombinationCount / 2,
                                       e.CombinationStartingPoint.Y + controller.WinningCombinationCount / 2);
                break;
            }

            mapView.CenterOnTile(middleTile);

            winningAnimation.Start();
        }