Browse Source

Reimplement singleton classes and update copyrights

Signed-off-by: Chris Cromer <chris@cromer.cl>
master
Chris Cromer 2 years ago
parent
commit
6c2665b1c5
  1. 2
      build.gradle
  2. 2
      gradle.properties
  3. 2
      gradle/wrapper/gradle-wrapper.properties
  4. 2
      settings.gradle
  5. 2
      src/main/java/cl/cromer/azaraka/Azaraka.java
  6. 4
      src/main/java/cl/cromer/azaraka/Canvas.java
  7. 2
      src/main/java/cl/cromer/azaraka/Cell.java
  8. 2
      src/main/java/cl/cromer/azaraka/Constants.java
  9. 2
      src/main/java/cl/cromer/azaraka/MainWindow.java
  10. 8
      src/main/java/cl/cromer/azaraka/Scene.java
  11. 2
      src/main/java/cl/cromer/azaraka/ai/AI.java
  12. 2
      src/main/java/cl/cromer/azaraka/ai/AIException.java
  13. 2
      src/main/java/cl/cromer/azaraka/ai/EnemyAI.java
  14. 2
      src/main/java/cl/cromer/azaraka/ai/PlayerAI.java
  15. 2
      src/main/java/cl/cromer/azaraka/ai/PlayerAStarAI.java
  16. 2
      src/main/java/cl/cromer/azaraka/ai/PlayerBreadthFirstAI.java
  17. 2
      src/main/java/cl/cromer/azaraka/ai/package-info.java
  18. 2
      src/main/java/cl/cromer/azaraka/json/Json.java
  19. 2
      src/main/java/cl/cromer/azaraka/json/JsonCell.java
  20. 2
      src/main/java/cl/cromer/azaraka/json/package-info.java
  21. 2
      src/main/java/cl/cromer/azaraka/logging/HtmlFormatter.java
  22. 2
      src/main/java/cl/cromer/azaraka/logging/StringUtils.java
  23. 2
      src/main/java/cl/cromer/azaraka/logging/package-info.java
  24. 2
      src/main/java/cl/cromer/azaraka/object/Chest.java
  25. 2
      src/main/java/cl/cromer/azaraka/object/Enemy.java
  26. 2
      src/main/java/cl/cromer/azaraka/object/Gem.java
  27. 2
      src/main/java/cl/cromer/azaraka/object/Object.java
  28. 2
      src/main/java/cl/cromer/azaraka/object/Obstacle.java
  29. 31
      src/main/java/cl/cromer/azaraka/object/Player.java
  30. 31
      src/main/java/cl/cromer/azaraka/object/Portal.java
  31. 2
      src/main/java/cl/cromer/azaraka/object/package-info.java
  32. 2
      src/main/java/cl/cromer/azaraka/package-info.java
  33. 2
      src/main/java/cl/cromer/azaraka/sound/Sound.java
  34. 2
      src/main/java/cl/cromer/azaraka/sound/SoundException.java
  35. 2
      src/main/java/cl/cromer/azaraka/sound/package-info.java
  36. 2
      src/main/java/cl/cromer/azaraka/sprite/Animation.java
  37. 2
      src/main/java/cl/cromer/azaraka/sprite/AnimationException.java
  38. 2
      src/main/java/cl/cromer/azaraka/sprite/Sheet.java
  39. 2
      src/main/java/cl/cromer/azaraka/sprite/SheetException.java
  40. 2
      src/main/java/cl/cromer/azaraka/sprite/package-info.java

2
build.gradle

@ -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:
*

2
gradle.properties

@ -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:
#

2
gradle/wrapper/gradle-wrapper.properties

@ -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:
#

2
settings.gradle

@ -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:
*

2
src/main/java/cl/cromer/azaraka/Azaraka.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:
*

4
src/main/java/cl/cromer/azaraka/Canvas.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:
*
@ -514,6 +514,8 @@ public class Canvas extends java.awt.Canvas implements Constants {
public void keyPressed(KeyEvent event) {
super.keyPressed(event);
if (event.getKeyCode() == KeyEvent.VK_ENTER) {
player.deleteInstance();
portal.deleteInstance();
azaraka.restart();
}
}

2
src/main/java/cl/cromer/azaraka/Cell.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:
*

2
src/main/java/cl/cromer/azaraka/Constants.java

@ -41,7 +41,7 @@ public interface Constants {
/**
* Which type of AI to use
*/
PlayerAIType PLAYER_AI = PlayerAIType.ASTAR;
PlayerAIType PLAYER_AI = PlayerAIType.HUMAN;
/**
* Whether or not the enemies should be controlled by AI
*/

2
src/main/java/cl/cromer/azaraka/MainWindow.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:
*

8
src/main/java/cl/cromer/azaraka/Scene.java

@ -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(new Player(null, cells.get(x).get(y)));
cells.get(x).get(y).setObject(Player.getInstance(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(new Portal(null, cells.get(x).get(y)));
cells.get(x).get(y).setObject(Portal.getInstance(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<Object> objectArrayList = new ArrayList<>();
// The player has a fixed position
cells.get(2).get(1).setObject(new Player(this, cells.get(2).get(1)));
cells.get(2).get(1).setObject(Player.getInstance(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(new Portal(this, cells.get(random[0]).get(random[1])));
cells.get(random[0]).get(random[1]).setObjectOnBottom(Portal.getInstance(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

2
src/main/java/cl/cromer/azaraka/ai/AI.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:
*

2
src/main/java/cl/cromer/azaraka/ai/AIException.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:
*

2
src/main/java/cl/cromer/azaraka/ai/EnemyAI.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:
*

2
src/main/java/cl/cromer/azaraka/ai/PlayerAI.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:
*

2
src/main/java/cl/cromer/azaraka/ai/PlayerAStarAI.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:
*

2
src/main/java/cl/cromer/azaraka/ai/PlayerBreadthFirstAI.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:
*

2
src/main/java/cl/cromer/azaraka/ai/package-info.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:
*

2
src/main/java/cl/cromer/azaraka/json/Json.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:
*

2
src/main/java/cl/cromer/azaraka/json/JsonCell.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:
*

2
src/main/java/cl/cromer/azaraka/json/package-info.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:
*

2
src/main/java/cl/cromer/azaraka/logging/HtmlFormatter.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:
*

2
src/main/java/cl/cromer/azaraka/logging/StringUtils.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:
*

2
src/main/java/cl/cromer/azaraka/logging/package-info.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:
*

2
src/main/java/cl/cromer/azaraka/object/Chest.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:
*

2
src/main/java/cl/cromer/azaraka/object/Enemy.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:
*

2
src/main/java/cl/cromer/azaraka/object/Gem.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:
*

2
src/main/java/cl/cromer/azaraka/object/Object.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:
*

2
src/main/java/cl/cromer/azaraka/object/Obstacle.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:
*

31
src/main/java/cl/cromer/azaraka/object/Player.java

@ -48,6 +48,10 @@ public class Player extends Object implements Constants {
* The current health of the player
*/
private int health = MAX_HEALTH;
/**
* The Player instance
*/
private static Player instance;
/**
* Initialize the player
@ -55,7 +59,7 @@ public class Player extends Object implements Constants {
* @param scene The scene the player is in
* @param cell The cell the player is in
*/
public Player(Scene scene, Cell cell) {
private Player(Scene scene, Cell cell) {
super(scene, cell);
setLogger(getLogger(this.getClass(), LogLevel.PLAYER));
loadPlayerAnimation();
@ -72,6 +76,31 @@ public class Player extends Object implements Constants {
}
}
/**
* Create the Player instance
*
* @param scene The scene the player is in
* @param cell The cell the player is in
* @return Returns the 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;
}
/**
* Delete the Player instance
*/
public void deleteInstance() {
instance = null;
}
/**
* Load the player animation
*/

31
src/main/java/cl/cromer/azaraka/object/Portal.java

@ -45,6 +45,10 @@ public class Portal extends Object implements Constants {
* The portal sound when a gem is purified
*/
private Sound sound;
/**
* The Portal instance
*/
private static Portal instance;
/**
* Initialize the portal
@ -52,12 +56,37 @@ public class Portal extends Object implements Constants {
* @param scene The scene that contains the portal
* @param cell The cell the portal is in
*/
public Portal(Scene scene, Cell cell) {
private Portal(Scene scene, Cell cell) {
super(scene, cell);
setLogger(getLogger(this.getClass(), LogLevel.PORTAL));
loadPortalAnimations();
}
/**
* Create an 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;
}
/**
* Delete the Portal instance
*/
public void deleteInstance() {
instance = null;
}
/**
* Load the portal animation
*/

2
src/main/java/cl/cromer/azaraka/object/package-info.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:
*

2
src/main/java/cl/cromer/azaraka/package-info.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:
*

2
src/main/java/cl/cromer/azaraka/sound/Sound.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:
*

2
src/main/java/cl/cromer/azaraka/sound/SoundException.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:
*

2
src/main/java/cl/cromer/azaraka/sound/package-info.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:
*

2
src/main/java/cl/cromer/azaraka/sprite/Animation.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:
*

2
src/main/java/cl/cromer/azaraka/sprite/AnimationException.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:
*

2
src/main/java/cl/cromer/azaraka/sprite/Sheet.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:
*

2
src/main/java/cl/cromer/azaraka/sprite/SheetException.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:
*

2
src/main/java/cl/cromer/azaraka/sprite/package-info.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:
*

Loading…
Cancel
Save