private void HitEnemy(EnemyHealth enemyHealth, Vector3 hitPoint) { if (!enemyHealth.AlreadyHit && !enemyHealth.IsDead) { DashingFeature enemyDashing = enemyHealth.GetComponent <DashingFeature>(); if (enemyDashing != null && enemyDashing.isActiveAndEnabled && enemyDashing.Dashing) { return; } enemyHealth.AlreadyHit = true; hitEnemies.Add(enemyHealth); EnemyControlManager enemyControl = enemyHealth.GetComponentInParent <EnemyControlManager>(); enemyControl.GetHit(); BlockingFeature enemyBlocking = enemyHealth.GetComponentInChildren <BlockingFeature>(); if (enemyBlocking != null && enemyBlocking.isActiveAndEnabled && enemyBlocking.Blocking) { Disable(); enemyBlocking.BlockHit(isPlayer, enemyBlocking.CharacterTransform.position - transform.position); GetComponentInParent <PlayerControlManager>().KnockBack(transform.position - enemyHealth.transform.position, isShort: true); anim.SetTrigger("recoil"); return; } enemyControl.KnockBack(enemyHealth.transform.position - transform.position, isShort: false); enemyHealth.TakeDamage(damage, hitPoint); //Debug.Log("Enemy hit"); } }
private void HitPlayer() { if (!playerHealth.AlreadyHit && !playerHealth.IsDead) { if (playerDashing != null && playerDashing.isActiveAndEnabled && playerDashing.Dashing) { return; } playerHealth.AlreadyHit = true; PlayerControlManager playerControl = playerHealth.GetComponentInParent <PlayerControlManager>(); playerControl.GetHit(); if (playerBlocking != null && playerBlocking.isActiveAndEnabled && playerBlocking.Blocking) { Disable(); anim.SetTrigger("recoil"); GetComponentInParent <EnemyControlManager>().KnockBack(transform.position - playerHealth.transform.position, isShort: true); playerBlocking.BlockHit(isPlayer, playerBlocking.CharacterTransform.position - transform.position); return; } playerControl.KnockBack(playerHealth.transform.position - transform.position, isShort: false); playerHealth.TakeDamage(damage); GetComponentInParent <FitnessTracker>().DamagedPlayer(damage); inflictedDamage = true; //Debug.Log("Player hit"); } }
private void OnCollisionEnter(Collision collision) { if (collision.collider.tag == "Environment") { Sizzle(); return; } if (ByPlayer) { //if (collision.collider.tag == "Projectile" && // !collision.collider.GetComponent<ProjectileBehaviour>().ByPlayer) //{ // outerBehaviour.Clear(); // Explode(collision); // return; //} EnemyHealth enemyHealth = collision.collider.GetComponent <EnemyHealth>(); if (collision.collider.tag == "Enemy" && !enemyHealth.IsDead) { outerBehaviour.Clear(); Explode(collision); DashingFeature enemyDashing = collision.collider.GetComponent <DashingFeature>(); if (enemyDashing != null && enemyDashing.isActiveAndEnabled && enemyDashing.Dashing) { return; } enemyHealth.GetComponentInParent <EnemyControlManager>().GetHit(); BlockingFeature enemyBlocking = collision.collider.GetComponentInChildren <BlockingFeature>(); if (enemyBlocking != null && enemyBlocking.isActiveAndEnabled && enemyBlocking.Blocking) { Sizzle(); enemyBlocking.BlockHit(ByPlayer, transform.forward, reflect: true); return; } enemyHealth.GetComponentInParent <EnemyControlManager>().KnockBack(enemyHealth.transform.position - transform.position, isShort: false); enemyHealth.TakeDamage(damage, enemyHealth.transform.position); //Debug.Log("Enemy hit"); } } else { //if (collision.collider.tag == "Projectile" && // collision.collider.GetComponent<ProjectileBehaviour>().ByPlayer) //{ // Explode(collision); // return; //} if (collision.collider.tag == "Enemy") { Sizzle(); } else if (collision.collider.tag == "Player" && !playerHealth.IsDead) { if (playerDashing != null && playerDashing.isActiveAndEnabled && playerDashing.Dashing) { Sizzle(); return; } playerHealth.GetComponentInParent <PlayerControlManager>().GetHit(); if (playerBlocking != null && playerBlocking.isActiveAndEnabled && playerBlocking.Blocking) { Sizzle(); playerBlocking.BlockHit(ByPlayer, transform.forward, reflect: true); return; } Explode(collision); playerHealth.GetComponentInParent <PlayerControlManager>().KnockBack(playerHealth.transform.position - transform.position, isShort: false); playerHealth.TakeDamage(damage); user.GetComponentInParent <FitnessTracker>().DamagedPlayer(damage); inflictedDamage = true; //Debug.Log("Player hit"); } else if (collision.collider.tag == "OuterCharacter") { outerHit = true; } } }