void EnemyEntity::SetHurt(Vector2 pos)
{
    AnimatedSprite2D* animatesprite = GetComponent<AnimatedSprite2D>();
    if(animatesprite->GetAnimation()!= "hurt")
    {
        animatesprite->SetAnimation("hurt", LM_FORCE_CLAMPED);
        isBusy = true;
        CurrentTime = 0;
        life-=2;
        if(life >= 0)
        {
            timeBusy = 0.26f;
            RigidBody2D* body = GetComponent<RigidBody2D>();
            if(pos.x_>node_->GetPosition2D().x_)
                body->ApplyLinearImpulse(Vector2(-0.5f,0.5f),node_->GetPosition2D(),true );
            else
                body->ApplyLinearImpulse(Vector2(0.5f,0.5f),node_->GetPosition2D(),true );
        }
        else{
            isDead = true;
            animatesprite->SetAnimation("dead", LM_FORCE_CLAMPED);
            timeBusy = 2.0f;
            node_->RemoveComponent<RigidBody2D>();
        }

    }
}
void EnemyEntity::Shoot()
{
    ResourceCache* cache = GetSubsystem<ResourceCache>();

    Sprite2D* bulletSprite = cache->GetResource<Sprite2D>("Urho2D/bullet2.png");
    if (!bulletSprite)
        return;

	SharedPtr<Node> bulletNode_(GetScene()->CreateChild("e_bullet"));
	bulletNode_->SetPosition2D(node_->GetPosition2D());
	//bulletNode_->SetDirection(Vector3(dir.x_,-dir.y_,0));
	StaticSprite2D* staticSprite = bulletNode_->CreateComponent<StaticSprite2D>();
	staticSprite->SetSprite(bulletSprite);
	staticSprite->SetLayer(6 * 10);

	RigidBody2D* bulletBody = bulletNode_->CreateComponent<RigidBody2D>();
    bulletBody->SetBodyType(BT_DYNAMIC);
    bulletBody->SetFixedRotation(true);
    bulletBody->SetBullet(true);

    CollisionCircle2D* circleshape = bulletNode_->CreateComponent<CollisionCircle2D>();
    circleshape->SetRadius(0.08f);
    circleshape->SetDensity(1.0f);
    circleshape->SetFriction(0.0f);
    circleshape->SetRestitution(0.0f);
    circleshape->SetMaskBits(57340);
    circleshape->SetCategoryBits(2);

	bulletNode_->CreateComponent<BulletEntity>();

	Node* nodebullet2 = bulletNode_->Clone();
	Node* nodebullet3 = bulletNode_->Clone();
	Node* nodebullet4 = bulletNode_->Clone();

    nodebullet2->GetComponent<RigidBody2D>()->ApplyLinearImpulse(Vector2(0.030f,0.13f),node_->GetPosition2D(),true );
    nodebullet3->GetComponent<RigidBody2D>()->ApplyLinearImpulse(Vector2(-0.02f,0.13f),node_->GetPosition2D(),true );
    nodebullet4->GetComponent<RigidBody2D>()->ApplyLinearImpulse(Vector2(-0.030f,0.13f),node_->GetPosition2D(),true );
	bulletBody->ApplyLinearImpulse(Vector2(0.02f,0.13f),node_->GetPosition2D(),true );
}