Commit 2e4aff74 authored by bogdanbear's avatar bogdanbear

Renamed DummyLocalGameLoop

parent 00834334
......@@ -2,15 +2,12 @@ package core.abilities.effects;
import core.event.AbilityEvent;
import core.event.Event;
import core.event.MoveEvent;
import core.gamestate.*;
import core.gamestate.Character;
import core.relayer.Relayer;
import core.relayer.RelayerEntity;
import core.zone.Direction;
import core.zone.Translation;
import core.zone.Zone;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import java.io.Serializable;
import java.util.ArrayList;
......@@ -103,8 +100,8 @@ public class EffectBuilder implements Serializable{
gameContent.addTriggerToCheck(entity);
RelayerEntity relayer = new RelayerEntity(entity.getID(),entity,gameContent);
entity.setRelayer(relayer);
if(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection() != Direction.NONE) {
relayer.move(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection());
if(LocalGameLoop.getInstance().getFollowedRelayer().getDirection() != Direction.NONE) {
relayer.move(LocalGameLoop.getInstance().getFollowedRelayer().getDirection());
}
else{
relayer.move(charac.getDirection());
......@@ -140,8 +137,8 @@ public class EffectBuilder implements Serializable{
gameContent.addTriggerToCheck(entity);
RelayerEntity relayer = new RelayerEntity(entity.getID(),entity,gameContent);
entity.setRelayer(relayer);
if(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection() != Direction.NONE) {
relayer.move(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection());
if(LocalGameLoop.getInstance().getFollowedRelayer().getDirection() != Direction.NONE) {
relayer.move(LocalGameLoop.getInstance().getFollowedRelayer().getDirection());
}
else{
relayer.move(charac.getDirection());
......@@ -177,8 +174,8 @@ public class EffectBuilder implements Serializable{
gameContent.addTriggerToCheck(entity);
RelayerEntity relayer = new RelayerEntity(entity.getID(),entity,gameContent);
entity.setRelayer(relayer);
if(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection() != Direction.NONE) {
relayer.move(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection());
if(LocalGameLoop.getInstance().getFollowedRelayer().getDirection() != Direction.NONE) {
relayer.move(LocalGameLoop.getInstance().getFollowedRelayer().getDirection());
}
else{
relayer.move(charac.getDirection());
......@@ -232,7 +229,7 @@ public class EffectBuilder implements Serializable{
}
if(hit){
Event event = new AbilityEvent(casterCharacterID, 0);
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
}
}
};
......@@ -283,7 +280,7 @@ public class EffectBuilder implements Serializable{
}
if(hit){
Event event = new AbilityEvent(casterCharacterID, 0);
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
}
}
};
......
......@@ -4,7 +4,7 @@ import java.io.Serializable;
import core.gamestate.Entity;
import core.gamestate.GameContent;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
/**
* Created by dupriez on 22/11/15.
......@@ -32,7 +32,7 @@ public class MapInit implements ClientEvent, Serializable {
@Override
public boolean execute(GameContent gameContent) {
DummyLocalGameLoop.getInstance().setContent(this.gameContent);
LocalGameLoop.getInstance().setContent(this.gameContent);
return true;
}
......
......@@ -7,7 +7,7 @@ import core.gamestate.EntityNotFoundExeption;
import core.gamestate.GameContent;
import core.zone.Point;
import core.zone.Translation;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
/**
* This event is executed when an entity wants to move.
......@@ -37,7 +37,7 @@ public class MoveEvent implements ClientEvent,ServerEvent {
}
else if(target.getSpeciesName().equals("FrostBolt") || target.getSpeciesName().equals("FireBoltLP")){
Event event = new AbilityEvent(targetID, 0);
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
}
return true;
} catch (EntityNotFoundExeption entityNotFoundExeption) {
......
......@@ -2,9 +2,6 @@ package core.event;
import core.gamestate.*;
import core.gamestate.Character;
import core.relayer.RelayerEntity;
import core.zone.Direction;
import gameloop.DummyLocalGameLoop;
/**
* Created by hilaire on 06/01/16.
......
......@@ -6,16 +6,14 @@ import java.util.Objects;
import java.util.logging.Logger;
import core.abilities.Ability;
import core.abilities.effects.EffectBuilder;
import core.event.Event;
import core.event.SpawnGold;
import core.event.ToServerDeathEvent;
import core.zone.Zone;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayerType;
import logging.Logging;
import map_generation.tiles.TilePropertyVector;
import network.inner_shell.NetworkConnection;
/**
* This class represents an Entity able to be hit and die.
......@@ -149,19 +147,19 @@ public class Being extends Entity {
if (HP==0){
Event event = new ToServerDeathEvent(this.getID());
Logger LOGGER = Logging.getInstance().getLogger();
if (DummyLocalGameLoop.getInstance().networkConnectionIsNull()){
if (LocalGameLoop.getInstance().networkConnectionIsNull()){
LOGGER.severe("NetworkConnection null, Being"+this.getID()+" can't die");
} else {
LOGGER.info("Death of "+this.getID()+" is send");
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
}
Event event2 = new SpawnGold(this.getID());
if (DummyLocalGameLoop.getInstance().networkConnectionIsNull()){
if (LocalGameLoop.getInstance().networkConnectionIsNull()){
LOGGER.severe("NetworkConnection null, GOld"+this.getID()+" can't be created");
} else {
LOGGER.info("Gold creation by " + this.getID() + " is send");
DummyLocalGameLoop.getInstance().sendEvent(event2);
LocalGameLoop.getInstance().sendEvent(event2);
}
}
......
......@@ -8,7 +8,7 @@ import core.gamestate.Character;
import core.gamestate.Entity;
import core.zone.Direction;
import core.zone.Translation;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import gameloop.ServerLoop;
import java.util.Objects;
......@@ -74,7 +74,7 @@ public class Relayer extends Thread{
return;
}
Event event = new MoveEvent(character.getID(), Translation.construct(direction,character.getSpeed()));
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
}
private void stopMove(){
......@@ -95,7 +95,7 @@ public class Relayer extends Thread{
*/
private void applyAbility() {
Event event = new AbilityEvent(character.getID(), currentAbility);
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
hasTriedToCastAbility = false;
}
......
......@@ -7,7 +7,7 @@ import core.gamestate.Entity;
import core.gamestate.GameContent;
import core.zone.Direction;
import core.zone.Translation;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import gameloop.ServerLoop;
import java.util.Objects;
......@@ -40,7 +40,7 @@ public class RelayerEntity extends Thread{
return;
}
Event event = new MoveEvent(character.getID(), Translation.construct(direction,character.getSpeed()));
DummyLocalGameLoop.getInstance().sendEvent(event);
LocalGameLoop.getInstance().sendEvent(event);
}
private void stopMove(){
......
......@@ -30,31 +30,31 @@ public class GameStarter {
NetworkConnection[] localConnections= LocalConnection.createNew();
NetworkConnection serverConnection = localConnections[0];
NetworkConnection clientConnection = localConnections[1];
DummyLocalGameLoop.getInstance().setNetworkConnection(clientConnection);
LocalGameLoop.getInstance().setNetworkConnection(clientConnection);
//we are not allowing the LocalGameLoop to function here, commented the next line
//DummyLocalGameLoop.getInstance().startGame(GameType.SINGLEPLAYER);
//LocalGameLoop.getInstance().startGame(GameType.SINGLEPLAYER);
//but we start the thread nonetheless
if (!DummyLocalGameLoop.getInstance().startedBefore())
DummyLocalGameLoop.getInstance().start();
if (!LocalGameLoop.getInstance().startedBefore())
LocalGameLoop.getInstance().start();
//this is start and not run like in the DummyServer, because here we are dealing with a thread
ServerLoop dummyServerLoop=new ServerLoop(serverConnection);
dummyServerLoop.start();
//let the loop run now!
DummyLocalGameLoop.getInstance().startGame();
LocalGameLoop.getInstance().startGame();
}
static public void startGameMultiplayerPlayer(String ip, int port)
{
NetworkConnection networkConnection=new ClientConnection(ip,port);
DummyLocalGameLoop.getInstance().setNetworkConnection(networkConnection);
LocalGameLoop.getInstance().setNetworkConnection(networkConnection);
//Symmetric behavior, the same as with singlePlayerStartProcedure
if (!DummyLocalGameLoop.getInstance().startedBefore())
DummyLocalGameLoop.getInstance().start();
if (!LocalGameLoop.getInstance().startedBefore())
LocalGameLoop.getInstance().start();
//let the loop run now!
DummyLocalGameLoop.getInstance().startGame();
LocalGameLoop.getInstance().startGame();
}
......@@ -64,8 +64,8 @@ public class GameStarter {
Logging.getInstance().getLogger().info("Leaving the game");
AIControler.killAll();
Relayers.killAll();
DummyLocalGameLoop.getInstance().getNetworkConnection().initiateConnectionEnd();
DummyLocalGameLoop.getInstance().pauseGame();
LocalGameLoop.getInstance().getNetworkConnection().initiateConnectionEnd();
LocalGameLoop.getInstance().pauseGame();
}
static public void initiateBrokenConnectionMeasures()
{
......@@ -78,6 +78,6 @@ public class GameStarter {
* @return the relayer of the instance the player is going to command
*/
static public Relayer startGameBackup() {
return DummyLocalGameLoop.getInstance().getFollowedRelayer();
return LocalGameLoop.getInstance().getFollowedRelayer();
}
}
......@@ -19,9 +19,9 @@ import java.util.logging.Logger;
/**
* Created by bogdanbear on 22/11/2015.
Singleton class for the DummyLocalGameLoop
Singleton class for the LocalGameLoop
*/
public class DummyLocalGameLoop extends Thread{
public class LocalGameLoop extends Thread{
private NetworkConnection networkConnection;
private GameContent gameContent;
//this is the counter which gives us the ID of the game
......@@ -121,16 +121,16 @@ public class DummyLocalGameLoop extends Thread{
{
return gameContent;
}
private static DummyLocalGameLoop ourInstance = new DummyLocalGameLoop();
public static DummyLocalGameLoop getInstance() {
private static LocalGameLoop ourInstance = new LocalGameLoop();
public static LocalGameLoop getInstance() {
return ourInstance;
}
private DummyLocalGameLoop() {
private LocalGameLoop() {
}
@Override
public void run() {
LOGGER.info("DummyLocalGameLoop Thread started+"+currentThread().getId());
LOGGER.info("LocalGameLoop Thread started+"+currentThread().getId());
while (true) {
//System.out.println("DummyLocalGameLoopThread, game is "+isPlaying);
if (getIsPlaying()) {
......@@ -140,14 +140,14 @@ public class DummyLocalGameLoop extends Thread{
Event eventToReceive = null;
LOGGER.info("The game is on!");
while (!((eventToReceive = (Event) getNetworkConnection().receiveEvent(true)) instanceof EndEvent)) {
//System.out.println("DummyLocalGameLoop Thread: We have received an event!applying...+"+eventToReceive);
//System.out.println("LocalGameLoop Thread: We have received an event!applying...+"+eventToReceive);
try {
eventToReceive.apply(gameContent);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (eventToReceive instanceof MapInit) {
GameContent gc = DummyLocalGameLoop.getInstance().getContent();
GameContent gc = LocalGameLoop.getInstance().getContent();
Relayer firstEntityRelayer = Relayers.addFollowedRelayer(((MapInit) eventToReceive).getFollowedDummyEntity());
setFollowedRelayer(firstEntityRelayer);
relayerSemaphore.release();
......
......@@ -3,10 +3,7 @@ package graphics.display_test;
/**
* Created by etouss on 06/01/2016.
*/
import artificial_intelligence.AIControler;
import artificial_intelligence.AIEntities.AgressiveEntity;
import artificial_intelligence.AIEntities.EnumBehaviourType;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import gameloop.GameStarter;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
import graphics.ingame_input_listener.Input;
......@@ -39,6 +36,6 @@ public class GamePanelTermTest {
gm.changeGUIStateTo(GraphicsMasterAbstraction.GUIStates.GAME_PANEL);
gm.keyPressedHandler(Input.LEFT_ARROW);
gm.keyPressedHandler(Input.UP_ARROW);
assertEquals(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection(), core.zone.Direction.LEFTUP);
assertEquals(LocalGameLoop.getInstance().getFollowedRelayer().getDirection(), core.zone.Direction.LEFTUP);
}
}
package graphics.graphical_abstraction.panel;
import core.relayer.Relayer;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import graphics.guiSkeleton.inputManagement.InputInterpreter;
import graphics.ingame_input_listener.Input;
......@@ -20,7 +20,7 @@ public class GamePanelAbstractionController {
}
public void initialise(){
followedRelayer = DummyLocalGameLoop.getInstance().getFollowedRelayer();
followedRelayer = LocalGameLoop.getInstance().getFollowedRelayer();
MyInputInterpreter = new InputInterpreter(followedRelayer);
}
......
......@@ -2,7 +2,7 @@ package graphics.guiSkeleton;
import core.abilities.AbilityPackageInitialiser;
import core.abilities.effects.EffectPackageInitialiser;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
/**
......@@ -20,9 +20,9 @@ public class Igniter_Main {
EffectPackageInitialiser.initialisePackage();
//System.out.println();
/** launch the DummyLocalGameLoop**/
DummyLocalGameLoop.getInstance().setStartedBefore();
DummyLocalGameLoop.getInstance().start();
/** launch the LocalGameLoop**/
LocalGameLoop.getInstance().setStartedBefore();
LocalGameLoop.getInstance().start();
/** Launch the GUI (and thus the game) **/
GraphicsMaster.build();
......
......@@ -8,7 +8,7 @@ import core.zone.Circle;
import core.zone.Point;
import core.zone.Rectangle;
import core.zone.Zone;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import gameloop.GameStarter;
import graphics.graphical_abstraction.panel.GamePanelAbstraction;
import graphics.graphical_abstraction.panel.GamePanelAbstractionController;
......@@ -69,9 +69,9 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
RepaintTimer.getInstance().enterPlayingFramerateMode();
controller.initialise();
followedRelayer = DummyLocalGameLoop.getInstance().getFollowedRelayer();
followedRelayer = LocalGameLoop.getInstance().getFollowedRelayer();
gameContent = DummyLocalGameLoop.getInstance().getContent();
gameContent = LocalGameLoop.getInstance().getContent();
//subscribe to the map changes of gameContent
//gameContent.addMapChangeListener(this);
......@@ -173,7 +173,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
/** Update the Animations **/
Animation.updateAnimation();
synchronized (DummyLocalGameLoop.getInstance())
synchronized (LocalGameLoop.getInstance())
{
/** Get the GraphicsMapPoint of the position of the entity followed by the gamePanel **/
GraphicsMapPoint followedEntityPositionGraphicsMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
......@@ -258,7 +258,7 @@ public class GamePanel extends GUIPanel implements GameContentMapChangeListener,
/** DummyGameContentMapChangeListener implementation **/
@Override
public void mapChange() {
GraphicsMap graphicsMap = MapDrawer.drawMap(DummyLocalGameLoop.getInstance().getContent().getMap());
GraphicsMap graphicsMap = MapDrawer.drawMap(LocalGameLoop.getInstance().getContent().getMap());
GraphicsMapPoint initialTopLeftMapPoint = GraphicalBridgeConfiguration.makeMapPointFromCoreCoordinates(followedRelayer.getCharacter().getX(), followedRelayer.getCharacter().getY());
visionBox = new VisionBox(initialTopLeftMapPoint, getSize().width, getSize().height, graphicsMap);
repaint();
......
package graphics.guiSkeleton.guiPanel.menuPanel;
import gameloop.DummyLocalGameLoop;
import graphics.guiSkeleton.GUIColorsAndFonts;
import graphics.guiSkeleton.GraphicsMaster;
import graphics.guiSkeleton.guiPanel.menuPanel.facilities.ButtonMaker;
......@@ -45,7 +44,7 @@ public class ServerAddressPanel extends MenuPanel{
String address = addressTextField.getText();
RPCClient.setIp(address);
//it should start RPC calls
//DummyLocalGameLoop.getInstance().setShouldRPC(true);
//LocalGameLoop.getInstance().setShouldRPC(true);
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MULTIPLAYER_MENU);
RPCClient.connect();
}
......
......@@ -5,7 +5,7 @@ import core.gamestate.Being;
import core.gamestate.Entity;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import gameloop.DummyLocalGameLoop;
import gameloop.LocalGameLoop;
import gameloop.GameStarter;
import graphics.graphical_abstraction.panel.GamePanelAbstraction;
import graphics.graphical_abstraction.panel.GamePanelAbstractionController;
......@@ -58,11 +58,11 @@ public class GamePanelTerminal extends PanelTerminal implements GamePanelAbstrac
@Override
public void initialise() {
controller.initialise();
followedRelayer = DummyLocalGameLoop.getInstance().getFollowedRelayer();
followedRelayer = LocalGameLoop.getInstance().getFollowedRelayer();
//MyInputInterpreter = new InputInterpreter(followedRelayer);
gameContent = DummyLocalGameLoop.getInstance().getContent();
gameContent = LocalGameLoop.getInstance().getContent();
}
@Override
......@@ -94,7 +94,7 @@ public class GamePanelTerminal extends PanelTerminal implements GamePanelAbstrac
int ratio_screen_map = 1;
int ratio_screen_core = ratio_core_map/ratio_screen_map;
Map map = DummyLocalGameLoop.getInstance().getContent().getMap();
Map map = LocalGameLoop.getInstance().getContent().getMap();
int x_max_map = map.getHeight();
int y_max_map = map.getWidth();
......
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