// Start is called before the first frame update void Start() { singleton = TardisSingleton.GetInstance(); rotorWhiteLights = new TardisLight("TimeRotorWhiteLight"); orangeEngineLights = new TardisLight("EngineLight"); wallRoundYellowLights = new TardisLight("WallDecorationYellowLight"); topLights = new RotatingLight("MainLight", true); topRealLights = new RealRotatingLight("Light"); catwalkLights = new TardisLight("CatwalkLight"); bottomWallBlueLight = new TardisLight("LongBlueLight"); topWallBlueLight = new TardisLight("WallDecorationBlueLight"); topWallOrangeLight = new TardisLight("WallDecorationOrangeLight"); }
// Use this for initialization public void Spawn(Vector3 position) { float fullArc = 360.0f / segments; float renderedArc = fullArc * (1.0f - borderPercentage); float spacing = ((outerRadius - innerRadius) - thickness) / (float)layers; int randomSeed = Random.Range(0, 10); BombField field = Instantiate(fieldPrefab.gameObject).GetComponent <BombField>(); for (int j = 0; j < layers; j++) { GameObject parent = new GameObject("BombRing" + j); parent.transform.position = position; //Instantiating glow and ring GameObject glow = new GameObject("Glow" + j); glow.transform.parent = parent.transform; glow.transform.localPosition = Vector3.zero; GameObject ring = new GameObject("Ring" + j); ring.transform.parent = parent.transform; ring.transform.localPosition = Vector3.zero; Random.InitState(randomSeed); for (int i = 0; i < segments; i++) { float randomValue = Random.Range(0.0f, 1.0f);// * (0.3f * (j+1)); if (randomValue < 0.5) { randomValue = Random.Range(0.0f, 0.25f); } else { randomValue = Random.Range(0.75f, 1.0f); } CreateGlow(renderedArc, fullArc * i, innerRadius + j * spacing, 2.0f + randomValue * 10.0f); CreateRingSegment(renderedArc, fullArc * i, innerRadius + j * spacing, randomValue); } List <MeshFilter> meshFilters = GetComponentsInChildren <MeshFilter>().Where(x => x.gameObject.name.Contains("Panel")).ToList(); CombineInstance[] combine = new CombineInstance[meshFilters.Count]; for (int i = 0; i < meshFilters.Count; i++) { combine[i].mesh = meshFilters[i].sharedMesh; combine[i].transform = meshFilters[i].transform.localToWorldMatrix; meshFilters[i].gameObject.SetActive(false); Destroy(meshFilters[i].gameObject); //meshFilters[i].sharedMesh; //combine[i].transform = meshFilters[i].transform.localToWorldMatrix; //meshFilters[i].gameObject.active = false; } MeshFilter glowMF = glow.AddComponent <MeshFilter>(); glowMF.mesh.CombineMeshes(combine); glowMF.mesh.RecalculateNormals(); MeshRenderer glowMR = glow.AddComponent <MeshRenderer>(); glowMR.material = glowMaterial; RotatingLight light = glow.AddComponent <RotatingLight>(); light.selfRenderer = glowMR; meshFilters = GetComponentsInChildren <MeshFilter>().Where(x => x.gameObject.name.Contains("Arc")).ToList(); combine = new CombineInstance[meshFilters.Count]; for (int i = 0; i < meshFilters.Count; i++) { combine[i].mesh = meshFilters[i].sharedMesh; combine[i].transform = meshFilters[i].transform.localToWorldMatrix; meshFilters[i].gameObject.SetActive(false); Destroy(meshFilters[i].gameObject); //meshFilters[i].sharedMesh; //combine[i].transform = meshFilters[i].transform.localToWorldMatrix; //meshFilters[i].gameObject.active = false; } MeshFilter ringMF = ring.AddComponent <MeshFilter>(); ringMF.mesh.CombineMeshes(combine); ringMF.mesh.RecalculateNormals(); MeshRenderer ringMR = ring.AddComponent <MeshRenderer>(); ringMR.material = floorMaterial; field.fieldRings.Add(parent); } field.transform.position = this.transform.position; field.SpawnField(); }