Added debugging steve
This commit is contained in:
parent
6cec59c7cb
commit
617c48d4ff
18
Assets/Scripts/DebuggingSteve.cs
Normal file
18
Assets/Scripts/DebuggingSteve.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/DebuggingSteve.cs.meta
Normal file
11
Assets/Scripts/DebuggingSteve.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a20b77427e31f0940ad0968a2ecce8d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user