void GenerateTileSet(Tile tile, Tile nTileSet) { foreach (Transform SP in tile.spawnlocations) { if (tile.chance != 100) { rand = Random.Range(0, 101); } else { rand = 0; } if (rand <= tile.chance) { RaycastHit hit; if (!Physics.Raycast(SP.transform.position + new Vector3(0, 1f, 0), transform.TransformDirection(Vector3.down), out hit, 1.0f, regularLayermask)) { rand = Random.Range(0, tile.pieces.Count); GameObject plate = Instantiate(tile.pieces[rand], SP.position, SP.rotation, transform); rand = Random.Range(0, 4); Z_Plate TP = plate.GetComponent <Z_Plate>(); if (TP.rotatable) { TP.geo.transform.Rotate(0, rotations[rand], 0); } //TG.TIS.Add(plate); foreach (Transform NSP in TP.spawnPoints) { nTileSet.spawnlocations.Add(NSP); } } } } foreach (Transform spawnPoint in tile.spawnlocations) { Destroy(spawnPoint.gameObject); } tile.spawnlocations.Clear(); }
void GenerateSpawnerSet(Spawner spawnSet) { RandomizeList(spawnSet.spawnlocations); int x = spawnSet.numberOf; for (int i = 0; i < x; i++) { RaycastHit hit; if (!Physics.Raycast(spawnSet.spawnlocations[i].transform.position + new Vector3(2, 0.5f, 0), transform.TransformDirection(Vector3.down), out hit, 1.0f, spawnLayermask) && !Physics.Raycast(spawnSet.spawnlocations[i].transform.position + new Vector3(-2, 0.5f, 0), transform.TransformDirection(Vector3.down), out hit, 1.0f, spawnLayermask) && !Physics.Raycast(spawnSet.spawnlocations[i].transform.position + new Vector3(0, 0.5f, 2), transform.TransformDirection(Vector3.down), out hit, 1.0f, spawnLayermask) && !Physics.Raycast(spawnSet.spawnlocations[i].transform.position + new Vector3(0, 0.5f, -2), transform.TransformDirection(Vector3.down), out hit, 1.0f, spawnLayermask)) { rand = Random.Range(0, spawnSet.pieces.Count); GameObject plate = Instantiate(spawnSet.pieces[rand], spawnSet.spawnlocations[i].position, spawnSet.spawnlocations[i].rotation, transform); rand = Random.Range(0, 4); Z_Plate TP = plate.GetComponent <Z_Plate>(); if (TP.rotatable) { TP.geo.transform.Rotate(0, rotations[rand], 0); } //TG.TIS.Add(plate); } else { Debug.Log(hit.transform.name); x++; } } //foreach (Transform spawnPoint in spawnSet.spawnlocations) // Destroy(spawnPoint.gameObject); spawnSet.spawnlocations.Clear(); }