private void showWinner(GameResult gameResult)
        {
            string     victorySpriteFile = "";
            string     uriString         = "";
            Storyboard videoStoryboard   = null;

            //set the file name of the sprite to be loaded
            switch (gameResult)
            {
            case GameResult.Win:
                victorySpriteFile = "VictorySprite";
                uriString         = @"Resources/Audio/FanfareHuman.wav";
                videoStoryboard   = FindResource("AstroWinStoryboard") as Storyboard;
                break;

            case GameResult.Loss:
                victorySpriteFile = "DefeatSprite";
                uriString         = @"Resources/Audio/FanfareRobot.wav";
                videoStoryboard   = FindResource("AstroLossStoryboard") as Storyboard;
                PageX.SetValue(Canvas.LeftProperty, -140.0);
                break;

            case GameResult.Tie:
                victorySpriteFile = "TieSprite";
                uriString         = @"Resources/Audio/FanfareHuman.wav";
                videoStoryboard   = FindResource("AstroTieStoryboard") as Storyboard;
                PageX.SetValue(Canvas.LeftProperty, -140.0);
                break;
            }
            if (videoStoryboard != null)
            {
                videoStoryboard.Begin();
            }

            //play the correct fanfare
            VolumeManager.play(uriString);

            // Sprite resource name and width
            Sprite victorySprite = new Sprite(victorySpriteFile, 641, AnimationType.AnimateOnce)
            {
                Width  = 640,
                Height = 360,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Stretch             = Stretch.Uniform,
                Name   = victorySpriteFile,
                Margin = new Thickness(0, 0, 0, 0)
            };

            SpriteCanvas.Children.Add(victorySprite);
            Panel.SetZIndex(victorySprite, 3);
        }
示例#2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public PageXViewModel()
        {
            // Model initialisation
            this.PageX = new PageX()
            {
                Distance = 0
            };

            this.Length          = this.PageX.Length.ToString();
            this.Width           = this.PageX.Width.ToString();
            this.Distance        = this.PageX.Distance.ToString();
            this.EstimatedHeight = this.PageX.EstimatedHeight.ToString();
        }