Beispiel #1
0
 public MapTerrainStructure(MainSave sav)
 {
     Terrain   = new TerrainLayer(sav.GetTerrainTiles(), sav.GetAcreBytes());
     Buildings = sav.Buildings;
     PlazaX    = sav.EventPlazaLeftUpX;
     PlazaY    = sav.EventPlazaLeftUpZ;
 }
    private Texture2D PlaceBuildings(NHSE.Core.TerrainLayer terrain, Texture2D tex, Building[] buildings)
    {
        for (int i = 0; i < buildings.Length; i++)
        {
            var b = buildings[i];
            if (b.BuildingType == 0)
            {
                continue;
            }
            terrain.GetBuildingCoordinate(b.X, b.Y, 1, out var x, out var y);

            var pen = BuildingCol;
            FillRect(tex, x - 2, y - 2, 4, 4, pen);
        }
        return(tex);
    }
Beispiel #3
0
    public MapGraphicGenerator(FieldItemManager items, NHSE.Core.TerrainLayer terrain, ushort plazaX, ushort plazaY, Building[] buildings)
    {
        PixelsItemMap        = new int[items.Layer1.MaxWidth * items.Layer2.MaxHeight];
        PixelsBackgroundMap1 = new int[PixelsItemMap.Length / 4];
        PixelsBackgroundMapX = new int[PixelsItemMap.Length];
        ItemManager          = items;
        Terrain = terrain;

        System.Drawing.Color[] pixels = new System.Drawing.Color[PixelsBackgroundMap1.Length];
        MapBackgroundImage = new Texture2D(Terrain.MaxWidth, Terrain.MaxHeight);

        // draw rivers + height
        int i = 0;

        for (int y = 0; y < Terrain.MaxHeight; y++)
        {
            for (int x = 0; x < Terrain.MaxWidth; x++, i++)
            {
                var pxl = Terrain.GetTileColorRGB(x, y);
                MapBackgroundImage.SetPixel(x, y, new Color32(pxl.R, pxl.G, pxl.B, pxl.A));
                pixels[i] = pxl;
            }
        }

        // draw buildings
        PlaceBuildings(Terrain, MapBackgroundImage, buildings);

        // draw plaza
        Terrain.GetBuildingCoordinate(plazaX, plazaY, 1, out var xp, out var yp);
        FillRect(MapBackgroundImage, xp, yp, PlazaWidth, PlazaHeight, PlazaCol);

        background = new Texture2D(MapBackgroundImage.width, MapBackgroundImage.height);
        Graphics.CopyTexture(MapBackgroundImage, background);
        //background = FlipTexture(background); // no need to flip for backgroud pixels of acre

        UpdateImageForLayer(0);
    }