示例#1
0
        public void CreateMaze(int _w, int _h)
        {
            var maze = new MazeGenerator(_w, _h, null);

            var w = new BlockMaze(maze);

            for (var y = 0; y < w.Height; y++)
            {
                Console.Write(new string(' ', 8));

                for (var x = 0; x < w.Width; x++)
                {
                    var v = w.Walls[x][y];

                    var p = new Panel();

                    p.SetBounds(16 + x * 16, 16 + y * 16, 15, 15);
                    if (!v)
                    {
                        p.BackColor = Color.White;
                    }
                    else
                    {
                        p.BackColor = Color.Black;
                    }

                    this.Controls.Add(p);



                }
            }

            this.ClientSize = new Size(16 * (w.Width + 2), 16 * (w.Height + 2));
        }
		public BlockMaze(MazeGenerator maze)
		{
			var sx = maze.Width * 2 - 3;
			var sy = maze.Height * 2 - 3;

			this.Width = sx;
			this.Height = sy;

			var w = new bool[sx][];

			this.Walls = w;

			for (var x = 0; x < w.Length; x++)
			{
				w[x] = new bool[sy];

				for (var y = 0; y < sy; y++)
					w[x][y] = true;

			}

			for (var x = 1; x < maze.Width - 1; x++)
			{
				var dx = x * 2 - 1;

				for (var y = 1; y < maze.Height - 1; y++)
				{
					var dy = y * 2 - 1;

					w[dx][dy] = false;

					var v = maze[x, y];

					var IsTop = (v & 1) != 0;
					var IsLeft = (v & 4) != 0;
					var IsBottom = (v & 2) != 0;
					var IsRight = (v & 8) != 0;

					var NotTop = (v & 1) == 0;
					var NotLeft = (v & 4) == 0;
					var NotBottom = (v & 2) == 0;
					var NotRight = (v & 8) == 0;

					if (NotTop)
						w[dx][dy - 1] = false;

					if (NotBottom)
						w[dx][dy + 1] = false;

					if (NotLeft)
						w[dx - 1][dy] = false;

					if (NotRight)
						w[dx + 1][dy] = false;
				}
			}
		}	
		public override void init()
		{
			this.InitializeComponents();

			base.resize(Settings.DefaultWidth, Settings.DefaultHeight);

			//try
			//{
				//System.Console.WriteLine("MazeGenerator");
				Maze = new MazeGenerator(20, 20, this);

			//}
			//catch (csharp.ThrowableException ex)
			//{
			//    Error = ex.Message;

			//}
		}
        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();
        }
		public MouseMazeCanvas()
		{
			Width = DefaultWidth;
			Height = DefaultHeight;

			#region Gradient
			for (int i = 0; i < DefaultHeight; i += 4)
			{
				new Rectangle
				{
					Fill = ((uint)(0xff00007F + (int)(128 * i / DefaultHeight))).ToSolidColorBrush(),
					Width = DefaultWidth,
					Height = 4,
				}.MoveTo(0, i).AttachTo(this);
			}
			#endregion



			var img = new Avalon.Images.jsc
			{
			}.MoveTo(DefaultWidth - 128, DefaultHeight - 128).AttachTo(this);


			var mouse = new Avalon.Images.mouse
			{
			}.MoveTo(0, 0).AttachTo(this);

			var container = new Canvas
			{
				Width = DefaultWidth,
				Height = DefaultHeight
			}.AttachTo(this);

            var mousehollow = new Avalon.Images.mouse_hollow
			{
			}.MoveTo(0, 0).AttachTo(this);

			var canvasdrawing = new Canvas
			{
				Width = DefaultWidth,
				Height = DefaultHeight
			}.AttachTo(container);

			InitializeCanvasDrawing(canvasdrawing);


			var canvas = new Rectangle
			{
				Fill = Brushes.Red,
				Width = DefaultWidth,
				Height = DefaultHeight,
				Opacity = 0
			}.MoveTo(0, 0).AttachTo(this);

			canvas.MouseLeftButtonUp +=
				delegate
				{
					canvasdrawing.Visibility = Visibility.Hidden;

					canvasdrawing = new Canvas
					{
						Width = DefaultWidth,
						Height = DefaultHeight
					}.AttachTo(container);

					maze = new MazeGenerator(maze.Width, maze.Height, null);

					InitializeCanvasDrawing(canvasdrawing);
				};

			this.Cursor = Cursors.None;

			canvas.MouseEnter +=
				delegate
				{
					mouse.Visibility = Visibility.Visible;
				};

			canvas.MouseLeave +=
				delegate
				{
					mouse.Visibility = Visibility.Hidden;
				};

			canvas.MouseMove +=
				(s, ev) =>
				{
					var p = ev.GetPosition(canvas);

					mouse.MoveTo(p.X - 8, p.Y - 8);
					mousehollow.MoveTo(p.X - 8, p.Y - 8);
				};




		}
示例#6
0
        public static void Main(string[] args)
        {
            // jsc needs to see args to make Main into main for javac..

            // generic parameter needs to be moved..
            //enumerable_10 = __Enumerable.AsEnumerable(__SZArrayEnumerator_1<String>.Of(stringArray3));

            Console.WriteLine("hi!");


            Console.WriteLine("maze...");

            var maze = new MazeGenerator(20, 20, new Feedback());

            var w = new BlockMaze(maze);
            
            for (int iy = 0; iy < w.Height; iy += 2)
            {
                for (int i = 0; i < w.Width; i++)
                {
                    var v0 = w.Walls[i][iy];
                    var v1 = false;

                    if (iy + 1 < w.Height)
                        v1 = w.Walls[i][iy + 1];

                    //Console.Write("" + v.ToString("x2"));



                    if (v0)
                    {
                        if (v1)
                            Console.Write("█");
                        else
                            Console.Write("▀");
                    }
                    else
                    {
                        if (v1)
                            Console.Write("▄");
                        else
                            Console.Write(" ");
                    }

                }
                Console.WriteLine();
            }

            System.Console.WriteLine("done");





            System.Console.WriteLine("jvm");


            CLRProgram.XML = new XElement("hello", "world");
            CLRProgram.CLRMain(
            );

        }