public HexaPoint HexaCoord( HexaPoint v, int t ) { HexaPoint res = new HexaPoint( v ); switch( t ) { case 0: res.y--; if ( ( res.y & 1 ) == 0 ) res.x--; return res; case 1: res.y--; res.x++; if ( ( res.y & 1 ) == 1 ) res.x++; return res; case 2: res.x--; return res; case 3: res.x++; return res; case 4: res.y++; if ( ( res.y & 1 ) == 0 ) res.x--; return res; case 5: res.y++; if ( ( res.y & 1 ) == 1 ) res.x++; return res; } return null; }
public bool IsEmpty(HexaPoint hp) { if (cluster[hp.x + hp.y * maxX] == float.MinValue) { return(true); } return(false); }
public float GetMap(HexaPoint hp) { if (hp == null) { return(float.MinValue); } return(cluster[hp.x + hp.y * maxX]); }
public HexaPoint HexaCoord(HexaPoint v, int t) { HexaPoint res = new HexaPoint(v); switch (t) { case 0: res.y--; if ((res.y & 1) == 0) { res.x--; } return(res); case 1: res.y--; res.x++; if ((res.y & 1) == 1) { res.x++; } return(res); case 2: res.x--; return(res); case 3: res.x++; return(res); case 4: res.y++; if ((res.y & 1) == 0) { res.x--; } return(res); case 5: res.y++; if ((res.y & 1) == 1) { res.x++; } return(res); } return(null); }
public double Distance(HexaPoint with) { float xx = (float)x; float yy = (float)y; float zx = (float)with.x; float zy = (float)with.y; if ((with.y & 1) == 0) { zx += 0.5F; } if ((y & 1) == 0) { xx += 0.5F; } float dx = xx - zx; dx *= dx; float dy = yy - zy; dy *= dy; dx += dy; return((double)dx); }
public HexaPoint HexaCoordNoBorder( HexaPoint v, int t ) { HexaPoint res = new HexaPoint( v ); switch( t ) { case 0: res.y--; if ( res.y < 0 ) res.y += maxY; if ( ( res.y & 1 ) == 0 ) { res.x--; if ( res.x < 0 ) res.x += maxX; } return res; case 1: res.y--; if ( res.y < 0 ) res.y += maxY; if ( ( res.y & 1 ) == 1 ) res.x++; if ( res.x >= maxX ) res.x = res.x - maxX; return res; case 2: res.x--; if ( res.x < 0 ) res.x = res.x + maxX; return res; case 3: res.x++; if ( res.x >= maxX ) res.x -= maxX; return res; case 4: res.y++; if ( res.y >= maxY ) res.y -= maxY; if ( ( res.y & 1 ) == 0 ) { res.x--; if ( res.x < 0 ) res.x += maxX; } return res; case 5: res.y++; if ( res.y >= maxY ) res.y -= maxY; if ( ( res.y & 1 ) == 1 ) res.x++; if ( res.x >= maxX ) res.x -= maxX; return res; } return null; }
public float GetMap( HexaPoint hp ) { if ( hp == null ) return float.MinValue; return cluster[ hp.x + hp.y * maxX ]; }
public double Distance( HexaPoint with ) { float xx = (float)x; float yy = (float)y; float zx = (float)with.x; float zy = (float)with.y; if ( ( with.y & 1 ) == 0 ) zx+=0.5F; if ( ( y & 1 ) == 0 ) xx+=0.5F; float dx = xx - zx; dx *= dx; float dy = yy - zy; dy *= dy; dx += dy; return (double)dx; }
public HexaPoint( HexaPoint v ) { x = v.x; y = v.y; }
public bool IsEmpty( HexaPoint hp ) { if ( cluster[ hp.x + hp.y * maxX ] == float.MinValue ) return true; return false; }
public HexaPoint HexaCoordNoBorder(HexaPoint v, int t) { HexaPoint res = new HexaPoint(v); switch (t) { case 0: res.y--; if (res.y < 0) { res.y += maxY; } if ((res.y & 1) == 0) { res.x--; if (res.x < 0) { res.x += maxX; } } return(res); case 1: res.y--; if (res.y < 0) { res.y += maxY; } if ((res.y & 1) == 1) { res.x++; } if (res.x >= maxX) { res.x = res.x - maxX; } return(res); case 2: res.x--; if (res.x < 0) { res.x = res.x + maxX; } return(res); case 3: res.x++; if (res.x >= maxX) { res.x -= maxX; } return(res); case 4: res.y++; if (res.y >= maxY) { res.y -= maxY; } if ((res.y & 1) == 0) { res.x--; if (res.x < 0) { res.x += maxX; } } return(res); case 5: res.y++; if (res.y >= maxY) { res.y -= maxY; } if ((res.y & 1) == 1) { res.x++; } if (res.x >= maxX) { res.x -= maxX; } return(res); } return(null); }
public HexaPoint(HexaPoint v) { x = v.x; y = v.y; }