//======================================== // 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(); }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions /// <summary> /// Shoot bullets multiple times in times. (not in per frame) /// </summary> public void Shoots(int hit, Vector3 pos) { if (mShootAction.Bullet == null) { JCS_Debug.LogReminders( "There is no bullet assign to \"JCS_ShootAction\", so we cannot shoot a sequence..."); return; } if (hit <= 0) { JCS_Debug.LogReminders( "Cannot shoot sequence of bullet with lower than 0 hit..."); return; } // after finding once is still null, // try it agian! if (mDetectedObject == null) { // find the target switch (mShootAction.GetTrackType()) { case JCS_ShootAction.TrackType.CLOSEST: mDetectedObject = mShootAction.GetDetectAreaAction().FindTheClosest(); break; case JCS_ShootAction.TrackType.FURTHEST: mDetectedObject = mShootAction.GetDetectAreaAction().FindTheFurthest(); break; } } // does not found the target to damage if (mDetectedObject == null) { mTargetsPerSequence.push(null); } else { // found target to damage, add in to data segment mTargetsPerSequence.push(mDetectedObject.transform); JCS_2DLiveObject liveObj = mDetectedObject.GetComponent <JCS_2DLiveObject>(); if (liveObj != null) { int defenseVal = 0; // get the targeting defense value if (liveObj.AbilityFormat != null) { defenseVal = liveObj.AbilityFormat.GetDefenseValue(); } // calculate the damage we are going to apply to // the target object. mDamageApplying = PreCalculateSequenceDamage( mAbilityFormat.GetMinDamage(), mAbilityFormat.GetMaxDamage(), hit, defenseVal); // pre calculate the damage before the // actual bullet hit the object, // so it could decide what object are dead already. // and other object or this object wont target the // object is going die. liveObj.ReceivePreCalDamage(mDamageApplying); // start targeting object to hit liveObj.BeenTarget = true; } } // thread itself mThread.push(mThread.length); // needed data mTimers.push(0); // timer to calculate between each shoot. mShootCount.push(hit); // hit per sequence. mShootCounter.push(0); // counter to count how many shoot left? mShootPos.push(pos); // position to spawn the bullet implements the position stay effect! bool isLeft = true; if (this.transform.localScale.x < 0) { isLeft = false; } // shoot direction mShootDirection.push(isLeft); // decide which direction should the bullet goes? (right/left) }
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(); }