SongInstance.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. if(objects.size() == 0)
  56. return 0;
  57. return objects.get(objects.size()-1).getTime();
  58. }
  59. public List<ButtonInstance> getButtonsBetween(long oldProgress, long progress) {
  60. List<ButtonInstance> b = new ArrayList<ButtonInstance>();
  61. for(ButtonInstance i : buttons)
  62. {
  63. if(i.getTime() > progress)
  64. {
  65. return b;
  66. }
  67. if(i.getTime() >= oldProgress && i.getTime() < progress)
  68. {
  69. b.add(i);
  70. }
  71. }
  72. return b;
  73. }
  74. public int getTimesPlayed() {
  75. return timesPlayed;
  76. }
  77. public void setTimesPlayed(int timesPlayed) {
  78. this.timesPlayed = timesPlayed;
  79. }
  80. public int getHighestScore() {
  81. return highestScore;
  82. }
  83. public void setHighestScore(int highestScore) {
  84. this.highestScore = highestScore;
  85. }
  86. public void played()
  87. {
  88. timesPlayed++;
  89. }
  90. }