/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IEnumerator OnEnableCoroutine() { //-------------- if (trigger0 == true) { distance = Mathf.Sqrt(Class_Controller.SqrMagnitudeToPlayer(thisTransform)); } //-------------- if (trigger0 == true && distance < thisAudioSource.maxDistance) { countCurent++; yield return(null); if (countCurent < 10) { thisAudioSource.clip = soundsFx[Random.Range(0, soundsFx.Length)]; thisAudioSource.pitch = Random.Range(audioPitch.x, audioPitch.y); thisAudioSource.volume = Random.Range(audioVolume.x, audioVolume.y); thisAudioSource.Play(); while (thisAudioSource.isPlaying == true) { yield return(delay0); } } countCurent--; } else { if (randomTime == true) { time = Random.Range(minTime, maxTime); } else { time = minTime; } yield return(new WaitForSeconds(time)); } //-------------- ExplosionParticlesPool.TakeExplosionParticle(gameObject); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static void ParticlesDestroyed(Transform thisTransform) { //-------------- GameObject obj = ExplosionParticlesPool.GiveExplosionParticle(3); if (obj != null) { Transform tr = obj.transform; tr.SetPositionAndRotation(thisTransform.position + (thisTransform.up * 3), Random.rotation); tr.localScale = Vector3.one + (thisTransform.lossyScale * Random.Range(2.7f, 3.3f)); obj.SetActive(true); } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IEnumerator SplitСube() { //-------------- amountDamage += currentDamage; if (amountDamage >= 10.0f + (faultSize * 0.5f) && brokenStage0 == false) { brokenStage0 = true; StartCoroutine(Class_ChunkCube.CheckChildCount(thisTransform, gameObject)); if (thisScaleX > faultSize * faultSizeOptimize) { Class_ChunkCube.CubeOutOfPool(thisTransform, numberCubeOutOfPool, cubeOutOfPoolScale, uvOffset); thisRenderer.enabled = false; thisBoxCollider.enabled = false; } else { outPool = false; if (visible == true) { Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(0), Random.Range(0.75f, 1.25f)); Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(1), Random.Range(0.75f, 1.25f)); for (int i = 0; i < numberDebris; i++) { Class_ChunkCube.DebrisOutOfPool(thisTransform, thisRenderer, DebrisesPool.GiveDebris(Random.Range(0, 2)), numberDebris, Random.Range(0.4f, 0.9f), uvOffset); } } Class_Mineral.RandomMinerals(thisTransform); yield return(delay0); ChunkCubesPool.TakeCube(gameObject); } } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Particles() { //-------------- amountDamage += currentDamage; if (amountDamage >= 2 && brokenStage0 == false) { brokenStage0 = true; if (visible == true) { Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(2), Random.Range(0.75f, 1.25f)); Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(3), Random.Range(0.75f, 1.25f)); } Class_Mineral.RandomMinerals(thisTransform); DebrisesPool.TakeDebris(gameObject); } //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IEnumerator Optimization() { //-------------- while (brokenStage0 == false) { yield return(delay0); int planetChildCount = planetCubeTransform.childCount; if (brokenStage1 == false && planetChildCount > 0) { brokenStage1 = true; } if (brokenStage1 == true) { if (planetChildCount < 6 && brokenStage2 == false) { brokenStage2 = true; rotationLod = false; Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(1), planetCubeTransform.localScale.x * Random.Range(0.75f, 1.25f)); while (gravity.transform.childCount != 0) { yield return(null); foreach (Transform child in gravity.transform) { child.transform.parent = null; } } Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(1), planetCubeTransform.localScale.x * Random.Range(0.75f, 1.25f)); yield return(null); gravity.SetActive(false); atmosphere.SetActive(false); forest.SetActive(false); } if (planetChildCount == 0) { brokenStage0 = true; } } if (brokenStage2 == false) { if (Class_Controller.SqrMagnitudeToPlayer(thisTransform) < sqrtDistanceLod) { rotationLod = false; } else { rotationLod = true; } } } //-------------- planetDestroyed = true; Class_PlanetarySystem.listPlanets.Remove(gameObject); planetCube.SetActive(false); collidersToOptimizeDestruction.SetActive(false); //-------------- }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IEnumerator Optimization() { //-------------- while (brokenStage0 == false) { yield return(delay0); int moonChildCount = moonCubeTransform.childCount; if (brokenStage1 == false && moonChildCount > 0) { brokenStage1 = true; } if (brokenStage1 == true) { if (moonChildCount < 6 && brokenStage2 == false) { brokenStage2 = true; rotationLod = false; Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(1), moonCubeTransform.localScale.x * Random.Range(0.75f, 1.25f)); while (gravity.transform.childCount != 0) { yield return(null); foreach (Transform child in gravity.transform) { child.transform.parent = null; } } Class_ChunkCube.ParticlesOutOfPool(thisTransform, ExplosionParticlesPool.GiveExplosionParticle(1), moonCubeTransform.localScale.x * Random.Range(0.75f, 1.25f)); yield return(null); gravity.SetActive(false); atmosphere.SetActive(false); } if (moonChildCount == 0) { brokenStage0 = true; } } if (brokenStage2 == false) { if (Class_Controller.SqrMagnitudeToPlayer(thisTransform) < sqrtDistanceLod) { rotationLod = false; } else { rotationLod = true; } } } //-------------- moonCube.SetActive(false); //-------------- }