public void hurt(HitBox hitbox)
    {
        if (!hitbox)
        {
            return;
        }
        float kbStrength = (hitbox.knockback ? 2.5f : 1.5f) / weight;
        float dx         = hitbox.kbDir.x;
        float dy         = hitbox.kbDir.y;

        if (hitbox.explosive)
        {
            Vector2 dir = (transform.position - hitbox.position).normalized;
            dx = dir.x;
            dy = dir.y;
        }
        velocity.x = kbStrength * dx;
        velocity.y = kbStrength * 1.5f * dy;
        act        = Mathf.Max(actionCoolDown / 2.0f, act);
        anim.SetBool("Hurt", true);

        if (hitbox.incendiary)
        {
            Vector2 size = GetComponent <BoxCollider2D>().size / 2.0f;
            Vector3 rpos = new Vector3(Random.Range(-size.x, size.x), Random.Range(-size.y, size.y), 0);
            gameManager.createInstance("Effects/Fire/IncendiaryParticle", rpos + transform.position, transform);
        }

        deformer.flashWhite();

        StartCoroutine(getHurt());
    }
    IEnumerator Picked(bool playSound = true)
    {
        canPick = false;
        deformer.flashWhite(0.2f);
        if (playSound)
        {
            if (pickSound)
            {
                SoundManager.Instance.playClip(pickSound.name);
            }
            if (pickParticle)
            {
                Instantiate(pickParticle, center, Quaternion.identity);
            }
        }

        yield return(new WaitForSeconds(0.1f));

        anim.SetTrigger("Picked");
        yield return(new WaitForSeconds(regrowTime));

        anim.SetTrigger("Regrow");
        yield return(new WaitForSeconds(0.5f));

        if (regrowSound)
        {
            SoundManager.Instance.playClip(regrowSound.name, -2, transform.position);
        }
        canPick = true;
        yield return(0);
    }
    IEnumerator doHitLag(float duration)
    {
        Vector3 oldVelocity = velocity;

        velocity = Vector3.zero;
        State oldState = state;

        state = State.Wait;
        deformer.flashWhite();
        yield return(new WaitForSeconds(duration));

        state    = oldState;
        velocity = oldVelocity;
    }
    public void Hurt(HitBox hitbox)
    {
        if (!hitbox)
        {
            return;
        }
        float kbStrength = (hitbox.knockback ? 2.5f : 1.5f);
        float dx         = hitbox.kbDir.x;
        float dy         = hitbox.kbDir.y;

        velocity.x = kbStrength * dx;
        velocity.y = kbStrength * 1.5f * dy;

        anim.SetTrigger("Hurt");
        deformer.flashWhite(0.2f);
    }
    public void takeDamage(float amount, HitBox hitbox = null, bool byPlayer = false)
    {
        if (!takeNoDamage)
        {
            hitpoints -= amount;
        }
        timeSinceHit = 0;

        if (flashWhiteOnHit)
        {
            if (deformer != null)
            {
                deformer.flashWhite();
            }
            //if (byPlayer) gameManager.Instance.playerCtrl.hitLag(0);
        }

        //Remember to set the hurtCallback as Dynamic and not Static
        //or it will user the Inspector HitBox (which shouldn't exist)
        if (receivesHitStun)
        {
            hitStun(hitStunDuration);
        }
        if (hurtCallback != null)
        {
            hurtCallback.Invoke(hitbox);
        }
        if (hitbox && hitbox.incendiary)
        {
            Vector3 rpos = new Vector3(Random.Range(-.25f, .25f), Random.Range(-.25f, .25f), 0);
            gameManager.createInstance("Effects/Fire/IncendiaryParticle", rpos + transform.position, transform);
        }
        if (hurtSound)
        {
            SoundManager.Instance.playClip(hurtSound.name);
        }

        if (!dead)
        {
            checkDead();
        }
    }