/// <summary> /// Stops and clears particles when they all finish. Despawns this object with the pool. /// </summary> private void OnParticleSystemsDead() { if (system != null) { system.stop(); system.clear(); } StartCoroutine(WaitForAudio()); }
/// <summary> /// Initializes the LineRenderer's that are the lasers and /// the muzzle flash emitter pool. /// </summary> protected override void SetupWeapon() { leftLaser = left.gameObject.AddComponent <LineRenderer>(); leftLaser.material = laserMaterial; leftLaser.shadowCastingMode = ShadowCastingMode.Off; leftLaser.receiveShadows = false; leftLaser.alignment = LineAlignment.View; leftLaser.startWidth = thickness; leftLaser.endWidth = thickness; leftLaser.enabled = false; rightLaser = right.gameObject.AddComponent <LineRenderer>(); rightLaser.material = laserMaterial; rightLaser.shadowCastingMode = ShadowCastingMode.Off; rightLaser.receiveShadows = false; rightLaser.alignment = LineAlignment.View; rightLaser.startWidth = thickness; rightLaser.endWidth = thickness; rightLaser.enabled = false; muzzleFlashEmitters = new ParticleSystems[Mathf.FloorToInt(fireRate * 2.5f)]; muzzleFlashIndex = 0; for (int i = 0; i < muzzleFlashEmitters.Length; ++i) { GameObject muzzleFlash = Instantiate(muzzleFlashEmitter, transform); ParticleSystems muzzleFlashSystem = muzzleFlash.GetComponent <ParticleSystems>(); muzzleFlashSystem.stop(); muzzleFlashSystem.clear(); muzzleFlashEmitters[i] = muzzleFlashSystem; } }
/// <summary> /// Initializes the LineRenderer's for the minigun tracers and /// the muzzle flash emitter pool. /// </summary> protected override void SetupWeapon() { foreach (Renderer r in barrelRenderers) { r.material.SetColor("_overheatColor", overheatBarrelColor); r.material.SetFloat("_overheatPercent", 0.0f); } for (int i = 0; i < left.Length; ++i) { InitLineRenderer(left[i]); InitLineRenderer(right[i]); } muzzleFlashEmitters = new ParticleSystems[Mathf.FloorToInt(fireRate * 2.5f)]; muzzleFlashIndex = 0; for (int i = 0; i < muzzleFlashEmitters.Length; ++i) { GameObject muzzleFlash = Instantiate(muzzleFlashEmitter, transform); ParticleSystems muzzleFlashSystem = muzzleFlash.GetComponent <ParticleSystems>(); muzzleFlashSystem.stop(); muzzleFlashSystem.clear(); muzzleFlashEmitters[i] = muzzleFlashSystem; } }