コード例 #1
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)
        {
            // Ensure we're not holding onto an old spell
            mSpellInstance       = null;
            mStoredAnimatorSpeed = 0f;

            // Default the spell
            int lSpellIndex = mSpellIndex;

            // If a spell was specified (through the parameter), use it
            if (mParameter > 0)
            {
                lSpellIndex = mParameter;
            }

            // Allow the spell to be modified before the attack occurs
            MagicMessage lMessage = MagicMessage.Allocate();

            lMessage.ID            = MagicMessage.MSG_MAGIC_PRE_CAST;
            lMessage.Caster        = mMotionController.gameObject;
            lMessage.SpellIndex    = lSpellIndex;
            lMessage.CastingMotion = this;
            lMessage.Data          = this;

            IActorCore lActorCore = mMotionController.gameObject.GetComponent <ActorCore>();

            if (lActorCore != null)
            {
                lActorCore.SendMessage(lMessage);
                lSpellIndex = lMessage.SpellIndex;
            }

#if USE_MESSAGE_DISPATCHER || OOTII_MD
            MessageDispatcher.SendMessage(lMessage);
            lSpellIndex = lMessage.SpellIndex;
#endif

            MagicMessage.Release(lMessage);

            // Ensure we know what spell to cast
            if (mSpellInventory != null)
            {
                mSpellInstance = mSpellInventory.InstantiateSpell(lSpellIndex);
            }

            if (mSpellInstance == null)
            {
                return(false);
            }

            // Allow the casting
            mIKWeight              = 0f;
            mHasCast               = false;
            mIsInterrupted         = false;
            mIsInterruptedReported = false;
            mHasReachedForward     = false;
            mWasTraversal          = (mActorController.State.Stance == EnumControllerStance.TRAVERSAL);

            // Rotate towards this target. If there's no camera, we'll
            // assume we're dealing with an NPC
            if (mMotionController._CameraTransform != null)
            {
                mTargetForward = mMotionController._CameraTransform.forward;
            }

            //// Ensure our combatant is setup
            //if (mCombatant != null)
            //{
            //    if (!mCombatant.OnAttackActivated(this))
            //    {
            //        return false;
            //    }
            //}

            // Run the approapriate cast
            int lMotionPhase = (mWasTraversal ? PHASE_STANDING_START : PHASE_START);
            mMotionController.SetAnimatorMotionPhase(mMotionLayer.AnimatorLayerIndex, lMotionPhase, mSpellInstance.CastingStyle, 0, true);

            // Now, activate the motion
            return(base.Activate(rPrevMotion));
        }