use of client.Client in project powerbot by powerbot.
the class Game method tileToMap.
/**
* Converts the 3-dimensional tile to a 2-dimensional point on the mini-map component.
*
* @param tile The tile to convert
* @return The point on screen of where the tile would be.
*/
public Point tileToMap(final Tile tile) {
final Client client = ctx.client();
if (client == null) {
return new Point(-1, -1);
}
final int rel = ctx.players.local().relative();
final int angle = client.getMinimapAngle() & 0x7ff;
final int[] d = { tile.x(), tile.y(), ARRAY_SIN[angle], ARRAY_COS[angle], -1, -1 };
d[0] = (d[0] - client.getOffsetX()) * 4 + 2 - (rel >> 16) / 32;
d[1] = (d[1] - client.getOffsetY()) * 4 + 2 - (rel & 0xffff) / 32;
d[4] = d[1] * d[2] + d[3] * d[0] >> 16;
d[5] = d[2] * d[0] - d[1] * d[3] >> 16;
final Point centre = mapComponent().centerPoint();
return new Point(centre.x + d[4], centre.y + d[5]);
}
use of client.Client in project powerbot by powerbot.
the class Game method worldToScreen.
/**
* Converts a 3-dimensional point within the overworld to a 2-dimensional point on the
* screen. The 3-dimensional axis is flipped to represent the X axis being horizontal,
* Y axis being vertical, and Z axis to be depth.
*
* @param relativeX The x-axis value relative to the origin
* @param relativeY The y-axis value relative to the origin
* @param relativeZ The z-axis value relative to the origin
* @param h The y-axis value, otherwise known as height
* @return The 2-dimensional point on screen.
*/
public Point worldToScreen(final int relativeX, final int relativeY, final int relativeZ, final int h) {
final Client client = ctx.client();
final Point r = new Point(-1, -1);
if (relativeX < 128 || relativeX > 13056 || relativeZ < 128 || relativeZ > 13056) {
return r;
}
final int floor = client.getFloor();
if (floor < 0) {
return r;
}
final int height = relativeY - h;
final int projectedX = relativeX - client.getCameraX(), projectedZ = relativeZ - client.getCameraZ(), projectedY = height - client.getCameraY();
final int pitch = client.getCameraPitch(), yaw = client.getCameraYaw();
final int[] c = { ARRAY_SIN[yaw], ARRAY_COS[yaw], ARRAY_SIN[pitch], ARRAY_COS[pitch] };
final int rotatedX = c[0] * projectedZ + c[1] * projectedX >> 16;
final int rotatedZ = c[1] * projectedZ - c[0] * projectedX >> 16;
final int rolledY = c[3] * projectedY - c[2] * rotatedZ >> 16;
final int rolledZ = c[3] * rotatedZ + c[2] * projectedY >> 16;
if (rolledZ >= 50) {
int mx = 256, my = 167;
if (ctx.widgets.widget(Constants.VIEWPORT_WIDGET >> 16).component(Constants.VIEWPORT_WIDGET & 0xffff).screenPoint().x != 4) {
final Dimension d = dimensions();
mx = d.width / 2;
my = d.height / 2;
}
final int proj = client.getTileSize();
return new Point((rotatedX * proj) / rolledZ + mx, (rolledY * proj) / rolledZ + my);
}
return r;
}
use of client.Client in project hpcourse by cscenter.
the class SimpleTests method subscribeTask.
public void subscribeTask() {
new Thread(new Runnable() {
@Override
public void run() {
Client client = new Client("localhost", 1500);
client.subscribe(5);
}
}).start();
}
use of client.Client in project hpcourse by cscenter.
the class Main method main.
public static void main(String[] args) {
int serverPort = 4242;
try {
new Server(serverPort);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
try {
Client client1 = new Client("localhost", serverPort, "#1");
client1.sendSubmitTaskRequest(42, 20, 30, 0, 0);
client1.sendSubscribeRequest(1);
client1.sendSubscribeRequest(2);
client1.sendSubscribeRequest(1);
Client client2 = new Client("localhost", serverPort, "#2");
client2.sendSubmitTaskRequest(10, 20, 40, 1, 1000000000);
client2.sendSubscribeRequest(2);
client2.sendSubscribeRequest(1);
client2.sendSubscribeRequest(2);
} catch (IOException e) {
e.printStackTrace();
System.exit(2);
}
}
use of client.Client in project ORCID-Source by ORCID.
the class JpaJaxbClientAdapterTest method getClient.
private Client getClient() {
Client client = new Client();
client.setAllowAutoDeprecate(true);
client.setPersistentTokensEnabled(true);
client.setClientType(ClientType.CREATOR);
client.setDescription("description");
client.setGroupProfileId("group-profile-id");
client.setId("id");
client.setName("client-name");
client.setWebsite("client-website");
client.setAuthenticationProviderId("authentication-provider-id");
Set<ClientRedirectUri> clientRedirectUris = new HashSet<ClientRedirectUri>();
ClientRedirectUri rUri1 = new ClientRedirectUri();
Set<ScopePathType> scopes1 = new HashSet<ScopePathType>();
scopes1.add(ScopePathType.ACTIVITIES_READ_LIMITED);
rUri1.setPredefinedClientScopes(scopes1);
rUri1.setRedirectUri("redirect-uri-1");
rUri1.setRedirectUriType("type-1");
rUri1.setUriActType("uri-act-type-1");
rUri1.setUriGeoArea("uri-geo-area-1");
ClientRedirectUri rUri2 = new ClientRedirectUri();
Set<ScopePathType> scopes2 = new HashSet<ScopePathType>();
scopes2.add(ScopePathType.ACTIVITIES_UPDATE);
rUri2.setPredefinedClientScopes(scopes2);
rUri2.setRedirectUri("redirect-uri-2");
rUri2.setRedirectUriType("type-2");
rUri2.setUriActType("uri-act-type-2");
rUri2.setUriGeoArea("uri-geo-area-2");
ClientRedirectUri rUri3 = new ClientRedirectUri();
Set<ScopePathType> scopes3 = new HashSet<ScopePathType>();
scopes3.add(ScopePathType.AFFILIATIONS_CREATE);
rUri3.setPredefinedClientScopes(scopes3);
rUri3.setRedirectUri("redirect-uri-3");
rUri3.setRedirectUriType("type-3");
rUri3.setUriActType("uri-act-type-3");
rUri3.setUriGeoArea("uri-geo-area-3");
clientRedirectUris.add(rUri1);
clientRedirectUris.add(rUri2);
clientRedirectUris.add(rUri3);
client.setClientRedirectUris(clientRedirectUris);
return client;
}
Aggregations