//LETHAL FORCES - add health to player 2 void AddHealthToPlayer2(GameObject player) { HealthSystemP2 hs2 = player.GetComponent <HealthSystemP2>(); //LETHAL FORCES - P2 Health if (hs2 != null) { //restore hp to unit hs2.AddHealth(RestoreHP); } else { Debug.Log("no health system found on GameObject '" + player.gameObject.name + "'."); } //show pickup effect if (pickupEffect != null) { GameObject effect = GameObject.Instantiate(pickupEffect); effect.transform.position = transform.position; } //play sfx if (pickupSFX != "") { GlobalAudioPlayer.PlaySFXAtPosition(pickupSFX, transform.position); } Destroy(gameObject); }
//we are hit public void Hit(DamageObject d) { //check if we can get hit again if (Time.time < LastHitTime + hitThreshold) { return; } //check if we are in a hittable state if (HitableStates.Contains(playerState.currentState)) { CancelInvoke(); //camera Shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.1f); } //defend incoming attack if (playerState.currentState == UNITSTATE.DEFEND && !d.DefenceOverride && (isFacingTarget(d.inflictor) || blockAttacksFromBehind)) { Defend(d); return; } else { animator.SetAnimatorBool("Defend", false); } //we are hit UpdateHitCounter(); LastHitTime = Time.time; //show hit effect animator.ShowHitEffect(); //substract health HealthSystemP2 hs = GetComponent <HealthSystemP2> (); //Lethal Forces - changed to use P2 Health System Script if (hs != null) { hs.SubstractHealth(d.damage); if (hs.CurrentHp == 0) { return; } } //check for knockdown if ((hitKnockDownCount >= knockdownHitCount || !IsGrounded() || d.knockDown) && playerState.currentState != UNITSTATE.KNOCKDOWN) { hitKnockDownCount = 0; StopCoroutine("KnockDownSequence"); StartCoroutine("KnockDownSequence", d.inflictor); GlobalAudioPlayer.PlaySFXAtPosition(d.hitSFX, transform.position + Vector3.up); GlobalAudioPlayer.PlaySFXAtPosition(knockdownVoiceSFX, transform.position + Vector3.up); return; } //default hit int i = Random.Range(1, 3); animator.SetAnimatorTrigger("Hit" + i); SetVelocity(Vector3.zero); playerState.SetState(UNITSTATE.HIT); //add a small force from the impact if (isFacingTarget(d.inflictor)) { animator.AddForce(-1.5f); } else { animator.AddForce(1.5f); } //SFX GlobalAudioPlayer.PlaySFXAtPosition(d.hitSFX, transform.position + Vector3.up); GlobalAudioPlayer.PlaySFXAtPosition(hitVoiceSFX, transform.position + Vector3.up); Invoke("Ready", hitRecoveryTime); } }