void generateAll() { Item[] itemLayer1 = Item.GetArray(field.Take(MapGrid.MapTileCount32x32 * Item.SIZE).ToArray()); Item[] itemLayer2 = Item.GetArray(field.Slice(MapGrid.MapTileCount32x32 * Item.SIZE, MapGrid.MapTileCount32x32 * Item.SIZE).ToArray()); // create templates for pushing bytes back layerTemplate1 = CloneItemArray(itemLayer1); layerTemplate2 = CloneItemArray(itemLayer2); fieldManager = new FieldItemManager(itemLayer1, itemLayer2); terrainLayer = new NHSE.Core.TerrainLayer(TerrainTile.GetArray(terrain), acre_plaza.Slice(0, AcreSizeAll)); buildings = new List <Building>(Building.GetArray(structure)); plazaX = BitConverter.ToUInt32(acre_plaza, AcreSizeAll + 4); plazaY = BitConverter.ToUInt32(acre_plaza, AcreSizeAll + 8); if (graphicGenerator != null) { graphicGenerator.ReleaseAllResources(); } graphicGenerator = new MapGraphicGenerator(fieldManager, terrainLayer, (ushort)plazaX, (ushort)plazaY, buildings.ToArray()); MapImage.texture = graphicGenerator.MapBackgroundImage; MapImage.color = Color.white; fetched = true; updateGrid(lastCursorX, lastCursorY); UnfetchedBlocker.gameObject.SetActive(false); AffectingMode.interactable = true; RefetchItemsButton.interactable = true; WriteButton.interactable = true; }
public FieldItemEditor(MainSave sav) { InitializeComponent(); this.TranslateInterface(GameInfo.CurrentLanguage); SAV = sav; Items = new FieldItemManager(SAV.GetFieldItems()); var l1 = Items.Layer1; Scale1 = new int[l1.GridWidth * l1.GridHeight]; ScaleX = new int[Scale1.Length * AcreScale * AcreScale]; ScaleAcre = new Bitmap(l1.GridWidth * AcreScale, l1.GridHeight * AcreScale); Map = new int[l1.MapWidth * l1.MapHeight * MapScale * MapScale]; MapReticle = new Bitmap(l1.MapWidth * MapScale, l1.MapHeight * MapScale); foreach (var acre in MapGrid.Acres) { CB_Acre.Items.Add(acre.Name); } PG_Tile.SelectedObject = new FieldItem(); CB_Acre.SelectedIndex = 0; LoadGrid(X, Y); }
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); }