コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Makas9/NoOpRunner
 /// <summary>
 /// Set up background, more images to make depth feel
 /// </summary>
 private void SetUpBackground()
 {
     for (int i = 1; i < 6; i++)
     {
         background_panel.Children.Add(new Image()
         {
             Source = new BitmapImage(ResourcesUriHandler.GetBackground(i)), Stretch = Stretch.Fill
         });
     }
 }
コード例 #2
0
        public PlayerSpeedBoostDecorator(IVisualElement player) : base(player)
        {
            MediaPlayer = new MediaPlayer();

            MediaPlayer.Open(ResourcesUriHandler.GetPowerUpSound(PowerUps.Speed_Boost));

            MediaPlayer.MediaEnded += (o, a) =>
            {
                MediaPlayer.Position = TimeSpan.Zero;
                MediaPlayer.Play();
            };

            MediaPlayer.Volume = 0.01;
            MediaPlayer.Play();
        }
コード例 #3
0
        public override void Display(Canvas canvas)
        {
            Logging.Instance.Write("Player decorator: Displaying Double jump animation", LoggingLevel.Pattern);

            var doubleJumpAnimation = canvas.Children.OfType <GifImage>().FirstOrDefault(x => x.VisualType == VisualElementType.DoubleJump);

            if (doubleJumpAnimation == null)
            {
                doubleJumpAnimation = new GifImage
                {
                    VisualType = VisualElementType.DoubleJump,
                    GifSource  = ResourcesUriHandler.GetPlayerPowerUp(VisualElementType.DoubleJump),
                    Stretch    = Stretch.Fill
                };

                canvas.Children.Add(doubleJumpAnimation);
            }

            base.Display(canvas);
        }
コード例 #4
0
        public override void Display(Canvas canvas)
        {
            Logging.Instance.Write("Player decorator: Displaying Invulnerability animation", LoggingLevel.Pattern);

            var playerInvincibilityAnimation = canvas.Children.OfType <GifImage>().FirstOrDefault(x => x.VisualType == VisualElementType.Invulnerability);

            if (playerInvincibilityAnimation == null)
            {
                playerInvincibilityAnimation = new GifImage
                {
                    VisualType = VisualElementType.Invulnerability,
                    GifSource  = ResourcesUriHandler.GetPlayerPowerUp(VisualElementType.Invulnerability),
                    Stretch    = Stretch.Fill
                };

                canvas.Children.Add(playerInvincibilityAnimation);
            }

            base.Display(canvas);
        }
コード例 #5
0
        public void Display(Canvas canvas)
        {
            var rectangleWidth  = canvas.ActualWidth / PlatformsContainer.SizeX;
            var rectangleHeight = canvas.ActualHeight / PlatformsContainer.SizeY;

            var pixels = PlatformsContainer.GetShapesEnumerable().ToList();

            if (canvas.Children.Count != pixels.Count)
            {
                canvas.Children.Clear();

                var imageBrush = new ImageBrush(new BitmapImage(ResourcesUriHandler.GetPlatformUri()));

                foreach (var pixel in pixels)
                {
                    var rec = new Rectangle
                    {
                        Width  = rectangleWidth,
                        Height = rectangleHeight,
                        Fill   = imageBrush
                    };
                    Canvas.SetLeft(rec, rectangleWidth * pixel.X);
                    Canvas.SetBottom(rec, rectangleHeight * pixel.Y);

                    canvas.Children.Add(rec);
                }
            }
            else
            {
                for (int i = 0; i < pixels.Count; i++)
                {
                    canvas.Children[i].SetValue(FrameworkElement.WidthProperty, rectangleWidth);
                    canvas.Children[i].SetValue(FrameworkElement.HeightProperty, rectangleHeight);

                    Canvas.SetLeft(canvas.Children[i], rectangleWidth * pixels[i].X);
                    Canvas.SetBottom(canvas.Children[i], rectangleHeight * pixels[i].Y);
                }
            }
        }
コード例 #6
0
ファイル: PowerUpsRenderer.cs プロジェクト: Makas9/NoOpRunner
        public void Display(Canvas canvas)
        {
            var rectangleWidth  = canvas.ActualWidth / PowerUpsContainer.SizeX;
            var rectangleHeight = canvas.ActualHeight / PowerUpsContainer.SizeY;


            var pixels = PowerUpsContainer.GetPowerUpsEnumerable();

            if (canvas.Children.Count != pixels.Count)
            {
                canvas.Children.Clear();

                foreach (var(windowPixel, powerUp) in pixels)
                {
                    var rec = new Rectangle
                    {
                        Width   = rectangleWidth,
                        Height  = rectangleHeight,
                        Fill    = new ImageBrush(new BitmapImage(ResourcesUriHandler.GetPowerUp(powerUp))),
                        Stretch = Stretch.Fill
                    };
                    Canvas.SetLeft(rec, rectangleWidth * windowPixel.X);
                    Canvas.SetBottom(rec, rectangleHeight * windowPixel.Y);

                    canvas.Children.Add(rec);
                }
            }
            else
            {
                for (int i = 0; i < pixels.Count; i++)
                {
                    canvas.Children[i].SetValue(Canvas.WidthProperty, rectangleWidth);
                    canvas.Children[i].SetValue(Canvas.HeightProperty, rectangleHeight);

                    Canvas.SetLeft(canvas.Children[i], rectangleWidth * pixels[i].Item1.X);
                    Canvas.SetBottom(canvas.Children[i], rectangleHeight * pixels[i].Item1.Y);
                }
            }
        }