/// <summary> /// Called when the core has finished running and is released /// </summary> /// <param name="rCore"></param> protected virtual void OnCoreReleased(ILifeCore rCore, object rUserData = null) { ParticleCore lParticleCore = rCore as ParticleCore; if (lParticleCore != null && mParticleCores != null) { mParticleCores.Remove(lParticleCore); } if (mParticleCores == null || mParticleCores.Count == 0) { base.Deactivate(); } }
/// <summary> /// Activates a single target by running the links for that target /// </summary> /// <param name="rTarget"></param> protected bool ActivateInstance(GameObject rTarget, object rData) { if (rTarget != null) { if (rTarget.GetComponent <ParticleCore>() != null) { ParticleCore lParticleCore = rTarget.GetComponent <ParticleCore>(); lParticleCore.Stop(true); } else { GameObject.Destroy(rTarget); } } return(true); }
/// <summary> /// Create the splash that will play on the surface /// </summary> /// <param name="rPosition"></param> public void CreateSplash(Vector3 rPosition) { if (SplashPrefab != null) { //GameObject lSplash = GameObject.Instantiate(Resources.Load(mSplashPath)) as GameObject; GameObject lSplash = GameObjectPool.Allocate(SplashPrefab); if (lSplash != null) { ParticleCore lSplashCore = lSplash.GetComponent <ParticleCore>(); lSplashCore.Prefab = SplashPrefab; if (mWaterSurface != null) { rPosition.y = mWaterSurface.position.y; } lSplash.transform.position = rPosition; } } }
/// <summary> /// Create the underwater effect. Keep it alive as long as it's active /// </summary> /// <param name="rAnimator">Mecanim animator this swimmer is tied to</param> /// <param name="rBone">Bone the effect is to play from</param> public void CreateUnderwaterEffect(Animator rAnimator, HumanBodyBones rBone) { if (mUnderwaterCore == null) { if (UnderwaterPrefab != null) { //GameObject lUnderwater = GameObject.Instantiate(Resources.Load(mUnderwaterPath)) as GameObject; GameObject lUnderwater = GameObjectPool.Allocate(UnderwaterPrefab); if (lUnderwater != null) { Vector3 lPosition = Vector3.zero; if (rAnimator != null) { Transform lBone = rAnimator.GetBoneTransform(rBone); if (lBone != null) { lPosition = lBone.position; } } mUnderwaterCore = lUnderwater.GetComponent <ParticleCore>(); mUnderwaterCore.Prefab = UnderwaterPrefab; mUnderwaterCore.OnReleasedEvent = OnUnderwaterReleased; mUnderwaterCore.Transform.parent = mActorController._Transform; mUnderwaterCore.Transform.position = lPosition; } } } else { mUnderwaterCore.Age = 0f; if (rAnimator != null) { Transform lBone = rAnimator.GetBoneTransform(rBone); if (lBone != null) { mUnderwaterCore.Transform.position = lBone.position; } } } }
/// <summary> /// Create the ripples that will play on the surface. I the ripples exist, /// we'll simply keep them alive /// </summary> /// <param name="rPosition"></param> public void CreateRipples(Vector3 rPosition) { if (mRipplesCore == null) { if (RipplesPrefab != null) { //GameObject lRipples = GameObject.Instantiate(RipplesPrefab) as GameObject; GameObject lRipples = GameObjectPool.Allocate(RipplesPrefab); if (lRipples != null) { mRipplesCore = lRipples.GetComponent <ParticleCore>(); if (mRipplesCore != null) { mRipplesCore.Prefab = RipplesPrefab; mRipplesCore.OnReleasedEvent = OnRipplesReleased; if (mWaterSurface != null) { rPosition.y = mWaterSurface.position.y; } mRipplesCore.Transform.position = rPosition; } } } } else { mRipplesCore.Age = 0f; if (mWaterSurface != null) { rPosition.y = mWaterSurface.position.y; } mRipplesCore.Transform.position = rPosition; } }
/// <summary> /// Called when the object is selected in the editor /// </summary> private void OnEnable() { // Grab the serialized objects mTarget = (ParticleCore)target; mTargetSO = new SerializedObject(target); }
/// <summary> /// Notification that the bubbles have been destroyed /// </summary> /// <param name="rRipples"></param> public void OnUnderwaterReleased(ILifeCore rCore, object rUserData = null) { mUnderwaterCore = null; }
/// <summary> /// Notification that the ripples have been destroyed /// </summary> /// <param name="rRipples"></param> public void OnRipplesReleased(ILifeCore rCore, object rUserData = null) { mRipplesCore = null; }
/// <summary> /// Called when the action is first activated /// <param name="rPreviousSpellActionState">State of the action prior to this one activating</param> public override void Activate(int rPreviousSpellActionState = -1, object rData = null) { mIsShuttingDown = false; base.Activate(rPreviousSpellActionState, rData); if (mInstances != null && mInstances.Count > 0) { if (_Spell.ShowDebug) { for (int i = 0; i < mInstances.Count; i++) { mInstances[i].hideFlags = HideFlags.None; } } for (int i = 0; i < mInstances.Count; i++) { ParticleCore lParticleCore = mInstances[i].GetComponent <ParticleCore>(); if (lParticleCore != null) { lParticleCore.Age = 0f; lParticleCore.Prefab = _Prefab; lParticleCore.OnReleasedEvent = OnCoreReleased; if (MaxAge > 0f) { if (_DeactivationIndex == EnumSpellActionDeactivation.TIMER || _DeactivationIndex == EnumSpellActionDeactivation.IMMEDIATELY) { lParticleCore.MaxAge = MaxAge; } } if (UseAttractor) { Transform lAttractor = null; Vector3 lAttractorPosition = _AttractorOffset; // SpellData Targets if (AttractorTypeIndex == 4 && _Spell.Data.Targets != null) { if (i < _Spell.Data.Targets.Count) { lAttractor = _Spell.Data.Targets[i].transform; } } // SpellData Prev Targets else if (AttractorTypeIndex == 5 && _Spell.Data.PreviousTargets != null) { if (_Spell.Data.PreviousTargets.Count > 0) { lAttractor = _Spell.Data.PreviousTargets[_Spell.Data.PreviousTargets.Count - 1].transform; } } else { GetBestPosition(AttractorTypeIndex, rData, _Spell.Data, _AttractorOffset, out lAttractor, out lAttractorPosition); lAttractorPosition = _AttractorOffset; } lParticleCore.Attractor = lAttractor; lParticleCore.AttractorOffset = lAttractorPosition; } lParticleCore.Play(); if (mParticleCores == null) { mParticleCores = new List <ParticleCore>(); } mParticleCores.Add(lParticleCore); } // Determine how we release the spell if (_Spell.ReleaseFromCamera && Camera.main != null) { mInstances[i].transform.rotation = Camera.main.transform.rotation; } else if (ReleaseFromCameraForward && Camera.main != null) { mInstances[i].transform.rotation = Camera.main.transform.rotation; } else { mInstances[i].transform.rotation = _Spell.Owner.transform.rotation; } } } // If there were no particles, stop if (mInstances == null) { Deactivate(); } }