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 ); }
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 ); }
public Arrow( Case[] path ) { this.path = path; }
public Case[] returnSquareCases( Case pos, int rayon ) { return returnSquareCases( pos.X, pos.Y, rayon ); }
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; }
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; } }