public void OnTriggerEnter(Collider collider) { Player player = collider.gameObject.GetComponent <Player>(); if (player != null) { if (player.playerState.isLegendary) { enemyHealth.TakeDamage(player.GetCurrentDamage()); //StartCoroutine(FlashDamage(0.33f)); chainKillParticlePooler.SpawnFromQueueAndPlay(null, transform.position, Vector3.zero); } else { StartCoroutine(DelayedDamage(collider, player)); } } else { EnemyDestroysRunestone edr = collider.gameObject.GetComponent <EnemyDestroysRunestone>(); if (edr != null) { edr.WinOrLoose(false); } else { return; } } }
public void PlayerDestroysShield() { //shieldAnimator.SetTrigger("shieldDestroyed"); playerDestroyShieldPooler.SpawnFromQueueAndPlay(null, transform.position, transform.forward); audioShieldDestroyed.PlayOneShot(enemyAudioSource); DestroyShieldObject(); }
public IEnumerator DashInDirection(Vector3 target) { playerAnimator.SetBool("isDashing", true); player.playerState.canDash = false; player.playerState.isDashing = true; transform.LookAt(target); Vector3 direction; //if the chainkill script events are in effect, the dash is no longer clamped to a maximum range if (!player.playerState.isLegendary) { direction = (transform.position + (target - transform.position).normalized * dashRadius) * 1.01f; } else { direction = transform.position + (target - transform.position); } //this is a precaution against certain rare flukes in which the player character learned to fly... direction.y = 0; audioPlayerKickoff.PlayOneShot(playerAudioSource); audioPlayerDash.PlayOneShot(playerAudioSource); playerDashKickoffPooled.SpawnFromQueueAndPlay(null, transform.position, direction); naginataControl.StartBladeTrail(); //move towards the current dash target as long as it has not been reached //and no enemy shield has been hit while (Vector3.Distance(transform.position, direction) > 0.05f && !player.playerState.hitEnemyShield) { transform.position = Vector3.MoveTowards(transform.position, direction, Time.deltaTime * dashSpeed); yield return(null); } if (player.playerState.hitEnemyShield) { //if an enemy shield has been hit, everything related to dashing is stopped //because the PlayerShovedBack method and ShovedBack coroutine take over yield break; } yield return(new WaitForSeconds(0.15f)); player.playerState.canDash = true; if (targetStash.Count > 0) { targetStashEmpty = false; yield break; } else { targetStashEmpty = true; } yield return(new WaitForSeconds(0.6f)); EndDashChain(); }
public void OnCollisionEnter(Collision col) { Player player = col.gameObject.GetComponent <Player>(); if (player != null) { if (isDestructible) { PlayerDestroysShield(); return; } if (!player.playerState.isDashing) { enemyHealth.TriggerIFrames(0.2f); ShieldBash(player); return; } enemyForward = durabilityBarPosition.forward.normalized; playerForward = player.transform.forward.normalized; playerForward.y = enemyForward.y; //determine the direction the player has hit the shield from via dot product float dot = Vector3.Dot(enemyForward, playerForward); //if we've made it this far, the player is dashing ... get it? if (dot > 0.4f) { //shield hit from behind PlayerDestroysShield(); } else { //shield hit from the front if (!DurabilityHit()) { //at this point the shield has been hit from the front and is still intact enough to bash the player enemyHealth.TriggerIFrames(0.2f); playerHitShieldPooler.SpawnFromQueueAndPlay(transform, col.contacts[0].point, player.transform.position); ShieldBash(player); } } } }