Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public bool IsEmpty(HexaPoint hp)
 {
     if (cluster[hp.x + hp.y * maxX] == float.MinValue)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 public float GetMap(HexaPoint hp)
 {
     if (hp == null)
     {
         return(float.MinValue);
     }
     return(cluster[hp.x + hp.y * maxX]);
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 public float GetMap( HexaPoint hp )
 {
     if ( hp == null )
         return float.MinValue;
     return cluster[ hp.x + hp.y * maxX ];
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 public HexaPoint( HexaPoint v )
 {
     x = v.x;
     y = v.y;
 }
Exemplo n.º 10
0
 public bool IsEmpty( HexaPoint hp )
 {
     if ( cluster[ hp.x + hp.y * maxX ] == float.MinValue )
         return true;
     return false;
 }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 public HexaPoint(HexaPoint v)
 {
     x = v.x;
     y = v.y;
 }