SongInstance.java 1.8 KB

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