/// <summary>
        /// Removes the motion from the list of motions being managed
        /// </summary>
        /// <param name="rMotion">Motion to remove</param>
        public void RemoveMotion(MotionControllerMotion rMotion)
        {
            Motions.Remove(rMotion);

            rMotion.MotionController = null;
            rMotion.MotionLayer      = null;
        }
Beispiel #2
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mIsEquipped = false;

            // Tell the actor controller about our stance (in case the motion was forced)
            mActorController.State.Stance = EnumControllerStance.SPELL_CASTING;

            // If we already have equipment in hand, we don't need to run this motion
            if (mInventorySource != null)
            {
                string lItemID = (_OverrideItemID != null && _OverrideItemID.Length > 0 ? _OverrideItemID : _ItemID);
                string lSlotID = (_OverrideSlotID != null && _OverrideSlotID.Length > 0 ? _OverrideSlotID : _SlotID);

                string lEquippedItemID = mInventorySource.GetItemID(lSlotID);
                if (lEquippedItemID != null && lEquippedItemID.Length > 0)
                {
                    if (lItemID != null && lItemID.Length > 0 && lItemID == lEquippedItemID)
                    {
                        return(false);
                    }
                }
            }

            // Trigger the animation
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true);
            return(base.Activate(rPrevMotion));
        }
        /// <summary>
        /// Clear this instance.
        /// </summary>
        public override void Clear()
        {
            Motion   = null;
            Continue = false;

            base.Clear();
        }
Beispiel #4
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, _Form, mParameter, true);

            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #5
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mIdleTime         = 0f;
            mIsRotationLocked = false;

            mInputX.Clear();
            mInputY.Clear();
            mInputMagnitude.Clear();

            // Update the max speed based on our animation
            mMotionController.MaxSpeed = 5.668f;

            // Start the motion
            mActiveForm = (_Form >= 0 ? _Form : mMotionController.CurrentForm);
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, mActiveForm, 0, true);

            // Register this motion with the camera
            if (mMotionController.CameraRig is BaseCameraRig)
            {
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated;
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated;
            }

            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #6
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mStopTime     = 0f;
            mStopInput    = Vector2.zero;
            mLinkRotation = false;

            // Helps with syncronizing from a motion like attack
            float lRunFactor = (IsRunActive ? 1f : 0.5f);

            mInputX.Clear(mMotionController.State.InputX * lRunFactor);
            mInputY.Clear(mMotionController.State.InputY * lRunFactor);

            // Update the max speed based on our animation
            mMotionController.MaxSpeed = (_RunSpeed > 0f ? _RunSpeed : 3.2f);

            // Determine how we'll start our animation
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true);

            // Register this motion with the camera
            if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig)
            {
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated;
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated;
            }

            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #7
0
        /// <summary>
        /// New way to create sub-state machines without destroying what exists first.
        /// </summary>
        protected override void CreateStateMachine()
        {
            int rLayerIndex = mMotionLayer._AnimatorLayerIndex;
            MotionController rMotionController = mMotionController;

            UnityEditor.Animations.AnimatorController lController = null;

            Animator lAnimator = rMotionController.Animator;

            if (lAnimator == null)
            {
                lAnimator = rMotionController.gameObject.GetComponent <Animator>();
            }
            if (lAnimator != null)
            {
                lController = lAnimator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
            }
            if (lController == null)
            {
                return;
            }

            while (lController.layers.Length <= rLayerIndex)
            {
                UnityEditor.Animations.AnimatorControllerLayer lNewLayer = new UnityEditor.Animations.AnimatorControllerLayer();
                lNewLayer.name         = "Layer " + (lController.layers.Length + 1);
                lNewLayer.stateMachine = new UnityEditor.Animations.AnimatorStateMachine();
                lController.AddLayer(lNewLayer);
            }

            UnityEditor.Animations.AnimatorControllerLayer lLayer = lController.layers[rLayerIndex];

            UnityEditor.Animations.AnimatorStateMachine lLayerStateMachine = lLayer.stateMachine;

            UnityEditor.Animations.AnimatorStateMachine lSSM_37928 = MotionControllerMotion.EditorFindSSM(lLayerStateMachine, "BasicEquipStore-SM");
            if (lSSM_37928 == null)
            {
                lSSM_37928 = lLayerStateMachine.AddStateMachine("BasicEquipStore-SM", new Vector3(192, -1008, 0));
            }

#if USE_ARCHERY_MP || OOTII_AYMP
            ArcheryPackDefinition.ExtendBasicEquipStore(rMotionController, rLayerIndex);
#endif

#if USE_SWORD_SHIELD_MP || OOTII_SSMP
            SwordShieldPackDefinition.ExtendBasicEquipStore(rMotionController, rLayerIndex);
#endif

#if USE_SPELL_CASTING_MP || OOTII_SCMP
            SpellCastingPackDefinition.ExtendBasicEquipStore(rMotionController, rLayerIndex);
#endif

#if USE_SHOOTER_MP || OOTII_SHMP
            ShooterPackDefinition.ExtendBasicEquipStore(rMotionController, rLayerIndex);
#endif


            // Run any post processing after creating the state machine
            OnStateMachineCreated();
        }
Beispiel #8
0
        private void OnIsAliveChanged(bool alive)
        {
            m_IsActive &= alive;

            if (alive)
            {
                return;
            }

            CombatMessage message = CombatMessage.Allocate();

            if (message != null)
            {
                message.ID         = EnumMessageID.MSG_COMBAT_DEFENDER_KILLED;
                message.StyleIndex = -1; // Random
                message.Defender   = m_MotionController.gameObject;
                m_MotionController.SendMessage(message);
                message.Release();
            }

            if (m_NavMeshAgent != null)
            {
                m_NavMeshAgent.isStopped = true;
            }

            if (message.IsHandled)
            {
                m_DeathMotion = message.Recipient as MotionControllerMotion;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mNoInputElapsed = 0f;
            mLinkRotation   = false;

            // Force the stance
            mSwimmerInfo.EnterWater();

            if (rPrevMotion is Jump || rPrevMotion is Fall)
            {
                mSwimmerInfo.CreateSplash();
            }

            // Helps with syncronizing from a motion like attack
            float lRunFactor = (IsRunActive ? 1f : 0.5f);

            mInputX.Clear(mMotionController.State.InputX * lRunFactor);
            mInputY.Clear(mMotionController.State.InputY * lRunFactor);
            mInputMagnitude.Clear(Mathf.Sqrt((mInputX.Value * mInputX.Value) + (mInputY.Value * mInputY.Value)));

            // Determine how we'll start our animation
            mMotionController.ForcedInput = Vector3.zero;
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true);

            // Register this motion with the camera
            if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig)
            {
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated;
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated;
            }

            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #10
0
        /// <summary>
        /// Equip all items in the weapon set
        /// </summary>
        /// <param name="rIndex">Index of the weapon set whose items will be stored</param>
        protected virtual IEnumerator Internal_EquipWeaponsSet(int rIndex)
        {
            // First, find all the entries with no equip motions and spawn them first
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventoryItem lItem = GetInventoryItem(WeaponSets[rIndex].Items[i].ItemID);
                if (lItem != null && lItem.EquipMotion.Length == 0)
                {
                    BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                    if (lSlot != null)
                    {
                        if (WeaponSets[rIndex].Items[i].Instantiate)
                        {
                            GameObject lInstance = EquipItem(lItem.ID, lSlot.ID);
                            if (lInstance != null)
                            {
                                lSlot.ItemID = lItem.ID;
                            }
                        }
                        else
                        {
                            lSlot.ItemID = lItem.ID;
                        }
                    }
                }
            }

            // Now, find all the entries that do have an equip motion
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventoryItem lItem = GetInventoryItem(WeaponSets[rIndex].Items[i].ItemID);
                if (lItem != null && lItem.EquipMotion.Length > 0)
                {
                    BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                    if (lSlot != null && lSlot.ItemID.Length == 0)
                    {
                        // If we have a motion to equip, activate it
                        MotionControllerMotion lMotion = mMotionController.GetMotion(lItem.EquipMotion);
                        if (lMotion != null)
                        {
                            IEquipStoreMotion lEquipStoreMotion = lMotion as IEquipStoreMotion;
                            if (lEquipStoreMotion != null)
                            {
                                lEquipStoreMotion.OverrideItemID = lItem.ID;
                                lEquipStoreMotion.OverrideSlotID = lSlot.ID;
                            }

                            mMotionController.ActivateMotion(lMotion);
                            while (lMotion.IsActive || lMotion.QueueActivation)
                            {
                                yield return(null);
                            }

                            // Set the item
                            lSlot.ItemID = lItem.ID;
                        }
                    }
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mIdleTime     = 0f;
            mLinkRotation = false;

            mInputX.Clear();
            mInputY.Clear();
            mInputMagnitude.Clear();

            // Update the max speed based on our animation
            mMotionController.MaxSpeed = 5.668f;

            // Determine how we'll start our animation
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true);

            // Register this motion with the camera
            if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig)
            {
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated;
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated;
            }

            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #12
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mHasLanded   = false;
            mHasLaunched = false;

            // Ensure the AC allows us to levitate
            mStoredIsGravityEnabled           = mActorController.IsGravityEnabled;
            mActorController.IsGravityEnabled = false;

            mStoredIsOrientationEnabled     = mActorController.OrientToGround;
            mActorController.OrientToGround = false;

            mActorController.FixGroundPenetration = false;

            // Run the approapriate cast
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, 0, true);

            // Register this motion with the camera
            if (_RotateWithCamera && mMotionController.CameraRig is BaseCameraRig)
            {
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate -= OnCameraUpdated;
                ((BaseCameraRig)mMotionController.CameraRig).OnPostLateUpdate += OnCameraUpdated;
            }

            // Now, activate the motion
            return(base.Activate(rPrevMotion));
        }
Beispiel #13
0
        /// <summary>
        /// Activates the motion on the specified target
        /// </summary>
        /// <param name="rTarget">GameObject to activate the motion on</param>
        /// <returns>Bool that determines if the motion was activated</returns>
        public bool ActivateInstance(GameObject rTarget)
        {
            bool lIsActivated = false;

            // Check if we have a motion controller and activate the motion
            MotionController lMotionController = rTarget.GetComponent <MotionController>();

            if (lMotionController != null)
            {
                mMotion = lMotionController.ActivateMotion(MotionName);
                if (mMotion != null)
                {
                    lIsActivated = true;

                    // Clear out any event first, then add our event
                    if (TargetTypeIndex == 0 || TargetTypeIndex == 1)
                    {
                        mMotion.OnDeactivatedEvent -= OnMotionDeactivated;
                        mMotion.OnDeactivatedEvent += OnMotionDeactivated;
                    }
                }
                // Grab the state as needed
                if (ExitState.Length > 0)
                {
                    mExitStateID = lMotionController.AddAnimatorName(ExitState);
                }
            }

            return(lIsActivated);
        }
Beispiel #14
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, (IsRunActive ? 1 : 0), true);

            // Flag this motion as active
            return(base.Activate(rPrevMotion));
        }
Beispiel #15
0
        /// <summary>
        /// Raised when a motion is being interrupted by another motion
        /// </summary>
        /// <param name="rMotion">Motion doing the interruption</param>
        /// <returns>Boolean determining if it can be interrupted</returns>
        public override bool TestInterruption(MotionControllerMotion rMotion)
        {
            // Since we're dealing with a blend tree, keep the value until the transition completes
            mMotionController.ForcedInput.x = mInputX.Average;
            mMotionController.ForcedInput.y = mInputY.Average;

            return(true);
        }
Beispiel #16
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mActiveForm = (_Form >= 0 ? _Form : mMotionController.CurrentForm);
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, mActiveForm, 0, true);

            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #17
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            mIsEquipped = true;

            // Trigger the animation
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, true);
            return(base.Activate(rPrevMotion));
        }
Beispiel #18
0
        /// <summary>
        /// Store all items in the weapon set
        /// </summary>
        /// <param name="rIndex">Index of the weapon set whose items will be stored</param>
        protected virtual IEnumerator Internal_StoreWeaponsSet(int rIndex)
        {
            mIsEquippingItem = true;

            // First, find all the entries that do have a store motion
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                if (lSlot != null && lSlot.ItemID.Length > 0)
                {
                    BasicInventoryItem lItem = GetInventoryItem(lSlot.ItemID);
                    if (lItem != null && lItem.StoreMotion.Length > 0)
                    {
                        // If we have a motion to unequip, activate it
                        MotionControllerMotion lMotion = mMotionController.GetMotion(lItem.StoreMotion);
                        if (lMotion != null)
                        {
                            // This is an extra test so we don't try to sheathe a weapons we just
                            // unsheathed... until we're totally done with the transitions
                            while (lMotion.MotionLayer._AnimatorTransitionID != 0)
                            {
                                yield return(null);
                            }

                            // Ensure we override the item and slot
                            IEquipStoreMotion lEquipStoreMotion = lMotion as IEquipStoreMotion;
                            if (lEquipStoreMotion != null)
                            {
                                lEquipStoreMotion.OverrideItemID = lItem.ID;
                                lEquipStoreMotion.OverrideSlotID = lSlot.ID;
                            }

                            // Now sheathe
                            mMotionController.ActivateMotion(lMotion);
                            while (lMotion.IsActive || lMotion.QueueActivation)
                            {
                                yield return(null);
                            }

                            // Clear the item
                            lSlot.ItemID = "";
                        }
                    }
                }
            }

            // Second, find all the entries with no store motions destroy them
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                if (lSlot != null && lSlot.ItemID.Length > 0)
                {
                    StoreItem(lSlot.ID);
                }
            }

            mIsEquippingItem = false;
        }
        /// <summary>
        /// Moves the agent to the link in a straight line
        /// </summary>
        /// <param name="speed">Speed at which we'll move</param>
        protected IEnumerator ClimbUp(float rSpeed)
        {
            bool lStoredUpdatePosition = mNavMeshAgent.updatePosition;
            bool lStoredUpdateRotation = mNavMeshAgent.updateRotation;

            mNavMeshAgent.updatePosition = false;
            mNavMeshAgent.updateRotation = false;

            // First, move to the nav mesh start position
            Vector3 lTargetPosition = mOffMeshLinkData.startPos + (Vector3.up * mNavMeshAgent.baseOffset);

            while (mMotionController._Transform.position != lTargetPosition)
            {
                mMotionController._Transform.position = Vector3.MoveTowards(mMotionController._Transform.position, lTargetPosition, rSpeed * Time.deltaTime);

                float lAngle = NumberHelper.GetHorizontalAngle(mMotionController._Transform.forward, (mOffMeshLinkData.endPos - mOffMeshLinkData.startPos).normalized, mMotionController._Transform.up);
                mMotionController._Transform.rotation = mMotionController._Transform.rotation * Quaternion.AngleAxis(lAngle * 0.05f, Vector3.up);

                yield return(null);
            }

            // Next, lets see if we can find a climb motion that will handle our movement
            NavigationMessage lMessage = NavigationMessage.Allocate();

            lMessage.ID = NavigationMessage.MSG_NAVIGATE_CLIMB;

            mMotionController.SendMessage(lMessage);

            if (lMessage.IsHandled)
            {
                // Wait for the climb to finish
                mMotionController.ActorController.UseTransformPosition = false;

                MotionControllerMotion lMotion = lMessage.Recipient as MotionControllerMotion;
                while (lMotion != null && (lMotion.QueueActivation || lMotion.IsActive))
                {
                    yield return(null);
                }

                mMotionController.ActorController.UseTransformPosition = true;

                // Finally, move to the nav mesh end position
                lTargetPosition = mOffMeshLinkData.endPos + (Vector3.up * mNavMeshAgent.baseOffset);
                while (mMotionController._Transform.position != lTargetPosition)
                {
                    mMotionController._Transform.position = Vector3.MoveTowards(mMotionController._Transform.position, lTargetPosition, rSpeed * Time.deltaTime);
                    yield return(null);
                }
            }
            else
            {
                yield return(mMotionController.StartCoroutine(MoveParabola(mHeight, rSpeed)));
            }

            mNavMeshAgent.Warp(mMotionController._Transform.position);
            mNavMeshAgent.updatePosition = lStoredUpdatePosition;
            mNavMeshAgent.updateRotation = lStoredUpdateRotation;
        }
Beispiel #20
0
        /// <summary>
        /// Coroutine to play the death animation and disable the actor after a couple of seconds
        /// </summary>
        /// <param name="rDamageValue">Amount of damage to take</param>
        /// <param name="rDamageType">Damage type taken</param>
        /// <param name="rAttackAngle">Angle that the damage came from releative to the actor's forward</param>
        /// <param name="rBone">Transform that the damage it... if known</param>
        /// <returns></returns>
        protected virtual IEnumerator InternalDeath(IMessage rMessage)
        {
            ActorController  lActorController  = gameObject.GetComponent <ActorController>();
            MotionController lMotionController = gameObject.GetComponent <MotionController>();

            // Run the death animation if we can
            if (rMessage != null && lMotionController != null)
            {
                // Send the message to the MC to let it activate
                rMessage.ID = CombatMessage.MSG_DEFENDER_KILLED;
                lMotionController.SendMessage(rMessage);

                if (!rMessage.IsHandled && DeathMotion.Length > 0)
                {
                    MotionControllerMotion lMotion = lMotionController.GetMotion(DeathMotion);
                    if (lMotion != null)
                    {
                        lMotionController.ActivateMotion(lMotion);
                    }
                    else
                    {
                        int lID = Animator.StringToHash(DeathMotion);
                        if (lID != 0)
                        {
                            Animator lAnimator = gameObject.GetComponent <Animator>();
                            if (lAnimator != null)
                            {
                                try
                                {
                                    lAnimator.CrossFade(DeathMotion, 0.25f, 0);
                                }
                                catch { }
                            }
                        }
                    }
                }

                // Trigger the death animation
                yield return(new WaitForSeconds(3.0f));

                // Shut down the MC
                lMotionController.enabled = false;
                lMotionController.ActorController.enabled = false;
            }

            // Disable all colliders
            Collider[] lColliders = gameObject.GetComponents <Collider>();
            for (int i = 0; i < lColliders.Length; i++)
            {
                lColliders[i].enabled = false;
            }

            if (lActorController != null)
            {
                lActorController.RemoveBodyShapes();
            }
        }
Beispiel #21
0
        /// <summary>
        /// Registers a motion with the behavior
        /// </summary>
        /// <param name="rAnimator"></param>
        /// <param name="rMotion"></param>
        public virtual void AddMotion(MotionControllerMotion rMotion)
        {
            if (mMotions.IndexOf(rMotion) < 0)
            {
                mMotions.Add(rMotion);
            }

            mMotionCount = mMotions.Count;
        }
        /// <summary>
        /// Raised when a motion is being interrupted by another motion
        /// </summary>
        /// <param name="rMotion">Motion doing the interruption</param>
        /// <returns>Boolean determining if it can be interrupted</returns>
        public override bool TestInterruption(MotionControllerMotion rMotion)
        {
            // ********************************************************************************
            // 16. If another motion with a higher priority wants to activate and deactivate
            //     your motion, you can prevent that from happening here. Simply return 'false'.
            // ********************************************************************************

            return(true);
        }
        /// <summary>
        /// Adds a motion to the list of motions being managed
        /// </summary>
        /// <param name="rMotion">Motion to add</param>
        public void AddMotion(MotionControllerMotion rMotion)
        {
            if (!Motions.Contains(rMotion))
            {
                rMotion.MotionController = mMotionController;
                rMotion.MotionLayer      = this;

                Motions.Add(rMotion);
            }
        }
Beispiel #24
0
        /// <summary>
        /// Called to start the specific motion. If the motion
        /// were something like 'jump', this would start the jumping process
        /// </summary>
        /// <param name="rPrevMotion">Motion that this motion is taking over from</param>
        public override bool Activate(MotionControllerMotion rPrevMotion)
        {
            // Trigger the transition
            mActiveForm = (mActiveForm >= 0 ? mActiveForm : _Form);
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, PHASE_START, mActiveForm, mParameter, true);


            // Finalize the activation
            return(base.Activate(rPrevMotion));
        }
Beispiel #25
0
        /// <summary>
        /// Example code on how to force which attack style to use.
        /// </summary>
        /// <param name="rCombatant">Combatant the event was fired for</param>
        /// <param name="rMotion">Motion that represents the attack</param>
        /// <returns></returns>
        private bool OnAttackActivated(Combatant rCombatant, MotionControllerMotion rMotion)
        {
            BasicSpellCasting lAttacks = rMotion as BasicSpellCasting;

            if (lAttacks != null)
            {
                lAttacks.SpellIndex = 0;
            }

            return(true);
        }
Beispiel #26
0
        /// <summary>
        /// Allows the combatant a chance to modify the motion before it is fully activated.
        /// </summary>
        /// <param name="rMotion">Motion that is being activated</param>
        /// <returns>Boolean used to determine if the motion should continue activation.</returns>
        public virtual bool OnAttackActivated(MotionControllerMotion rMotion)
        {
            //com.ootii.Utilities.Debug.Log.FileWrite(_Transform.name + ".OnAttackActivated(" + rMotion.GetType().Name + ")");

            if (AttackActivated != null)
            {
                return(AttackActivated(this, rMotion));
            }

            return(true);
        }
Beispiel #27
0
        /// <summary>
        /// Raised when a motion is being interrupted by another motion
        /// </summary>
        /// <param name="rMotion">Motion doing the interruption</param>
        /// <returns>Boolean determining if it can be interrupted</returns>
        public override bool TestInterruption(MotionControllerMotion rMotion)
        {
            if (rMotion is Fall)
            {
                if (mActorController.State.GroundSurfaceDistance < 2f)
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #28
0
        /// <summary>
        /// Deactivates the motion on the specified target
        /// </summary>
        /// <param name="rTarget">GameObject to activate the motion on</param>
        /// <returns>Bool that determines if the motion was activated</returns>
        public void ActivateInstance(GameObject rTarget)
        {
            MotionController lMotionController = rTarget.GetComponent <MotionController>();

            if (lMotionController != null)
            {
                MotionControllerMotion lMotion = lMotionController.ActiveMotion;
                if (lMotion != null && (lMotion.Name == _MotionName || lMotion.GetType().Name == _MotionName))
                {
                    lMotion.Deactivate();
                }
            }
        }
Beispiel #29
0
        /// <summary>
        /// Determines if this motion can be interrupted
        /// </summary>
        /// <param name="rMotion"></param>
        /// <returns></returns>
        public override bool TestInterruption(MotionControllerMotion rMotion)
        {
            // Don't allow the fall to kick in if we're close to the ground
            if (rMotion is Fall)
            {
                if (mActorController.State.GroundSurfaceDistance < 1f)
                {
                    return(false);
                }
            }

            return(base.TestInterruption(rMotion));
        }
Beispiel #30
0
        /// <summary>
        /// Raised when a motion is being interrupted by another motion
        /// </summary>
        /// <param name="rMotion">Motion doing the interruption</param>
        /// <returns>Boolean determining if it can be interrupted</returns>
        public override bool TestInterruption(MotionControllerMotion rMotion)
        {
            if (rMotion.Category != EnumMotionCategories.DEATH)
            {
                if (mIsEquipped)
                {
                    mIsEquipped = false;
                    StoreItem();
                }
            }

            return(base.TestInterruption(rMotion));
        }