示例#1
0
        /// <summary>
        /// Raised when we release the lock on a target
        /// </summary>
        protected virtual void OnTargetUnlocked(Transform rTransform)
        {
            if (_UnlockCameraMode >= 0)
            {
                if (mMotionController != null && mMotionController.CameraRig != null)
                {
                    mMotionController.CameraRig.Mode = _UnlockCameraMode;
                }
            }

            if (TargetUnlocked != null)
            {
                TargetUnlocked(this, rTransform);
            }

            // Send the message
            CombatMessage lMessage = CombatMessage.Allocate();

            lMessage.ID       = EnumMessageID.MSG_COMBAT_ATTACKER_TARGET_UNLOCKED;
            lMessage.Attacker = gameObject;
            lMessage.Defender = rTransform.gameObject;

            if (TargetUnlockedEvent != null)
            {
                TargetUnlockedEvent.Invoke(lMessage);
            }

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

            CombatMessage.Release(lMessage);
        }
        /// <summary>
        /// Pulls an object from the pool.
        /// </summary>
        /// <returns></returns>
        public static CombatMessage Allocate(CombatMessage rSource)
        {
            // Grab the next available object
            CombatMessage lInstance = sPool.Allocate();

            if (lInstance == null)
            {
                lInstance = new CombatMessage();
            }

            lInstance.Attacker     = rSource.Attacker;
            lInstance.Defender     = rSource.Defender;
            lInstance.Weapon       = rSource.Weapon;
            lInstance.StyleIndex   = rSource.StyleIndex;
            lInstance.CombatStyle  = rSource.CombatStyle;
            lInstance.Damage       = rSource.Damage;
            lInstance.DamageType   = rSource.DamageType;
            lInstance.ImpactPower  = rSource.ImpactPower;
            lInstance.HitVector    = rSource.HitVector;
            lInstance.HitTransform = rSource.HitTransform;
            lInstance.HitPoint     = rSource.HitPoint;
            lInstance.HitDirection = rSource.HitDirection;

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // by default.
            lInstance.IsSent    = false;
            lInstance.IsHandled = false;

            // For this type, guarentee we have something
            // to hand back tot he caller
            return(lInstance);
        }
示例#3
0
        /// <summary>
        /// Notifies the defender that they are attacked.
        /// </summary>
        /// <param name="rRound"></param>
        public virtual void OnAttacked(CombatMessage rMessage)
        {
            //com.ootii.Utilities.Debug.Log.FileWrite(_Transform.name + ".OnAttacked()");

            if (Attacked != null)
            {
                Attacked(this, rMessage);
            }

            if (rMessage.ID != CombatMessage.MSG_DEFENDER_ATTACKED)
            {
                return;
            }

            ActorCore lDefenderCore = gameObject.GetComponent <ActorCore>();

            if (lDefenderCore != null)
            {
                lDefenderCore.SendMessage(rMessage);
            }
            else
            {
                // Check if this defender is blocking, parrying, etc
                if (mMotionController != null)
                {
                    mMotionController.SendMessage(rMessage);
                }

                // Determine if we're continuing with the attack and apply damage
                if (rMessage.ID == CombatMessage.MSG_DEFENDER_ATTACKED)
                {
                    IDamageable lDamageable = gameObject.GetComponent <IDamageable>();
                    if (lDamageable != null)
                    {
                        lDamageable.OnDamaged(rMessage);
                    }
                    else
                    {
                        rMessage.ID = CombatMessage.MSG_DEFENDER_DAMAGED;
                        if (mMotionController != null)
                        {
                            mMotionController.SendMessage(rMessage);
                        }
                    }
                }

                // Disable this combatant
                if (rMessage.ID == CombatMessage.MSG_DEFENDER_KILLED)
                {
                    this.enabled = false;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Occurs prior to the defender receiving the attack notification. This
        /// allows the attacker to augment the attack if needed.
        /// </summary>
        /// <param name="rRound"></param>
        public virtual void OnPreAttack(CombatMessage rMessage)
        {
            //com.ootii.Utilities.Debug.Log.FileWrite(_Transform.name + ".OnPreAttack()");

            if (PreAttack != null)
            {
                PreAttack(this, rMessage);
            }

            if (mMotionController != null)
            {
                mMotionController.SendMessage(rMessage);
            }
        }
示例#5
0
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static void Release(CombatMessage rInstance)
        {
            if (rInstance == null)
            {
                return;
            }

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // and removed by default.
            rInstance.IsSent    = true;
            rInstance.IsHandled = true;

            // Make it available to others.
            sPool.Release(rInstance);
        }
示例#6
0
        /// <summary>
        /// Pulls an object from the pool.
        /// </summary>
        /// <returns></returns>
        public static CombatMessage Allocate()
        {
            // Grab the next available object
            CombatMessage lInstance = sPool.Allocate();

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // by default.
            lInstance.IsSent    = false;
            lInstance.IsHandled = false;

            // For this type, guarentee we have something
            // to hand back tot he caller
            if (lInstance == null)
            {
                lInstance = new CombatMessage();
            }
            return(lInstance);
        }
        /// <summary>
        /// Returns an element back to the pool.
        /// </summary>
        /// <param name="rEdge"></param>
        public static void Release(CombatMessage rInstance)
        {
            if (rInstance == null)
            {
                return;
            }

            // We should never release an instance unless we're
            // sure we're done with it. So clearing here is fine
            rInstance.Clear();

            // Reset the sent flags. We do this so messages are flagged as 'completed'
            // and removed by default.
            rInstance.IsSent    = true;
            rInstance.IsHandled = true;

            // Make it available to others.
            sPool.Release(rInstance);
        }
示例#8
0
        /// <summary>
        /// Occurs after the defender receives the attack notification. This
        /// allows the attacker to react to the defender if needed.
        /// </summary>
        /// <param name="rRound"></param>
        public virtual void OnPostAttack(CombatMessage rMessage)
        {
            //com.ootii.Utilities.Debug.Log.FileWrite(_Transform.name + ".OnPostAttack()");

            if (PostAttack != null)
            {
                PostAttack(this, rMessage);
            }

            if (mMotionController != null)
            {
                mMotionController.SendMessage(rMessage);
            }

            // If the defender was killed, release the target
            if (_Target != null && rMessage.ID == CombatMessage.MSG_DEFENDER_KILLED)
            {
                IsTargetLocked = false;
                OnTargetUnlocked(_Target);
            }
        }