/// <summary>
        /// This method is used to Start the win game animation.
        /// </summary>
        void DoWinAmination()
        {
            (new System.Media.SoundPlayer(Properties.Resources.WinAudio)).Play();

            GameBoard.Opacity = 0.4;
            foreach (Ladder ladder in _ladders)
            {
                ladder.Opacity = 0.4;
            }
            foreach (Snake snake in _snakes)
            {
                snake.Opacity = 0.4;
            }

            (new System.Media.SoundPlayer(Properties.Resources.Applause)).Play();
            _winText             = new WinText(_currentToken);
            _winText.CanvasWidth = GameBoard.ActualWidth;
            if (_numOfPlayersLeft == (int)_enGameType)
            {
                _winText.Text = _currentToken.ToString() + " won the game!!!";
            }
            else if (_numOfPlayersLeft == (int)_enGameType - 1 && _numOfPlayersLeft > 1)
            {
                _winText.Text = "Second winner is " + _currentToken.ToString() + "!!!";
            }
            else if (_numOfPlayersLeft == (int)_enGameType - 2 && _numOfPlayersLeft > 1)
            {
                _winText.Text = "Third winner is " + _currentToken.ToString() + "!!!";
            }

            _winText.WinAnimation.Completed += WinAnimation_Completed;
            Canvas.SetLeft(_winText, (GameBoard.ActualWidth / 2) - (GameBoard.ActualWidth / 5));
            Canvas.SetTop(_winText, (GameBoard.ActualHeight / 2) - (GameBoard.ActualHeight / 15));
            BoardCanvas.Children.Add(_winText);

            _winText.StartAnimation();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for WinGame Text with animation.
        /// </summary>
        /// <param name="winningToken">The color which won the game.</param>
        public WinText(enGameToken winningToken)
        {
            InitializeComponent();
            DataContext   = this;
            _winAnimation = new DoubleAnimation();
            _winAnimation.FillBehavior   = FillBehavior.Stop;
            _winAnimation.Duration       = TimeSpan.FromSeconds(2);
            _winAnimation.AutoReverse    = true;
            _winAnimation.RepeatBehavior = new RepeatBehavior(2);
            _winAnimation.From           = 20;
            _winAnimation.To             = 35;
            _winAnimation.Completed     += WinAnimation_Completed;

            _colorAnimation = new ColorAnimation();
            _colorAnimation.FillBehavior   = FillBehavior.Stop;
            _colorAnimation.Duration       = TimeSpan.FromSeconds(2);
            _colorAnimation.AutoReverse    = true;
            _colorAnimation.RepeatBehavior = new RepeatBehavior(2);
            _colorAnimation.From           = Colors.Black;
            _colorAnimation.To             = (Color)System.Windows.Media.ColorConverter.ConvertFromString(winningToken.ToString());

            DropShadowEffect shadowEffect = new DropShadowEffect();

            shadowEffect.ShadowDepth = 0;
            shadowEffect.Color       = System.Windows.Media.Colors.LightGoldenrodYellow;// (System.Windows.Media.Color)(_color.GetValue(SolidColorBrush.ColorProperty));
            shadowEffect.BlurRadius  = 20;
            _WinText.Effect          = shadowEffect;


            shadowAnimation                = new DoubleAnimation();
            shadowAnimation.From           = 20;
            shadowAnimation.To             = 0;
            shadowAnimation.Duration       = TimeSpan.FromSeconds(2);
            shadowAnimation.RepeatBehavior = new RepeatBehavior(2);
            shadowAnimation.AutoReverse    = true;
            shadowAnimation.FillBehavior   = FillBehavior.Stop;
        }