Esempio n. 1
0
        /// <summary>
        /// This method is used to circulate the gameplay between players. This ensures that the chance for users is sequencially moved.
        /// </summary>
        /// <param name="ienGameToken">Current token value</param>
        /// <param name="ienGameType">Current game type</param>
        /// <returns>New token value</returns>
        public static enGameToken Next(this enGameToken ienGameToken, enGameType ienGameType)
        {
            enGameToken newtoken = enGameToken.Green;

            if (ienGameToken == enGameToken.Green)
            {
                newtoken = enGameToken.Red;
            }
            else if (ienGameToken == enGameToken.Red && ienGameType == enGameType.TwoPlayer)
            {
                newtoken = enGameToken.Green;
            }
            else if (ienGameToken == enGameToken.Red && ienGameType != enGameType.TwoPlayer)
            {
                newtoken = enGameToken.Blue;
            }
            else if (ienGameToken == enGameToken.Blue && ienGameType == enGameType.ThreePlayer)
            {
                newtoken = enGameToken.Green;
            }
            else if (ienGameToken == enGameToken.Blue && ienGameType != enGameType.ThreePlayer)
            {
                newtoken = enGameToken.Yellow;
            }
            else if (ienGameToken == enGameToken.Yellow)
            {
                newtoken = enGameToken.Green;
            }
            return(newtoken);
        }
        /// <summary>
        /// Adds all the tokens on the board.
        /// This method clears any previously drawn tokens from the canvas.
        /// </summary>
        private void AddTokens()
        {
            foreach (Token token in _tokens)
            {
                BoardCanvas.RemoveToken(token);
            }
            _tokens.Clear();

            Point p1 = new Point(0, BoardCanvas.ActualHeight);
            Point p2 = new Point(0, BoardCanvas.ActualHeight - 15);
            Point p3 = new Point(0, BoardCanvas.ActualHeight - 30);
            Point p4 = new Point(0, BoardCanvas.ActualHeight - 45);

            Point[] pts = new Point[] { p1, p2, p3, p4 };

            enGameToken gametoken = enGameToken.Green;

            for (int i = 0; i < (int)_enGameType; i++)
            {
                Token token = new Token(this, gametoken, pts[i], BoardCanvas.ActualWidth, BoardCanvas.ActualHeight);
                gametoken = gametoken.Next(_enGameType);
                _tokens.Add(token);
                BoardCanvas.AddToken(token);
            }
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        public Token(object parentWindow, enGameToken engameToken, Point pos, double canvaswidth, double canvasheight)
        {
            InitializeComponent();
            _startPoint    = new Point(pos.X, pos.Y);
            DataContext    = this;
            _parentWindow  = parentWindow as Window;
            tokenAnimation = new DoubleAnimation();
            tokenAnimation.FillBehavior = FillBehavior.Stop;
            _tokenMoveSound             = new System.Media.SoundPlayer(Properties.Resources.TokenMoveBasic);// Windows Pop-up Blocked.wav");
            _tokenLadderMoveSound       = new System.Media.SoundPlayer(Properties.Resources.TokenMoveAudio);
            _tokenSnakeMoveSound        = new System.Media.SoundPlayer(Properties.Resources.SnakeAudio);
            //tokenAnimation.Completed += Animation_Completed;
            switch (engameToken)
            {
            case enGameToken.Blue:
                _color     = Brushes.Blue;
                _RingColor = Brushes.DarkBlue;
                break;

            case enGameToken.Red:
                _color     = Brushes.Red;
                _RingColor = Brushes.DarkRed;
                break;

            case enGameToken.Green:
                _color     = Brushes.Green;
                _RingColor = Brushes.ForestGreen;
                break;

            case enGameToken.Yellow:
                _color     = Brushes.Yellow;
                _RingColor = Brushes.Goldenrod;
                break;
            }
            _centerPoint = pos;

            _outerRing             = new Ellipse();
            _outerRing.DataContext = this;
            _outerRing.Stretch     = Stretch.Uniform;
            _outerRing.Fill        = Brushes.Transparent;
            _outerRing.SetBinding(Ellipse.StrokeProperty, "RingColor");
            _outerRing.SetBinding(Canvas.LeftProperty, "OuterRingLeft");
            _outerRing.SetBinding(Canvas.TopProperty, "OuterRingTop");
            _outerRing.SetBinding(Ellipse.HeightProperty, "OuterRingHeight");
            _outerRing.SetBinding(Ellipse.WidthProperty, "OuterRingWidth");
            _outerRing.SetBinding(Ellipse.StrokeThicknessProperty, "RingStrokeThickness");
            _outerRing.SetValue(Ellipse.NameProperty, "OuterRing");
            DropShadowEffect effect = new System.Windows.Media.Effects.DropShadowEffect();

            effect.BlurRadius      = EffectBlurRadius;
            effect.Direction       = 3;
            effect.ShadowDepth     = 0;
            _outerRing.Effect      = effect;
            _innerRing             = new Ellipse();
            _innerRing.DataContext = this;
            _innerRing.Stretch     = Stretch.Uniform;
            _innerRing.Fill        = Brushes.Transparent;
            _innerRing.SetBinding(Ellipse.StrokeProperty, "RingColor");
            _innerRing.SetBinding(Canvas.LeftProperty, "InnerRingLeft");
            _innerRing.SetBinding(Canvas.TopProperty, "InnerRingTop");
            _innerRing.SetBinding(Ellipse.HeightProperty, "InnerRingHeight");
            _innerRing.SetBinding(Ellipse.WidthProperty, "InnerRingWidth");
            _innerRing.SetBinding(Ellipse.StrokeThicknessProperty, "RingStrokeThickness");
            _innerRing.SetValue(Ellipse.NameProperty, "InnerRing");
            _innerRing.Effect = effect;

            _canvasHeight = canvasheight;
            _canvasWidth  = canvaswidth;


            MainCircleWidth     = canvaswidth / 18.0;
            RingStrokeThickness = canvaswidth / 280.0;

            OnPropertyChanged("Color");
            OnPropertyChanged("RingColor");
        }