public Integer invoke(Integer arg1, Integer arg2) {
return arg1 + velY.getValue();
}
});
Signal s1 = ennemy.getOutLeft().merge(ennemy.getOutRight(), new Function2<Boolean, Boolean, Boolean>() {
@Override
public Boolean invoke(Boolean arg1, Boolean arg2) {
return arg1 || arg2;
}
}).subscribe(new Procedure1<Boolean>() {
@Override
public void invoke(Boolean arg1) {
if (arg1) {
velX.setValue(-velX.getValue());
}
}
});
Signal s2 = ennemy.getOutTop().merge(ennemy.getOutBottom(), new Function2<Boolean, Boolean, Boolean>() {
@Override
public Boolean invoke(Boolean arg1, Boolean arg2) {
return arg1 || arg2;
}
}).subscribe(new Procedure1<Boolean>() {
@Override
public void invoke(Boolean arg1) {
if (arg1) {
velY.setValue(-velY.getValue());
}
}
});
ennemy.getCollision().subscribe(new Procedure1<Shape>() {
@Override
public void invoke(Shape arg1) {
if (arg1.getType() == Shape.Type.PLAYER) {
game.addToScore(-250);
}
}
});
if (shoot) {
Signal shoot = TimeReact.every(500).subscribe(new Procedure1<Integer>() {
@Override
public void invoke(Integer arg1) {
addEnnemyShoot(x.getValue() + ennemy.getWidth() / 2, y.getValue() + ennemy.getHeight(), 25);
}