//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions //---------------------- // Protected Functions //---------------------- // Private Functions /// <summary> /// Do the damage to live object. /// </summary> /// <param name="liveObject"></param> private void DamageLiveObject(JCS_2DLiveObject liveObject) { // if cannot damage this live object than do nothing. if (!liveObject.CanDamage) { return; } 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 == mLiveObject.IsPlayer) { return; } } if (mAbilityFormat == null) { JCS_Debug.LogReminders( "You sure to not using any \"JCS_AbilityFormat\"?"); return; } liveObject.ApplyDamageText( mAbilityFormat.GetMinDamage(), mAbilityFormat.GetMaxDamage(), this.transform.position, 1, // hit 0, mHitSound); // critical chance // see if the collider is player. JCS_Player p = liveObject.GetComponent <JCS_Player>(); if (p == null) { return; } // if the living object we are attacking is // player do the hit effect. p.Hit(); }
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(); }