diff --git a/Assets/Scripts/DebuggingSteve.cs b/Assets/Scripts/DebuggingSteve.cs new file mode 100644 index 0000000..f441d1d --- /dev/null +++ b/Assets/Scripts/DebuggingSteve.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DebuggingSteve : MonoBehaviour { + + public Lorax Lorax; + public bool Reveal; + + void Update() { + if (Reveal) { + Reveal = false; + var chunk = Lorax.GetChunkAt(transform.position.x, transform.position.z); + chunk.SetActive(true); + } + + } +} diff --git a/Assets/Scripts/DebuggingSteve.cs.meta b/Assets/Scripts/DebuggingSteve.cs.meta new file mode 100644 index 0000000..aae7bd7 --- /dev/null +++ b/Assets/Scripts/DebuggingSteve.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a20b77427e31f0940ad0968a2ecce8d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Lorax.cs b/Assets/Scripts/Lorax.cs index 23b8887..9ccba04 100644 --- a/Assets/Scripts/Lorax.cs +++ b/Assets/Scripts/Lorax.cs @@ -31,6 +31,7 @@ public class Lorax : MonoBehaviour { private GameObject[] Chunks; void Start() { + Debug.Log((int)((Mathf.Floor((228.55f) / ChunkSize) * 25) + Mathf.Floor(245.27f / ChunkSize))); } @@ -51,9 +52,14 @@ public class Lorax : MonoBehaviour { } public GameObject GetChunkAt(float x, float y) { - y += 250; - x += 250; - int CurrentChunk = (int)((Mathf.Floor(y / ChunkSize) * 20) + Mathf.Floor(x / ChunkSize)); + /*Debug.Log("----------------"); + Debug.Log("y: " + (y + 250f)); + Debug.Log("x: " + (x + 250f)); + Debug.Log("y divided: " + (y + 250f) / ChunkSize); + Debug.Log("x divided: " + (x + 250f) / ChunkSize); + Debug.Log("y floored: " + (Mathf.Floor((y + 250f) / ChunkSize))); + Debug.Log("x floored: " + (Mathf.Floor((x + 250f) / ChunkSize)));*/ + int CurrentChunk = (int)((Mathf.Floor((y + 250f) / ChunkSize) * 25f) + Mathf.Floor((x + 250f) / ChunkSize)); return Chunks[CurrentChunk]; } @@ -77,7 +83,7 @@ public class Lorax : MonoBehaviour { for (int y = 0; y < cap; y++) { TreePositions[y] = new Vector3[cap]; for (int x = 0; x < cap; x++) { - int CurrentChunk = (int)((Mathf.Floor(y * Denseness / ChunkSize) * 20) + Mathf.Floor(x * Denseness / ChunkSize)); + int CurrentChunk = (int)((Mathf.Floor(y * Denseness / ChunkSize) * 25) + Mathf.Floor(x * Denseness / ChunkSize)); if (Chunks[CurrentChunk] == null) { Chunks[CurrentChunk] = new GameObject("Chunk " + CurrentChunk); Chunks[CurrentChunk].transform.parent = transform;