Added debugging steve

This commit is contained in:
Sofia 2020-04-20 04:55:29 +03:00
parent 6cec59c7cb
commit 617c48d4ff
3 changed files with 39 additions and 4 deletions

View File

@ -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);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a20b77427e31f0940ad0968a2ecce8d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -31,6 +31,7 @@ public class Lorax : MonoBehaviour {
private GameObject[] Chunks; private GameObject[] Chunks;
void Start() { 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) { public GameObject GetChunkAt(float x, float y) {
y += 250; /*Debug.Log("----------------");
x += 250; Debug.Log("y: " + (y + 250f));
int CurrentChunk = (int)((Mathf.Floor(y / ChunkSize) * 20) + Mathf.Floor(x / ChunkSize)); 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]; return Chunks[CurrentChunk];
} }
@ -77,7 +83,7 @@ public class Lorax : MonoBehaviour {
for (int y = 0; y < cap; y++) { for (int y = 0; y < cap; y++) {
TreePositions[y] = new Vector3[cap]; TreePositions[y] = new Vector3[cap];
for (int x = 0; x < cap; x++) { 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) { if (Chunks[CurrentChunk] == null) {
Chunks[CurrentChunk] = new GameObject("Chunk " + CurrentChunk); Chunks[CurrentChunk] = new GameObject("Chunk " + CurrentChunk);
Chunks[CurrentChunk].transform.parent = transform; Chunks[CurrentChunk].transform.parent = transform;