Exemplo n.º 1
0
		public void initGrid( int width, int height )
		{
			this.width = width;
			this.height = height;

			grid = new Case[ width, height ];

			for ( int x = 0; x < width; x ++ )
				for ( int y = 0; y < height; y ++ )
					grid[ x, y ] = new Case( x, y );
		}
Exemplo n.º 2
0
		public Game( int width, int height )
		{
			radius = new Radius( this );
			plans = new Plans( this );
			frontier = new Frontier( this );

			this.width = width;
			this.height = height;

			grid = new Case[ width, height ];

			for ( int x = 0; x < width; x ++ )
				for ( int y = 0; y < height; y ++ )
					grid[ x, y ] = new Case( x, y );
		}
Exemplo n.º 3
0
		public Arrow( Case[] path )
		{
			this.path = path;
		}
Exemplo n.º 4
0
		public  Case[] returnSquareCases( Case pos, int rayon )
		{
			return returnSquareCases( pos.X, pos.Y, rayon );
		}
Exemplo n.º 5
0
		public  Case[] returnSquareCases( int xo, int yo, int rayon )
		{
			Point[] retour = returnSquare( xo, yo, rayon );
			Case[] cases = new Case[ retour.Length ];

			for ( int i = 0; i < cases.Length; i ++ )
				cases[ i ] = game.grid[ retour[ i ].X, retour[ i ].Y ];

			return cases;
		}
Exemplo n.º 6
0
		public int getDistWith( Case ori, Case dest )
		{
			if ( ori.X == dest.X && ori.Y == dest.Y )
				return 0;

			int xDiff = dest.X - ori.X, yDiff = dest.Y - ori.Y;

			if ( xDiff < 0 )
				xDiff *= -1;

			if ( yDiff < 0 )
				yDiff *= -1;

			if ( xDiff > game.width / 2 )
				xDiff -= game.width;
			
			if ( xDiff < 0 )
				xDiff *= -1;

			if ( ori.Y % 2 == 1 )
			{
				if ( dest.X > ori.X )
					return xDiff + yDiff / 2;
				else 
					return xDiff + ( yDiff + 1 ) / 2;
			}
			else
			{
				if ( dest.X < ori.X )
					return xDiff + yDiff / 2;
				else 
					return xDiff + ( yDiff + 1 ) / 2;
			}
		}