public void SendPlayerDamage(int DamageAmount, Transform Target, EmeraldAISystem EmeraldComponent, bool CriticalHit = false) { if (!m_Initialised) { Initialise(); } // Store the AI m_AI = EmeraldComponent; // Apply damage if (m_HealthManager != null) { m_HealthManager.AddDamage(DamageAmount, CriticalHit, this); } // Kick the camera position & rotation if (m_HeadKicker != null) { // Get direction of attack var direction = transform.position - EmeraldComponent.transform.position; direction.y = 0; direction.Normalize(); m_HeadKicker.KickPosition(direction * k_KickDistance, k_KickDuration); m_HeadKicker.KickRotation(Quaternion.AngleAxis(k_KickRotation, Vector3.Cross(direction, Vector3.up)), k_KickDuration); } }
/// <summary> /// Attempt to damage the Target. /// </summary> /// <returns>Return true if an attack was made (whether damage was done or not)</returns> IEnumerator DamageTarget() { IAiWeapon weapon = m_AiCharacter.quickSlots.selected.GetComponent <IAiWeapon>(); if (weapon == null) { yield return(null); } var character = currentTarget.GetComponent <NeoFPS.ICharacter>(); if (character == null) { yield return(null); } var kicker = character.headTransformHandler.GetComponent <NeoFPS.AdditiveKicker>(); if (kicker == null) { yield return(null); } m_AiAnimator.SetTrigger("Attack"); m_CurrentStatus = TaskStatus.Running; yield return(new WaitForSeconds(weapon.timeToImpact)); bool isCritical = false; m_TargetHealthManager.AddDamage(weapon.damageAmount, isCritical, this); // Get direction of attack var direction = m_Target.Value.transform.position - transform.position; direction.y = 0; direction.Normalize(); // Kick the camera position & rotation kicker.KickPosition(direction * weapon.kickDistance, weapon.kickDuration); kicker.KickRotation(Quaternion.AngleAxis(weapon.kickRotation, Vector3.Cross(direction, Vector3.up)), weapon.kickDuration); yield return(new WaitForSeconds(weapon.recoveryTime)); m_CurrentStatus = TaskStatus.Success; }