示例#1
0
        void bfs(int x, int y)
        {
            if (t[x, y] != Empty)
            {
                return;
            }
            GamePos[] q = new GamePos[n * m];
            int       l = 0, r = -1;

            q[++r] = new GamePos(x, y);
            while (l <= r)
            {
                GamePos p = q[l++];
                setType(p, Obstacle);
                if (p.y + 1 < m && t[p.x, p.y + 1] == Empty)
                {
                    q[++r] = new GamePos(p.x, p.y + 1);
                }
                else if (p.y - 1 >= 0 && t[p.x, p.y - 1] == Empty)
                {
                    q[++r] = new GamePos(p.x, p.y - 1);
                }
                else if (p.x + 1 < n && t[p.x + 1, p.y] == Empty)
                {
                    q[++r] = new GamePos(p.x + 1, p.y);
                }
                else if (p.x - 1 >= 0 && t[p.x - 1, p.y] == Empty)
                {
                    q[++r] = new GamePos(p.x - 1, p.y);
                }
            }
        }
示例#2
0
 public static Point3D FromGamePos(GamePos p)
 {
     return(new Point3D(p.x, 0, p.y));
 }
示例#3
0
 public Point3D GameToWolrd(GamePos p)
 {
     return(GameToWolrd(new Point3D(p.x, 0, p.y)));
 }
示例#4
0
 public Monster(Circle _p)
 {
     cir = _p;
     p   = new GamePos(_p.c);
 }
示例#5
0
        /*
         * public GamePos worldToGame(Point3D worldPos)
         * {
         *  float x = worldPos.x, y = worldPos.y;
         *  x = x * rate + x_bias;
         *  y = y * rate + y_bias;
         *  return new GamePos((int)x, (int)y);
         * }
         *
         * public Point3D gameToWorld(GamePos gamePos, float height)
         * {
         *  float x = gamePos.x, y = gamePos.y;
         *  x = (x - x_bias) / rate;
         *  y = (y - y_bias) / rate;
         *  return new Point3D(x, y, height);
         * }*/

        private void setType(GamePos p, int _t)
        {
            t[p.x, p.y] = _t;
        }