SongInstance.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package audio;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. public class SongInstance {
  5. private String difficulty;
  6. private int timesPlayed;
  7. private int highestScore;
  8. private List<ObjectInstance> objects;
  9. private List<ButtonInstance> buttons;
  10. public SongInstance(String difficulty)
  11. {
  12. this.difficulty = difficulty;
  13. this.timesPlayed = 0;
  14. this.highestScore = 0;
  15. objects = new ArrayList<ObjectInstance>();
  16. buttons = new ArrayList<ButtonInstance>();
  17. }
  18. public void addObjectInstance(ObjectInstance obj)
  19. {
  20. objects.add(obj);
  21. }
  22. public void addButtonInstance(ButtonInstance btn)
  23. {
  24. buttons.add(btn);
  25. }
  26. public List<ObjectInstance> getObjects() {
  27. return objects;
  28. }
  29. public List<ButtonInstance> getButtons() {
  30. return buttons;
  31. }
  32. public String getDifficulty() {
  33. return difficulty;
  34. }
  35. public void setDifficulty(String difficulty) {
  36. this.difficulty = difficulty;
  37. }
  38. public List<ObjectInstance> getObjectsBetween(long oldProgress, long progress) {
  39. List<ObjectInstance> b = new ArrayList<ObjectInstance>();
  40. for(ObjectInstance i : objects)
  41. {
  42. if(i.getTime() >= progress)
  43. {
  44. return b;
  45. }
  46. if(i.getTime() >= oldProgress && i.getTime() < progress)
  47. {
  48. b.add(i);
  49. }
  50. }
  51. return b;
  52. }
  53. public long getEndTime()
  54. {
  55. return objects.get(objects.size()-1).getTime();
  56. }
  57. public List<ButtonInstance> getButtonsBetween(long oldProgress, long progress) {
  58. List<ButtonInstance> b = new ArrayList<ButtonInstance>();
  59. for(ButtonInstance i : buttons)
  60. {
  61. if(i.getTime() > progress)
  62. {
  63. return b;
  64. }
  65. if(i.getTime() >= oldProgress && i.getTime() < progress)
  66. {
  67. b.add(i);
  68. }
  69. }
  70. return b;
  71. }
  72. public int getTimesPlayed() {
  73. return timesPlayed;
  74. }
  75. public void setTimesPlayed(int timesPlayed) {
  76. this.timesPlayed = timesPlayed;
  77. }
  78. public int getHighestScore() {
  79. return highestScore;
  80. }
  81. public void setHighestScore(int highestScore) {
  82. this.highestScore = highestScore;
  83. }
  84. public void played()
  85. {
  86. timesPlayed++;
  87. }
  88. }