loads of changes
This commit is contained in:
1 parent
4726734370
commit
4833faed56
93 files changed
+36396
-23915
No files matched your search
@@ -0,0 +1,95 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class CubeController : TripsitterAve {
|
||||
public GameObject prefab;
|
||||
|
||||
public float minSize = 2;
|
||||
public float maxSize = 4;
|
||||
|
||||
void Start() {
|
||||
CreateCubes(0f, 0f, 0f, 100f, 50f, 100f);
|
||||
}
|
||||
|
||||
// void Update() {
|
||||
// var spectrumData = GetSpectrumData();
|
||||
|
||||
// for (int i = 0; i < cubes.Count; i++) {
|
||||
// GameObject cube = cubes[i];
|
||||
// float amp = spectrumData[i % SpectrumSize];
|
||||
// // Vector3 scale = new Vector3(1.0f, 1.0f, 1.0f * amp);
|
||||
// // cubes[i].transform.localScale *= scale;
|
||||
// }
|
||||
|
||||
// float avg = spectrumData.Sum() / SpectrumSize;
|
||||
// lightMat.SetFloat("_EmissiveIntensity", avg * 1000.0f);
|
||||
// }
|
||||
|
||||
// bool IsLeft(GameObject cube) {
|
||||
// float up = cube.transform.up;
|
||||
// return up < yBottom && up > yTop;
|
||||
// }
|
||||
|
||||
// bool IsRight(GameObject cube) {
|
||||
// float up = cube.transform.up;
|
||||
// return up < yBottom && up > yTop;
|
||||
// }
|
||||
|
||||
// bool IsBottom(GameObject cube) {
|
||||
// float up = cube.transform.up;
|
||||
// return up < yBottom && up > yTop;
|
||||
// }
|
||||
|
||||
// bool IsTop(GameObject cube) {
|
||||
// float up = cube.transform.up;
|
||||
// return up < yBottom && up > yTop;
|
||||
// }
|
||||
|
||||
void CreateCubes(float currentX, float currentZ, float currentY, float xWidth, float yWidth, float zWidth) {
|
||||
float xMargin = 10;
|
||||
float yMargin = 5;
|
||||
float zMargin = 10;
|
||||
float xLeft = xMargin;
|
||||
float xRight = xWidth - xMargin;
|
||||
float yBottom = yMargin;
|
||||
float yTop = yWidth - yMargin;
|
||||
float zBack = zWidth - zMargin;
|
||||
|
||||
while (currentY < yWidth) {
|
||||
while (currentZ < zWidth) {
|
||||
while (currentX < xWidth) {
|
||||
|
||||
bool ok = currentX < xLeft ||
|
||||
currentX > xRight ||
|
||||
currentY < yBottom ||
|
||||
currentY > yTop ||
|
||||
currentZ > zBack;
|
||||
float size = Random.Range(minSize, maxSize);
|
||||
|
||||
if (ok) {
|
||||
GameObject cube = GameObject.Instantiate(prefab);
|
||||
cube.transform.parent = gameObject.transform;
|
||||
cube.transform.localScale *= size;
|
||||
float x = currentX + (size / 2f);
|
||||
float y = currentY + (size / 2f);
|
||||
if (currentY > yTop) y = currentY - (size / 2f);
|
||||
float z = currentZ + (size / 2f);
|
||||
if (currentZ > zBack) z = currentZ - (size / 2f);
|
||||
|
||||
cube.transform.Translate(x, y, z);
|
||||
// cubes.Add(cube);
|
||||
}
|
||||
|
||||
currentX = currentX + size;
|
||||
}
|
||||
|
||||
currentX = 0;
|
||||
currentZ = currentZ + maxSize;
|
||||
}
|
||||
currentZ = 0;
|
||||
currentY = currentY + maxSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user