Beispiel #1
0
    private void Hurt(Enemy enemy)
    {
        DevMonsterInfo monsterInfo = Content.Instance.GetMonsterByName(enemy.Info.Name);

        if (!Invincible && monsterInfo.DMG != 0)
        {
            // EndAttack();

            SocketClient.Instance.SendTookDMG(enemy.Info);

            Instance.Hurt();

            Instance.PlayEyesEmote("angry");
            Instance.PlayMouthEmote("sad");

            StartCoroutine(DisableSpeedUntilGrounded());

            DevPerkMap knockbackPerk = monsterInfo.GetPerk("knockbackModifier");
            float      Modifier      = (knockbackPerk != null) ? knockbackPerk.Value : 1f;

            if (enemy.transform.position.x < transform.position.x)
            {
                Rigid.AddForce(2.5f * Modifier * transform.right, ForceMode2D.Impulse);
            }
            else
            {
                Rigid.AddForce(2.5f * Modifier * -transform.right, ForceMode2D.Impulse);
            }
        }
    }