//--------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------- public void SetDestroyed() { if (!s_fragments) { var fragments = new GameObject("Fragments"); s_fragments = fragments.transform; } foreach (var activate in ActivateOnDestroyed) { if (activate && !activate.activeInHierarchy) { activate.SetActive(true); } } foreach (var deactivate in DeactivateOnDestroyed) { if (deactivate && deactivate.activeInHierarchy) { deactivate.SetActive(false); } } foreach (var joint in jointBreaks) { if (joint) { Destroy(joint); } } foreach (var rbody in ejectedBodies) { if (!rbody) { continue; } rbody.constraints = RigidbodyConstraints.None; m_startingParent = rbody.transform.parent; rbody.transform.SetParent(s_fragments); Destroy(rbody.gameObject, fragmentLifetime); } OnDestroyed.Invoke(); if (useExplosion) { explosiveEffect.Initilize(explosionOrigin, explosiveEffect.m_profile); explosiveEffect.Detonate(); } }
//public void PrimeProjectile() //{ // if (!gameObject.activeSelf) // gameObject.SetActive(true); // isPrimed = true; // StartCoroutine(DestroyProjectile(ProjectileLifetime)); //} protected void InitializeProjectile() { OnProjectileSpawned.Invoke(); if (isRocket && profile.rocketProfile != null) { if (rocket == null) { rocket = new RocketEffect(); } rocket.Initialize(this.gameObject, profile.rocketProfile); if (rocket.IgnitionDelay == 0) { rocket.Ignite(); } StartCoroutine(rocket.UpdateRocket(projectileBody)); } if (isExplosive && profile.explosiveProfile != null) { if (explosive == null) { explosive = new ExplosiveEffect(); } explosive.Initilize(this.gameObject, profile.explosiveProfile); OnProjectileDestroyed.AddListener(explosive.Detonate); } if (profile.SoundGroupName.Length > 0 && isClient) { DarkTonic.MasterAudio.MasterAudio.PlaySound3DAtTransform(profile.SoundGroupName, this.transform); } }
private void Start() { explosiveEffect.Initilize(gameObject, explosiveEffect.m_profile); }