Skip to content

Commit

Permalink
Merge branch 'dev-map'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lost-Fly committed May 25, 2024
2 parents a213249 + 9921377 commit e362e2c
Show file tree
Hide file tree
Showing 54 changed files with 1,377 additions and 1,200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.util.Properties;

public class AndroidLauncher extends AndroidApplication {
private MessageProcessor messageProcessor;
private static final int MAX_RECONNECT_ATTEMPTS = 5;
private MessageProcessor messageProcessor;

public void connectSocket(WebSocketClient webSocketClient) {
int reconnectAttempts = 0;
Expand Down Expand Up @@ -80,7 +80,6 @@ private WebSocketListener getWebsocketListener(EventListenerCallback callback) {
WebSocketListener webSocketListener = new WebSocketListener() {
@Override
public void onMessageReceived(String message) {
// Gdx.app.log("MESSAGE RECEIVED", "MESSAGE: " + message);
WsEvent wsEvent = new WsEvent();
wsEvent.setData(message);
callback.onEvent(wsEvent);
Expand All @@ -104,7 +103,6 @@ public void onClose(int code, String reason) {

@Override
public void onError(Exception ex) {
// Gdx.app.error("CONNECTION ERROR", "ERROR_MESSAGE: " + ex.getMessage());
WsEvent wsEvent = new WsEvent();
wsEvent.setData("ERROR_OCCURRED");
callback.onEvent(wsEvent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.aqwsxlostfly.packandgo.client;

import static com.aqwsxlostfly.packandgo.Main.gameSession;

import com.aqwsxlostfly.packandgo.Main;
import com.aqwsxlostfly.packandgo.client.ws.WsEvent;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;

public class MessageProcessor {
private final Main main;

public static final String PLAYER_INTERACTION = "playerInteraction";
public static final String PLAYER_STATE = "player";
public static final String FURNITURE_STATE = "furniture";
private static final String SESSION_KEY = "sessionKey";
private static final String SESSION_ROOM = "sessionRoom";
private static final String SESSION_MAP = "sessionMap";
private static final String EVICT_MESSAGE = "evict";
private final Main main;

public MessageProcessor(Main main) {
this.main = main;
Expand Down Expand Up @@ -86,12 +88,16 @@ private void processObject(JsonValue object) {
String sessionId = object.getString("id");
String sessionPassword = object.getString("password");
String sessionMsg = object.getString("msg");
String sessionSize = object.getString("size");
String sessionMap = object.getString("map");
Gdx.app.log("SESSION STATE", "MSG " + sessionMsg);
try {
main.gameSession.setConnected(true);
main.gameSession.setId(sessionId);
main.gameSession.setPassword(sessionPassword);
main.gameSession.setSessionMsg(sessionMsg);
gameSession.setConnected(true);
gameSession.setId(sessionId);
gameSession.setPassword(sessionPassword);
gameSession.setSessionMsg(sessionMsg);
gameSession.setSize(Integer.parseInt(sessionSize));
gameSession.setSessionMap(sessionMap);
} catch (Exception e) {
// TODO
}
Expand All @@ -110,7 +116,7 @@ private void processObject(JsonValue object) {
float x = object.getFloat("x");
float y = object.getFloat("y");
boolean isHolding = object.getBoolean("isHolding");
// Gdx.app.log("UPD PLAYER FROM SERV", "ID " + id + " isHOLDING " + isHolding);

try {
Gdx.app.postRunnable(
new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ public InputStateImpl() {

}

@Override
public String getType() {
return this.type;
}

@Override
public void setType(String type) {
this.type = type;
}

@Override
public String getType() {
return this.type;
public String getId() {
return this.id;
}

@Override
Expand All @@ -35,19 +39,18 @@ public void setId(String id) {
}

@Override
public String getId() {
return this.id;
public float getX() {
return this.x;
}


@Override
public void setX(float x) {
this.x = x;
}

@Override
public float getX() {
return this.x;
public float getY() {
return this.y;
}

@Override
Expand All @@ -56,8 +59,8 @@ public void setY(float y) {
}

@Override
public float getY() {
return this.y;
public boolean isHolding() {
return this.holding;
}

@Override
Expand All @@ -66,18 +69,13 @@ public void setHolding(boolean isHolding) {
}

@Override
public boolean isHolding() {
return this.holding;
public int getHolders() {
return this.holders;
}

@Override
public void setHolders(int holdersCount) {
this.holders = holdersCount;
}

@Override
public int getHolders() {
return this.holders;
}

}
Binary file removed assets/badlogic.jpg
Binary file not shown.
File renamed without changes.
Binary file added assets/doc2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/doc2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="doc2" tilewidth="15" tileheight="16" tilecount="1" columns="1">
<image source="doc2.png" width="15" height="16"/>
</tileset>
Loading

0 comments on commit e362e2c

Please sign in to comment.