예제 #1
0
        private void DisplaySituationHandler(Situation situation)
        {
            CreateStoryBoard(situation.HasMultistepAnimation());
            for (int i = 0; i < situation.animations.Length; i++)
            {
                if (situation.animations[i] != null)
                {
                    foreach (Situation.Animation animation in situation.animations[i])
                    {
                        AnimatePieceToPosition(animation.Piece, animation.Start, animation.End, i);
                    }
                }
            }
            StartAnimation();
            situation.ClearAnimations();

            // When animation is done, move all pieces to correct positions to account for non-animated moves
            board.Completed += (sender, args) =>
            {
                for (int i = 0; i < situation.pieces.Length; i++)
                {
                    Point p = GetAbsolutePosition(situation.pieces[i]);
                    Canvas.SetLeft(pieces[i], p.X);
                    Canvas.SetTop(pieces[i], p.Y);
                }
            };

            GreenBeer.BeerCount = situation.beers[(int)Piece.Green];
            RedBeer.BeerCount = situation.beers[(int)Piece.Red];
            BlueBeer.BeerCount = situation.beers[(int)Piece.Blue];
            YellowBeer.BeerCount = situation.beers[(int)Piece.Yellow];

            GreenTurnsLabel.Content = SinglePlayerData.Instance.GetTurnsRemainingExpectedValue(situation, Piece.Green).ToString("f2");
            RedTurnsLabel.Content = SinglePlayerData.Instance.GetTurnsRemainingExpectedValue(situation, Piece.Red).ToString("f2");
            BlueTurnsLabel.Content = SinglePlayerData.Instance.GetTurnsRemainingExpectedValue(situation, Piece.Blue).ToString("f2");
            YellowTurnsLabel.Content = SinglePlayerData.Instance.GetTurnsRemainingExpectedValue(situation, Piece.Yellow).ToString("f2");
        }