Пример #1
0
        //画地图
        public void drawMap(MapMark map, Canvas canvas)
        {
            canvas.getBrushMap().setMaxValue(map.getMaxValue());
            int width = map.getWidth();
            int height = map.getHeight();
            int i, j;

            //根据是否有边距,在不同的位置画图
            if (left == 0 && top == 0)
            {
                for (i = 0; i < height; i++)
                {
                    for (j = 0; j < width; j++)
                    {
                        canvas.fillRectangle(map.getValue(j, i), j * blockWidth, i * blockHeight, blockWidth, blockHeight);
                    }
                }
            }
            else
            {
                for (i = 0; i < height; i++)
                {
                    for (j = 0; j < width; j++)
                    {
                        canvas.fillRectangle(map.getValue(j, i), j * blockWidth + left, i * blockHeight + top, blockWidth, blockHeight);
                    }
                }
            }
        }
Пример #2
0
        //画路径。应在画地图之后画路径,否则路径会被地图覆盖。
        public void drawPath(List <MyPoint> path, MapMark map, Canvas canvas)
        {
            if (path == null)
            {
                return;
            }

            int i;
            int halfBlockWidth  = (int)(blockWidth / 2.0 + 0.5);
            int halfBlockHeight = (int)(blockHeight / 2.0 + 0.5);
            int blockLeft       = blockWidth / 4;
            int blockTop        = blockHeight / 4;

            //根据是否有边距,改变表示路径的方块的画图位置
            if (left != 0)
            {
                blockLeft += left;
            }
            if (top != 0)
            {
                blockTop += top;
            }

            for (i = 0; i < path.Count; i++)
            {
                canvas.fillRectangleReversely(map.getValue(path[i].x, path[i].y), path[i].x * blockWidth + blockLeft, path[i].y * blockHeight + blockTop, halfBlockWidth, halfBlockHeight);
            }
        }
Пример #3
0
        public MapMark getMapMark()
        {
            if (nodeMap == null)
            {
                return(null);
            }

            MapMark mark = new MapMark(width, height);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    mark.setValue(j, i, nodeMap[i, j].g);
                }
            }
            return(mark);
        }