public OrcasAvalonApplicationCanvas() { Width = DefaultWidth; Height = DefaultHeight; this.ClipToBounds = true; Colors.Blue.ToGradient(Colors.Black, DefaultHeight / 4).Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 5, }.MoveTo(0, i * 4).AttachTo(this) ).ToArray(); var mouse = new Image { Source = (KnownAssets.Path.Assets + "/mouse.png").ToSource(), Width = 32, Height = 32 }.MoveTo(0, 0).AttachTo(this); var img = new Image { Source = (KnownAssets.Path.Assets + "/jsc.png").ToSource() }.MoveTo(DefaultWidth - 96, 0).AttachTo(this); var Content = new Canvas { Width = DefaultWidth, Height = DefaultHeight, }.AttachTo(this); var ContentY = new AnimatedDouble(0); ContentY.ValueChanged += y => Content.MoveTo(0, y); { var maze = new MazeGenerator(12, 8, null); var blocks = new BlockMaze(maze); var w = new BlockMaze(maze); Colors.Black.ToGradient(Colors.Yellow, 30).ForEach( (c, i) => RenderMaze(60 + i * 0.1, w, new SolidColorBrush(c), Content) ); } var TouchOverlay = new Rectangle { Fill = Brushes.Yellow, Opacity = 0, Width = DefaultWidth, Height = DefaultHeight }.AttachTo(this); TouchOverlay.MouseEnter += delegate { mouse.Show(); }; TouchOverlay.MouseLeave += delegate { mouse.Hide(); }; TouchOverlay.Cursor = Cursors.None; TouchOverlay.MouseMove += (s, args) => { var p = args.GetPosition(this); mouse.MoveTo(p.X - 4, p.Y - 4); }; TouchOverlay.MouseLeftButtonUp += (s, args) => { var p = args.GetPosition(this); ShowExplosion(Convert.ToInt32(p.X), Convert.ToInt32(p.Y), Content); ("assets/AvalonMouseMaze/explosion.mp3").PlaySound(); 150.AtDelay( delegate { ShowExplosion(Convert.ToInt32(p.X + 6), Convert.ToInt32(p.Y - 6), Content); } ); 300.AtDelay( delegate { ShowExplosion(Convert.ToInt32(p.X + 4), Convert.ToInt32(p.Y + 6), Content); ContentY.SetTarget(DefaultHeight); } ); 1500.AtDelay( delegate { ContentY.SetTarget(0); } ); }; new GameMenuWithGames(DefaultWidth, DefaultHeight, 32).AttachContainerTo(this).Hide(); }
private void StartAnimation(List<Entry> List) { double y = new Random().NextDouble() * List.Count * 3; const double maxspeed = 0.1; var aspeed = new AnimatedDouble(-maxspeed); var bspeed = new AnimatedDouble(1); this.MouseEnter += delegate { bspeed.SetTarget(0.4); foreach (var k in List) { k.Shadow.Opacity = 0.5; k.ShadowBottom.Opacity = 0.7; k.Text.Show(); } }; this.MouseLeave += delegate { bspeed.SetTarget(1); foreach (var k in List) { k.Shadow.Opacity = 0; k.ShadowBottom.Opacity = 0; k.Text.Hide(); } }; (1000 / 30).AtInterval( delegate { y += aspeed.Value * bspeed.Value * 0.1; if (aspeed.Value > 0) if (y > List.Count * 3) { aspeed.SetTarget(maxspeed / 2); 300.AtDelay( () => aspeed.SetTarget(-maxspeed / 2) ); 500.AtDelay( () => aspeed.SetTarget(-maxspeed) ); } if (aspeed.Value < 0) if (y < 0) { aspeed.SetTarget(-maxspeed / 2); 300.AtDelay( () => aspeed.SetTarget(maxspeed / 2) ); 500.AtDelay( () => aspeed.SetTarget(maxspeed) ); } List.ForEach( (Entry c, int i) => { if (Convert.ToInt32(Math.Floor(y)) % 4 > 1) { var qy = ((i + 1) * GameReferenceExtensions.Height + GameReferenceExtensions.Height * y) % (GameReferenceExtensions.Height * List.Count); qy -= GameReferenceExtensions.Height; c.Canvas.MoveTo(0, qy); c.TouchOverlay.MoveTo(0, qy); } else { var qx = ((i + 1) * GameReferenceExtensions.Width + GameReferenceExtensions.Width * y) % (GameReferenceExtensions.Width * List.Count); qx -= GameReferenceExtensions.Width; c.Canvas.MoveTo(qx, 0); c.TouchOverlay.MoveTo(qx, 0); } } ); } ); }