diff --git a/src/main/java/cl/cromer/azaraka/Scene.java b/src/main/java/cl/cromer/azaraka/Scene.java index 28162d0..cc548d1 100644 --- a/src/main/java/cl/cromer/azaraka/Scene.java +++ b/src/main/java/cl/cromer/azaraka/Scene.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Chris Cromer + * Copyright 2020 Chris Cromer * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * @@ -135,7 +135,7 @@ public class Scene extends JComponent implements Constants { cells.get(x).add(cell); if (jsonCells[x][y].type.equals(Player.class.getName())) { - cells.get(x).get(y).setObject(Player.getInstance(null, cells.get(x).get(y))); + cells.get(x).get(y).setObject(new Player(null, cells.get(x).get(y))); } else if (jsonCells[x][y].type.equals(Enemy.class.getName())) { cells.get(x).get(y).setObject(new Enemy(null, cells.get(x).get(y), null)); @@ -153,7 +153,7 @@ public class Scene extends JComponent implements Constants { cells.get(x).get(y).setObject(new Obstacle(null, cells.get(x).get(y))); } else if (jsonCells[x][y].type.equals(Portal.class.getName())) { - cells.get(x).get(y).setObject(Portal.getInstance(null, cells.get(x).get(y))); + cells.get(x).get(y).setObject(new Portal(null, cells.get(x).get(y))); } for (int k = 0; k < jsonCells[x][y].textures.size(); k++) { @@ -178,7 +178,7 @@ public class Scene extends JComponent implements Constants { List objectArrayList = new ArrayList<>(); // The player has a fixed position - cells.get(2).get(1).setObject(Player.getInstance(this, cells.get(2).get(1))); + cells.get(2).get(1).setObject(new Player(this, cells.get(2).get(1))); objectArrayList.add(cells.get(2).get(1).getObject()); for (int i = 0; i < OBSTACLES; i++) { @@ -201,7 +201,7 @@ public class Scene extends JComponent implements Constants { } random = randomCoordinates(); - cells.get(random[0]).get(random[1]).setObjectOnBottom(Portal.getInstance(this, cells.get(random[0]).get(random[1]))); + cells.get(random[0]).get(random[1]).setObjectOnBottom(new Portal(this, cells.get(random[0]).get(random[1]))); objectArrayList.add(cells.get(random[0]).get(random[1]).getObjectOnBottom()); // Generate enough keys for the chests that will exist diff --git a/src/main/java/cl/cromer/azaraka/object/Player.java b/src/main/java/cl/cromer/azaraka/object/Player.java index 1fb4377..bc58388 100644 --- a/src/main/java/cl/cromer/azaraka/object/Player.java +++ b/src/main/java/cl/cromer/azaraka/object/Player.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Chris Cromer + * Copyright 2020 Chris Cromer * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * @@ -36,10 +36,6 @@ public class Player extends Object implements Constants { * The maximum health of the player */ public final static int MAX_HEALTH = 20; - /** - * There can be only 1 player - */ - private static Player instance = null; /** * Objects that the player is carrying */ @@ -59,7 +55,7 @@ public class Player extends Object implements Constants { * @param scene The scene the player is in * @param cell The cell the player is in */ - private Player(Scene scene, Cell cell) { + public Player(Scene scene, Cell cell) { super(scene, cell); setLogger(getLogger(this.getClass(), LogLevel.PLAYER)); loadPlayerAnimation(); @@ -76,24 +72,6 @@ public class Player extends Object implements Constants { } } - /** - * Get a unique instance of the player - * - * @param scene The scene the player is in - * @param cell The cell the player is in - * @return Returns the Player instance - */ - public static Player getInstance(Scene scene, Cell cell) { - if (instance == null) { - synchronized (Player.class) { - if (instance == null) { - instance = new Player(scene, cell); - } - } - } - return instance; - } - /** * Load the player animation */ diff --git a/src/main/java/cl/cromer/azaraka/object/Portal.java b/src/main/java/cl/cromer/azaraka/object/Portal.java index 91384a7..c73d2b9 100644 --- a/src/main/java/cl/cromer/azaraka/object/Portal.java +++ b/src/main/java/cl/cromer/azaraka/object/Portal.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Chris Cromer + * Copyright 2020 Chris Cromer * * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * @@ -29,10 +29,6 @@ import java.util.List; * This class handles the portal functionality */ public class Portal extends Object implements Constants { - /** - * There can be only 1 portal - */ - private static Portal instance = null; /** * The current state of the portal */ @@ -56,30 +52,12 @@ public class Portal extends Object implements Constants { * @param scene The scene that contains the portal * @param cell The cell the portal is in */ - private Portal(Scene scene, Cell cell) { + public Portal(Scene scene, Cell cell) { super(scene, cell); setLogger(getLogger(this.getClass(), LogLevel.PORTAL)); loadPortalAnimations(); } - /** - * Get a unique instance of the portal - * - * @param scene The scene the portal is in - * @param cell The cell the portal is in - * @return Returns the Portal instance - */ - public static Portal getInstance(Scene scene, Cell cell) { - if (instance == null) { - synchronized (Portal.class) { - if (instance == null) { - instance = new Portal(scene, cell); - } - } - } - return instance; - } - /** * Load the portal animation */