Commit 0884f194 authored by Toussaint Etienne's avatar Toussaint Etienne

Merge branch 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project

* 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project:
  now it should colour in red when a character is hit
  Some minor modifications...
parents a1e0de30 354d0049
......@@ -48,20 +48,26 @@ public class EntityDisplayer implements Serializable {
Animation animation;
if (associatedEntity.hasAction(Action.ATTACK)) {
animation = animationMapTab[dir].get(Action.ATTACK);
if (associatedEntity.hasAction(Action.HIT))
if (associatedEntity.hasAction(Action.HIT)) {
animation.setHIT(true);
associatedEntity.removeAction(Action.HIT);
}
associatedEntity.removeAction(Action.ATTACK);
}
else if (associatedEntity.hasAction(Action.WALK)) {
animation = animationMapTab[dir].get(Action.WALK);
if (associatedEntity.hasAction(Action.HIT))
if (associatedEntity.hasAction(Action.HIT)) {
animation.setHIT(true);
associatedEntity.removeAction(Action.HIT);
}
associatedEntity.removeAction(Action.WALK);
}
else {
animation = animationMapTab[dir].get(Action.NONE);
if (associatedEntity.hasAction(Action.HIT))
if (associatedEntity.hasAction(Action.HIT)) {
animation.setHIT(true);
associatedEntity.removeAction(Action.HIT);
}
}
Sprite sprite = new Sprite(animation.getSpriteImage());
GraphicsMapPoint entityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(associatedEntity.getX(), associatedEntity.getY());
......
......@@ -57,7 +57,7 @@ public class ServerAddressPanel extends MenuPanel{
private ActionListener serverButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
RPCServer.main();
RPCServer.startServer();
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.SERVER_CREATED_PANEL);
}
};
......
......@@ -93,9 +93,9 @@ public class Animation implements Serializable, Displayable
for (int xx = 0; xx < width; xx++) {
for (int yy = 0; yy < height; yy++) {
int[] pixels = raster.getPixel(xx, yy, (int[]) null);
pixels[0] = 0;
pixels[0] = 255;
pixels[1] = 0;
pixels[2] = 255;
pixels[2] = 0;
raster.setPixel(xx, yy, pixels);
}
}
......
......@@ -8,7 +8,7 @@ import network.outershell.Lounge;
/**
* Created by bogdanbear on 20/11/2015.
*/
public class LoungeServer {
public class LoungeServer extends Thread {
private Lounge lounge;
private int numberOfPlayers;
public LoungeServer(Lounge lounge, int numberOfPlayers)
......@@ -16,12 +16,27 @@ public class LoungeServer {
this.lounge=lounge;
this.numberOfPlayers=numberOfPlayers;
}
public void initiateServer()
@Override
public void run()
{
ServerConnection serverConnection=new ServerConnection(lounge.getPort(),0, true,lounge.MAX_PLAYERS);
Logging.getInstance().getLogger().info("Server started second phase, initialization done");
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
dummyServerLoop.start();
notifyOnIt();
}
public synchronized void notifyOnIt()
{
notify();
}
public synchronized void waitOnIt()
{
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
......@@ -14,7 +14,7 @@ import java.util.logging.Logger;
public class RPCServer {
public static int scale=25;
private static Logger LOGGER = Logging.getInstance().getLogger();
public static void main()
public static void startServer()
{
try {
LocateRegistry.createRegistry(1099);
......@@ -24,5 +24,9 @@ public class RPCServer {
LOGGER.warning("RPCServer: Server failed: " + e);
}
}
public static void main(String[] arguments)
{
startServer();
}
}
......@@ -67,7 +67,8 @@ public class Registrar extends UnicastRemoteObject implements RegisterInterface
waiting.put(genID, lounge);
//instantiate a loungeServer on the serverside and then put it into motion
LoungeServer loungeServer=new LoungeServer(lounge,lounge.MAX_PLAYERS);
loungeServer.initiateServer();
loungeServer.start();
loungeServer.waitOnIt();
//after obtaining the genID the host will immediately launch joinGame
return lounge;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment