Пример #1
0
        /// <summary>
        /// Sets the message that will be run each time damage should be processed
        /// </summary>
        /// <param name="rMessage">Message containing information about the damage</param>
        /// <param name="rTriggerDelay">Time in seconds between triggering</param>
        /// <param name="rMaxAge">Max amount of time the effect can last</param>
        public virtual void Activate(float rMaxAge, GameObject rPrefab, Transform rParent = null)
        {
            if (rPrefab == null)
            {
                return;
            }

            GameObject lInstance = GameObject.Instantiate(rPrefab);

            if (lInstance != null)
            {
                mParticleCore = lInstance.GetComponent <ParticleCore>();
                if (mParticleCore != null)
                {
                    lInstance.transform.parent        = (rParent != null ? rParent : mActorCore.Transform);
                    lInstance.transform.localPosition = Vector3.zero;
                    lInstance.transform.localRotation = Quaternion.identity;

                    mParticleCore.Age             = 0f;
                    mParticleCore.MaxAge          = rMaxAge;
                    mParticleCore.Prefab          = rPrefab;
                    mParticleCore.OnReleasedEvent = OnParticleCoreReleased;
                    mParticleCore.Play();
                    base.Activate(0f, rMaxAge);
                }
                else
                {
                    GameObject.Destroy(lInstance);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Called when the particle core has finished running and is released
        /// </summary>
        /// <param name="rCore"></param>
        private void OnParticleCoreReleased(ILifeCore rCore, object rUserData = null)
        {
            if (mParticleCore != null)
            {
                mParticleCore.OnReleasedEvent = null;
                mParticleCore = null;
            }

            base.Deactivate();
        }