public bool Spawn(TA_SHAPES shape, MeshFilter spawnArea, Spawned geometry, int visiblePercentage) { Vector3 RandomPos = spawnArea.mesh.GetRandomPointInsideConvex(); RandomPos = spawnArea.transform.TransformPoint(RandomPos); if (Physics.Raycast(RandomPos, Vector3.down, out info, Mathf.Infinity, mask)) { switch (shape) { case TA_SHAPES.Cube: geometryHandler.PlaceCube(info.point, info.normal, geometry, visiblePercentage); break; case TA_SHAPES.Cylinder: geometryHandler.PlaceCylinder(info.point, info.normal, geometry, visiblePercentage); break; case TA_SHAPES.Plane_Small: case TA_SHAPES.Plane_Big: geometryHandler.PlacePlane(info.point, info.normal, geometry, visiblePercentage); break; case TA_SHAPES.Sphere: geometryHandler.PlaceSphere(info.point, info.normal, geometry, visiblePercentage); break; } return(true); } else { return(false); } }
public Spawned SpawnSpecificTrashArea(int indexForm, int indexSpawnArea) { Spawned ret = null; TA_SHAPES standard = TA_SHAPES.Plane_Small; SpawnedList spawnable_curList = spawnable_TrashAreas[indexForm]; SpawnedList spawned_curList = spawned_TrashAreas[indexForm]; Spawned curPopped; int lastPos; if (spawnable_curList.Count == 0) { lastPos = 0; curPopped = spawned_curList[0]; spawned_curList.RemoveAt(0); spawnable_curList.Add(curPopped); } else { lastPos = spawnable_TrashAreas[indexForm].Count - 1; curPopped = spawnable_curList[lastPos]; } curPopped.gameObject.SetActive(true); //trashAreaHandler.Spawn(current + i, spawnArea[/*Random.Range(0, spawnArea.Length)*/4], curPopped); bool spawnedCorrectly = trashAreaHandler.Spawn(standard + indexForm, spawnArea[indexSpawnArea], curPopped, Random.Range(100, 160)); if (spawnedCorrectly) { StartCoroutine(GrowToSize(curPopped)); spawnable_curList.RemoveAt(lastPos); spawned_curList.Add(curPopped); ret = curPopped; LevelBalancing.SetTrashValue(curPopped.personalTrashValue); } else if (!spawnedCorrectly) { curPopped.gameObject.SetActive(false); } return(ret); }
public bool Spawn(TA_SHAPES shape, MeshFilter spawnArea, Spawned geometry) => Spawn(shape, spawnArea, geometry, 30);