implemented new map structure
This commit is contained in:
@@ -7,17 +7,18 @@ import zero1hd.polyjet.audio.AudioData;
|
||||
import zero1hd.polyjet.entity.Entities;
|
||||
|
||||
public class GamePlayMap {
|
||||
private AudioData playableClip;
|
||||
private AudioData musicData;
|
||||
private float playTime;
|
||||
private Array<EntitySpawnInfo> spawnList;
|
||||
private Array<MapWindowData> spawnList;
|
||||
private boolean building;
|
||||
private int index;
|
||||
private int absoluteIndex;
|
||||
/**
|
||||
* GamePlayMap is what the game area will use to generate entities and judge current audio data
|
||||
* @param audioData audio data
|
||||
*/
|
||||
public GamePlayMap(AudioData audioData) {
|
||||
this.playableClip = audioData;
|
||||
this.musicData = audioData;
|
||||
spawnList = new Array<>();
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ public class GamePlayMap {
|
||||
* @return
|
||||
*/
|
||||
public Music getPlayableClip() {
|
||||
return playableClip.getPlaybackMusic();
|
||||
return musicData.getPlaybackMusic();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,6 +43,10 @@ public class GamePlayMap {
|
||||
*/
|
||||
public void beginBuild() {
|
||||
building = true;
|
||||
spawnList.clear();
|
||||
spawnList.add(new MapWindowData());
|
||||
index = 0;
|
||||
absoluteIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,6 +54,8 @@ public class GamePlayMap {
|
||||
*/
|
||||
public void endBuild() {
|
||||
building = false;
|
||||
index = 0;
|
||||
absoluteIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,46 +65,47 @@ public class GamePlayMap {
|
||||
* @param entityType what type of entity to spawn
|
||||
* @param parameters the arguments for the entity. It is important to have the same amount of parameters the entity requires to spawn
|
||||
*/
|
||||
|
||||
public void addToMap(Entities entityType, float... parameters) {
|
||||
if (building && entityType != null && parameters != null) {
|
||||
spawnList.add(new EntitySpawnInfo(entityType, parameters));
|
||||
spawnList.get(index).addEntity(new EntitySpawnInfo(entityType, parameters));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves onto the next window of the map for the song
|
||||
*/
|
||||
public void nextWindow() {
|
||||
absoluteIndex++;
|
||||
resetIndex();
|
||||
if (building) {
|
||||
spawnList.add(new MapWindowData());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* moves to the previous window to make edits to that frame.
|
||||
*/
|
||||
public void previousWindow() {
|
||||
absoluteIndex--;
|
||||
resetIndex();
|
||||
}
|
||||
/**
|
||||
* use this to add rest for current index position
|
||||
*/
|
||||
public void addNullToMap() {
|
||||
if (building) {
|
||||
spawnList.add(null);
|
||||
spawnList.set(index, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only works when not started.
|
||||
* retrieve next entity in list.
|
||||
* @return
|
||||
*/
|
||||
public EntitySpawnInfo nextEntity(boolean indexUpdate) {
|
||||
if (!building) {
|
||||
if (indexUpdate) {
|
||||
index++;
|
||||
}
|
||||
EntitySpawnInfo spawnInfo = spawnList.get(index);
|
||||
return spawnInfo;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public EntitySpawnInfo safeNextEntity() {
|
||||
playableClip.readIndexUpdate();
|
||||
if (index != playableClip.getReadIndex()) {
|
||||
index = playableClip.getReadIndex();
|
||||
return nextEntity(false);
|
||||
} else {
|
||||
return null;
|
||||
public MapWindowData nextWindowData() {
|
||||
if (index != musicData.getReadIndex()) {
|
||||
absoluteIndex = musicData.getReadIndex();
|
||||
resetIndex();
|
||||
return spawnList.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,4 +115,12 @@ public class GamePlayMap {
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public boolean isCurrentNull() {
|
||||
return spawnList.get(index) == null ? true : false;
|
||||
}
|
||||
|
||||
public void resetIndex() {
|
||||
index = absoluteIndex;
|
||||
}
|
||||
}
|
||||
|
19
core/src/zero1hd/polyjet/audio/map/MapWindowData.java
Executable file
19
core/src/zero1hd/polyjet/audio/map/MapWindowData.java
Executable file
@@ -0,0 +1,19 @@
|
||||
package zero1hd.polyjet.audio.map;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
|
||||
public class MapWindowData {
|
||||
Array<EntitySpawnInfo> entityDatas;
|
||||
public MapWindowData() {
|
||||
entityDatas = new Array<>(EntitySpawnInfo.class);
|
||||
}
|
||||
|
||||
public void addEntity(EntitySpawnInfo entity) {
|
||||
entityDatas.add(entity);
|
||||
}
|
||||
|
||||
public EntitySpawnInfo[] getArray() {
|
||||
return entityDatas.toArray();
|
||||
}
|
||||
}
|
@@ -83,11 +83,11 @@ public class RhythmMapAlgorithm implements Runnable {
|
||||
(Polyjet.GAME_AREA_HEIGHT/4f)/avgSPB);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
map.addNullToMap();
|
||||
}
|
||||
|
||||
map.nextWindow();
|
||||
|
||||
progress = MathUtils.round(100f*index/bassPeaks.size);
|
||||
|
||||
sender.send(MiniEvents.MAPGEN_ITERATED);
|
||||
|
Reference in New Issue
Block a user