Exemplo n.º 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 override void Activate(float rTriggerDelay, float rMaxAge)
        {
            bool lActivated = false;

            // Check if we can modify the movement each frame
            mActorController = mActorCore.gameObject.GetComponent <ActorController>();
            if (mActorController != null)
            {
                // If we are in control of movement, this is a bit easier
                if (!mActorController.UseTransformPosition)
                {
                    lActivated = true;
                    mActorController.OnPreControllerMove += OnControllerMoved;
                }
            }

            // If we couldn't use the Actor Controller, let's see if we can use a nav mesh angent
            if (!lActivated)
            {
                mNavMeshDriver = mActorCore.gameObject.GetComponent <NavMeshDriver>();
                if (mNavMeshDriver != null)
                {
                    lActivated     = true;
                    mOriginalSpeed = mNavMeshDriver.MovementSpeed;

                    mNavMeshDriver.MovementSpeed = mNavMeshDriver.MovementSpeed * _MovementFactor;
                }
            }

            // If we couldn't use the Actor Controller, let's see if we can use a nav mesh angent
            if (!lActivated)
            {
                mNavMeshAgent = mActorCore.gameObject.GetComponent <NavMeshAgent>();
                if (mNavMeshAgent != null)
                {
                    lActivated     = true;
                    mOriginalSpeed = mNavMeshAgent.speed;

                    mNavMeshAgent.speed = mNavMeshAgent.speed * _MovementFactor;
                }
            }

            base.Activate(rTriggerDelay, rMaxAge);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when the effect is meant to be deactivated
        /// </summary>
        public override void Deactivate()
        {
            if (mActorController != null)
            {
                mActorController.OnPreControllerMove -= OnControllerMoved;
                mActorController = null;
            }

            if (mNavMeshDriver != null)
            {
                mNavMeshDriver.MovementSpeed = mOriginalSpeed;
                mNavMeshDriver = null;
            }

            if (mNavMeshAgent != null)
            {
                mNavMeshAgent.speed = mOriginalSpeed;
                mNavMeshAgent       = null;
            }

            base.Deactivate();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Called when the object is selected in the editor
 /// </summary>
 private void OnEnable()
 {
     // Grab the serialized objects
     mTarget   = (NavMeshDriver)target;
     mTargetSO = new SerializedObject(target);
 }
 /// <summary>
 /// Called when the object is selected in the editor
 /// </summary>
 private void OnEnable()
 {
     // Grab the serialized objects
     mTarget = (NavMeshDriver)target;
     mTargetSO = new SerializedObject(target);
 }