Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        EnemyDamagable damagable = InteractiveHelpers.GetEnemy(collision);

        if (damagable)
        {
            damagable.TakeDamageFrom(boxCollider, controller);
            if (damagable.HasRecoilAfterDamage())
            {
                controller.di.stateMachine.SetRecoilState(damagable.GetRecoilAfterDamage());
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        bool isFalling = physics.velocity.Y < 0;

        if (isFalling)
        {
            EnemyDamagable damagable = InteractiveHelpers.GetEnemy(collision);
            if (damagable)
            {
                damagable.TakeDamageFrom(boxCollider, controller);
                if (damagable.HasRecoilAfterDamage())
                {
                    controller.di.stateMachine.SetRecoilState(damagable.GetRecoilAfterDamage());
                }
                else
                {
                    Vector2 playerRecoil = RecoilHelpers.GetRecoilFromTo(controller.transform, controller.transform, tileRecoilOnHit);
                    Debug.Log(playerRecoil);
                    physics.velocity.Value = playerRecoil;
                    //controller.StateMachine.SetRecoilState(playerRecoil);
                }
            }
        }
    }