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);
    }
示例#2
0
    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);
    }
示例#3
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);
    }