예제 #1
0
    public IEnumerator DelayedDamage(object[] args)
    {
        float delayTime = (float)args[0];

        yield return(new WaitForSeconds(delayTime)); // lmao this will be fine

        Player       player         = (Player)args[1];
        MeleeHandler m_meleeHandler = (MeleeHandler)args[2];

        float distanceFromPlayer = (player.transform.position - transform.position).magnitude;

        if (distanceFromPlayer - m_meleeHandler.GetAttackRange() <= 0f) // Check if in range BEFORE appling damage
        {
            player.m_healthHandler.Damage(m_meleeHandler.GetMeleeDamage());
            StartCoroutine(player.m_audioHandler.PlayDamageSound());
            StartCoroutine(player.m_healthHandler.ApplyDamageEffect(player.GetComponent <SpriteRenderer>()));
            player.m_movementHandler.Knockback(1000f, (player.transform.position - transform.position), player.GetComponent <Rigidbody2D>());
        }
    }
예제 #2
0
 //So we can see the Attack Range - Can be deleted later
 private void OnDrawGizmos()
 {
     Gizmos.color = Color.blue;
     // If the application is playing, THEN draw the damn cube. NullReferenceException THIS you stingy twat
     if (Application.isPlaying)
     {
         Gizmos.DrawWireCube((Vector2)m_charController2D.GetBoxCollider2D().bounds.center +
                             (m_charDirection == char_direction.RIGHT ? m_meleeHandler.GetHitboxOffset() : -m_meleeHandler.GetHitboxOffset()),
                             (Vector2)m_charController2D.GetBoxCollider2D().bounds.size + new Vector2(m_meleeHandler.GetAttackRange(), 0));
     }
 }