From f69bd91a28797df42f32c342a0d0305d08278a93 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Mon, 25 Dec 2023 23:36:15 +0000
Subject: [PATCH] Added border to map

---
 Assets/Scripts/GenerateTileMap.cs |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/Assets/Scripts/GenerateTileMap.cs b/Assets/Scripts/GenerateTileMap.cs
index 6d5d630..136a14d 100644
--- a/Assets/Scripts/GenerateTileMap.cs
+++ b/Assets/Scripts/GenerateTileMap.cs
@@ -8,8 +8,9 @@
 public class GenerateTileMap : MonoBehaviour
 {
     public int? seed;
-    public int width = 256;
-    public int height = 256;
+    public int maxWidth = 256;
+    public int maxHeight = 384;
+    public int maxGroundHeight = 256;
     private float scale;
     private float offsetX;
     private float offsetY;
@@ -59,12 +60,12 @@
 
     public IEnumerator GenerateTiles(Action finishedCallback, List<Vector3Int> destroyedTiles)
     {
-        for (int x = 0; x < width; x++)
+        for (int x = 1; x < maxWidth; x++)
         {
-            for (int y = 0; y < height; y++)
+            for (int y = 1; y < maxGroundHeight; y++)
             {
-                float xPerlin = ((float)x / width) * scale + offsetX;
-                float yPerlin = ((float)y / height) * scale + offsetY;
+                float xPerlin = ((float)x / maxWidth) * scale + offsetX;
+                float yPerlin = ((float)y / maxHeight) * scale + offsetY;
                 float perlinNoise = Mathf.PerlinNoise(xPerlin, yPerlin);
 
                 if (perlinNoise >= 0.3f)
@@ -83,6 +84,24 @@
                 yield return null;
             }
         }
+        for (int x = 0; x <= maxWidth; x += maxWidth)
+        {
+            for (int y = 0; y <= maxHeight; y++)
+            {
+                tilemap.SetTile(new Vector3Int(x, y), borderTile);
+            }
+
+        }
+        yield return null;
+        for (int y = 0; y <= maxHeight; y += maxHeight)
+        {
+            for (int x = 1; x <= maxWidth; x++)
+            {
+                tilemap.SetTile(new Vector3Int(x, y), borderTile);
+            }
+
+        }
+        yield return null;
         finishedCallback();
     }
 }

--
Gitblit v1.9.3