/// <summary>
        ///
        /// </summary>
        /// <param name="liveObj"> object to check </param>
        /// <returns>
        /// true: able to target, no worry.
        /// false: not able to target by following reason.
        ///             1) Same Tribe
        ///             2) not able in the scene/hierarchy.
        /// </returns>
        private bool AbleTarget(JCS_2DLiveObject liveObj)
        {
            if (mAttackerInfo.Attacker != null)
            {
                // cannot target it-self.
                if (liveObj.transform == mAttackerInfo.Attacker)
                {
                    return(false);
                }

                JCS_2DLiveObject owenerLiveObject = mAttackerInfo.Attacker.GetComponent <JCS_2DLiveObject>();

                if (!JCS_GameSettings.instance.TRIBE_DAMAGE_EACH_OTHER)
                {
                    // check same tribe.
                    if (JCS_Utility.IsSameTribe(liveObj, owenerLiveObject))
                    {
                        return(false);
                    }
                }
            }

            // don't target the are disabled.
            if (liveObj.gameObject.activeInHierarchy == false)
            {
                return(false);
            }

            // don't target the dead live object
            if (liveObj.IsDead())
            {
                return(false);
            }

            // make sure the object can be target/damage.
            if (!liveObj.CanDamage)
            {
                return(false);
            }


            return(true);
        }
示例#2
0
        private void OnTriggerEnter(Collider other)
        {
            if (mIsDestroyed)
            {
                return;
            }

            // do not target itself.
            if (other.transform == mAttackerInfo.Attacker)
            {
                return;
            }


            if (mInSequence)
            {
                if (mDestroyByThisAction)
                {
                    if (mTargetTransform == other.transform)
                    {
                        Destroy(this.gameObject);
                    }
                }

                return;
            }

            JCS_2DLiveObject liveObject = other.GetComponent <JCS_2DLiveObject>();

            // doing the lock on effect
            if (mOnlyWithTarget)
            {
                // if the target isn't what we want ignore than.
                if (mTargetTransform != other.transform)
                {
                    return;
                }
                else
                {
                    if (liveObject != null)
                    {
                        JCS_2DTrackAction tact = this.GetComponent <JCS_2DTrackAction>();

                        // only the last bullet in sequence will check dead.
                        if (tact != null)
                        {
                            if (tact.OrderIndex == Hit)
                            {
                                liveObject.BeenTarget = false;
                                liveObject.CheckDie();
                            }
                        }
                    }

                    DestroyWithAction();
                }
            }
            // if not in sequence
            else
            {
                if (liveObject == null)
                {
                    return;
                }

                if (!liveObject.CanDamage)
                {
                    return;
                }

                // liveObject is already dead.
                if (liveObject.IsDead())
                {
                    //DestroyWithAction();
                    return;
                }
            }

            Transform attacker = mAttackerInfo.Attacker;

            if (attacker != null)
            {
                JCS_2DLiveObject owenerLiveObject = mAttackerInfo.Attacker.GetComponent <JCS_2DLiveObject>();
                if (owenerLiveObject != null)
                {
                    if (!JCS_GameSettings.instance.TRIBE_DAMAGE_EACH_OTHER)
                    {
                        // if both player does not need to add in to list.
                        // or if both enemy does not need to add in to list.
                        if (liveObject.IsPlayer == owenerLiveObject.IsPlayer)
                        {
                            return;
                        }
                    }
                }
            }

            if (mAbilityFormat != null)
            {
                mMinDamage      = mAbilityFormat.GetMinDamage();
                mMaxDamage      = mAbilityFormat.GetMaxDamage();
                mCriticalChance = mAbilityFormat.GetCriticalChance();
            }
            else
            {
                JCS_Debug.LogReminder(
                    "You sure to not using any \"JCS_AbilityFormat\"?");
            }

            Vector3 currentPos = liveObject.transform.position + mDamageTextPositionOffset;

            if (mRandPos)
            {
                AddRandomPosition(ref currentPos);
            }

            if (mPreCalculateEffect)
            {
                liveObject.ApplyDamageText(
                    this.mAttackerInfo.Attacker,
                    mDamageApplying,
                    currentPos,
                    mCriticalChance,
                    mHitSound);

                mHit = this.mDamageApplying.Length;
            }
            else
            {
                liveObject.ApplyDamageText(
                    this.mAttackerInfo.Attacker,
                    mMinDamage,
                    mMaxDamage,
                    currentPos,
                    mHit,
                    mCriticalChance,
                    mHitSound);
            }

            // only if there is only one hit need to do this.
            if (mHit == 1)
            {
                liveObject.BeenTarget = false;
            }

            liveObject.CheckDie();

            DestroyWithAction();
        }