예제 #1
0
    public Texture2D RenderMap(object _m, Texture2D tex)
    {
        Tile[,] map = (Tile[, ])_m;

        tex = new Texture2D(8 * map.GetLength(0), 8 * map.GetLength(1), TextureFormat.ARGB32, false);
        int sf = 8; int Width = map.GetLength(0); int Height = map.GetLength(1);
        // int sf = 10;
        Texture2D gnd = Resources.Load <Texture2D>("tiles/tile_17");

        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                if (map[i, j].BLOCKS_MOVEMENT)
                {
                    VisUtils.PaintTexture(tex, i, j, sf, gnd, 8, 8);
                    VisUtils.PaintTexture(tex, i, j, sf, selectTexture(map, i, j), 8, 8);
                }
                else
                {
                    VisUtils.PaintTexture(tex, i, j, sf, gnd, 8, 8);
                }
            }
        }

        tex.Apply();
        return(tex);
    }
    public Texture2D RenderSimpleMap(object _m)
    {
        //Cast the object to the type we expect
        Tile[,] map = (Tile[, ])_m;

        //Create a new texture the right size for our content
        Texture2D tex = new Texture2D(map.GetLength(0), map.GetLength(1), TextureFormat.ARGB32, false);

        //For each tile in the map...
        for (int i = 0; i < map.GetLength(0); i++)
        {
            for (int j = 0; j < map.GetLength(1); j++)
            {
                //...if it's a wall tile...
                if (map[i, j].BLOCKS_MOVEMENT)
                {
                    //...paint a black pixel on the screen
                    VisUtils.PaintPoint(tex, i, j, 1, Color.black);
                }
                else
                {
                    //...otherwise, paint a white pixel
                    VisUtils.PaintPoint(tex, i, j, 1, Color.white);
                }
            }
        }

        //Remember to apply the results before we return it
        tex.Apply();

        return(tex);
    }
예제 #3
0
    public Texture2D RenderMap(object _m)
    {
        int[,] _maze = (int[, ])_m;

        int       sf = 4;
        Texture2D tex = new Texture2D(sf * _maze.GetLength(0), sf * _maze.GetLength(1), TextureFormat.ARGB32, false);
        int       Width = _maze.GetLength(0); int Height = _maze.GetLength(1);

        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                if ((_maze[i, j] & START) != 0)
                {
                    VisUtils.PaintSquare(tex, sf * i + 1, sf * j + 1, sf - 1, sf - 1, Color.green);
                }
                else if ((_maze[i, j] & END) != 0)
                {
                    VisUtils.PaintSquare(tex, sf * i + 1, sf * j + 1, sf - 1, sf - 1, Color.red);
                }
            }
        }

        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                if (!CanMove(i, j, NORTH, _maze))
                {
                    VisUtils.PaintLine(tex, sf * i, sf * j, sf + 1, false, Color.black);
                }
                if (!CanMove(i, j, WEST, _maze))
                {
                    VisUtils.PaintLine(tex, sf * i, sf * j, sf + 1, true, Color.black);
                }
            }
        }

        VisUtils.PaintLine(tex, 0, 0, sf * _maze.GetLength(0), false, Color.black);
        VisUtils.PaintLine(tex, 0, 0, sf * _maze.GetLength(1), true, Color.black);
        VisUtils.PaintLine(tex, 0, sf * (_maze.GetLength(0)) - 1, sf * _maze.GetLength(0), false, Color.black);
        VisUtils.PaintLine(tex, sf * (_maze.GetLength(0)) - 1, 0, sf * _maze.GetLength(1), true, Color.black);

        tex.Apply();
        return(tex);
    }
예제 #4
0
파일: BoardCreator.cs 프로젝트: r618/Danesh
    public Texture2D RenderMap(object _m, Texture2D tex)
    {
        Tile[,] map = (Tile[, ])_m;
        int sf = 10; int Width = map.GetLength(0); int Height = map.GetLength(1);

        for (int i = 0; i < Width; i++)
        {
            for (int j = 0; j < Height; j++)
            {
                if (map[i, j].BLOCKS_MOVEMENT)
                {
                    VisUtils.PaintPoint(tex, i, j, sf, Color.black);
                }
                else
                {
                    VisUtils.PaintPoint(tex, i, j, sf, Color.white);
                }
            }
        }

        tex.Apply();
        return(tex);
    }
예제 #5
0
    public Texture2D Visualise(object _w, Texture2D target)
    {
        DSWorld w = (DSWorld)_w;

        //scale factor
        //not really sure how to handle varying output size yet in danesh so for now we just overshoot slightly
        int sf = 2;

        target = new Texture2D(mapsize * sf, mapsize * sf, TextureFormat.ARGB32, false);

        if (sf < 0)
        {
            //Do something to fix the problem...? Sure.
        }

        for (int i = 0; i < w.elevation.GetLength(0); i++)
        {
            for (int j = 0; j < w.elevation.GetLength(1); j++)
            {
                Color c = beachColor;
                float v = w.elevation[i, j];
                //Select a colour
                if (v < waterLimit - 40)
                {
                    c = deepWaterColor;
                }
                else if (v < waterLimit)
                {
                    c = shallowWaterColor;
                }
                else if (v < waterLimit + 5)
                {
                    c = beachColor;
                }
                else if (v < plainsLimit)
                {
                    // if(temp_data[i][j] < -5):
                    // col = white;
                    // elif(temp_data[i][j] < 5):
                    // if(random.randint(0, 255)/float(255) > (temp_data[i][j]+5)/float(10)):
                    // col = white
                    // else:
                    // col = grass;
                    // else:
                    c = plainsColor;
                }
                else if (v < hillsLimit && v < mountainLimit)
                {
                    c = hillsColor;
                }
                else
                {
                    c = snowColor;
                }

                VisUtils.PaintPoint(target, i, j, sf, c);
                // target.SetPixel(i, j, new Color(v/255f, v/255f, v/255f, 1f));
                // target.SetPixel(i, j, c);
            }
        }
        target.Apply();

        return(target);
    }