entity coordinator integration works
This commit is contained in:
parent
a72bd104f0
commit
cfe5e3592b
@ -13,6 +13,7 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import com.badlogic.gdx.utils.Pool.Poolable;
|
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||||
|
|
||||||
|
import zero1hd.rhythmbullet.RhythmBullet;
|
||||||
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||||
|
|
||||||
public class Entity extends Actor implements Poolable {
|
public class Entity extends Actor implements Poolable {
|
||||||
@ -58,6 +59,7 @@ public class Entity extends Actor implements Poolable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init(HashMap<String, Float> params) {
|
public void init(HashMap<String, Float> params) {
|
||||||
|
params.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,13 +90,18 @@ public class Entity extends Actor implements Poolable {
|
|||||||
* @return if this entity is dead or not.
|
* @return if this entity is dead or not.
|
||||||
*/
|
*/
|
||||||
public boolean isDead() {
|
public boolean isDead() {
|
||||||
|
if (getX() > RhythmBullet.GAME_AREA_WIDTH || getY() > RhythmBullet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
if (!nonStnrd) {
|
if (!nonStnrd) {
|
||||||
coordinator.coordinate(delta);
|
if (coordinator != null) {
|
||||||
|
coordinator.coordinate(delta);
|
||||||
|
}
|
||||||
|
|
||||||
if (move) {
|
if (move) {
|
||||||
move(delta, true);
|
move(delta, true);
|
||||||
@ -104,6 +111,9 @@ public class Entity extends Actor implements Poolable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (angle >= 360f) {
|
||||||
|
angle -= 360f;
|
||||||
|
}
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +160,10 @@ public class Entity extends Actor implements Poolable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
coordinator.clean();
|
if (coordinator != null) {
|
||||||
coordinator = null;
|
coordinator.clean();
|
||||||
|
coordinator = null;
|
||||||
|
}
|
||||||
rotRatios.set(0, 0);
|
rotRatios.set(0, 0);
|
||||||
sprite.setPosition(0, 0);
|
sprite.setPosition(0, 0);
|
||||||
hitbox.set(0, 0, 0, 0);
|
hitbox.set(0, 0, 0, 0);
|
||||||
@ -180,5 +192,6 @@ public class Entity extends Actor implements Poolable {
|
|||||||
|
|
||||||
public void setCoordinator(Coordinator coordinator) {
|
public void setCoordinator(Coordinator coordinator) {
|
||||||
this.coordinator = coordinator;
|
this.coordinator = coordinator;
|
||||||
|
coordinator.setEntity(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ public class EntityFrame<T extends Entity> {
|
|||||||
private EntityManager ec;
|
private EntityManager ec;
|
||||||
Class<T> ct;
|
Class<T> ct;
|
||||||
EntityFrame<T> ef;
|
EntityFrame<T> ef;
|
||||||
public EntityFrame(EntityManager entityController) {
|
public EntityFrame(EntityManager entityController, Class<T> classType) {
|
||||||
|
this.ct = classType;
|
||||||
ef = this;
|
ef = this;
|
||||||
ec = entityController;
|
ec = entityController;
|
||||||
pool = new Pool<T>() {
|
pool = new Pool<T>() {
|
||||||
@ -52,4 +53,9 @@ public class EntityFrame<T extends Entity> {
|
|||||||
entity.remove();
|
entity.remove();
|
||||||
pool.free(ct.cast(entity));
|
pool.free(ct.cast(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ct.getSimpleName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ public class EntityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
voidCircle = new EntityFrame<>(this);
|
voidCircle = new EntityFrame<>(this, VoidCircle.class);
|
||||||
pellet = new EntityFrame<>(this);
|
pellet = new EntityFrame<>(this, Pellet.class);
|
||||||
shard = new EntityFrame<>(this);
|
shard = new EntityFrame<>(this, Shard.class);
|
||||||
bar = new EntityFrame<>(this);
|
bar = new EntityFrame<>(this, Bar.class);
|
||||||
flake = new EntityFrame<>(this);
|
flake = new EntityFrame<>(this, Flake.class);
|
||||||
laser = new EntityFrame<>(this);
|
laser = new EntityFrame<>(this, Laser.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@ public class Coordinator implements Poolable {
|
|||||||
cf.recycleCoordinator(this);
|
cf.recycleCoordinator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEntity(Entity entity) {
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
entity = null;
|
entity = null;
|
||||||
|
@ -9,8 +9,9 @@ public class CoordinatorFrame<T extends Coordinator> {
|
|||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
CoordinatorFrame<T> cf;
|
CoordinatorFrame<T> cf;
|
||||||
Class<T> coordinatorType;
|
Class<T> coordinatorType;
|
||||||
public CoordinatorFrame(EntityManager entityManager) {
|
public CoordinatorFrame(EntityManager entityManager, Class<T> classtype) {
|
||||||
this.em = entityManager;
|
this.em = entityManager;
|
||||||
|
coordinatorType = classtype;
|
||||||
cf = this;
|
cf = this;
|
||||||
pool = new Pool<T>() {
|
pool = new Pool<T>() {
|
||||||
@Override
|
@Override
|
||||||
@ -35,5 +36,9 @@ public class CoordinatorFrame<T extends Coordinator> {
|
|||||||
protected void recycleCoordinator(Coordinator coordinator) {
|
protected void recycleCoordinator(Coordinator coordinator) {
|
||||||
pool.free(coordinatorType.cast(coordinator));
|
pool.free(coordinatorType.cast(coordinator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return coordinatorType.getSimpleName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package zero1hd.rhythmbullet.entity.coordinator;
|
|
||||||
|
|
||||||
public enum CoordinatorIndex {
|
|
||||||
SLOW_RIGHT, SLOW_LEFT;
|
|
||||||
}
|
|
@ -14,7 +14,7 @@ public class CoordinatorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
slowLeft = new CoordinatorFrame<>(em);
|
slowLeft = new CoordinatorFrame<>(em, SlowLeftCoordinator.class);
|
||||||
slowRight = new CoordinatorFrame<>(em);
|
slowRight = new CoordinatorFrame<>(em, SlowRightCoordinator.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package zero1hd.rhythmbullet.entity.coordinator;
|
|||||||
public class SlowLeftCoordinator extends Coordinator {
|
public class SlowLeftCoordinator extends Coordinator {
|
||||||
@Override
|
@Override
|
||||||
public void coordinate(float delta) {
|
public void coordinate(float delta) {
|
||||||
entity.angle -= 8*delta;
|
entity.angle -= 32*delta;
|
||||||
super.coordinate(delta);
|
super.coordinate(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package zero1hd.rhythmbullet.entity.coordinator;
|
|||||||
public class SlowRightCoordinator extends Coordinator {
|
public class SlowRightCoordinator extends Coordinator {
|
||||||
@Override
|
@Override
|
||||||
public void coordinate(float delta) {
|
public void coordinate(float delta) {
|
||||||
entity.angle += 8*delta;
|
entity.angle += 32*delta;
|
||||||
super.coordinate(delta);
|
super.coordinate(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,6 @@ public class Bar extends Entity {
|
|||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
hitbox.setPosition(getX(), getY());
|
hitbox.setPosition(getX(), getY());
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
if (getY() < 0-getHeight()) {
|
|
||||||
dead = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,14 +68,10 @@ public class Flake extends Entity {
|
|||||||
timer -= delta;
|
timer -= delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
move(delta, false);
|
move(delta, true);
|
||||||
System.out.println("---Start----");
|
|
||||||
System.out.println("Flake: " + center);
|
|
||||||
for (int i = 0; i < shards.length; i++) {
|
for (int i = 0; i < shards.length; i++) {
|
||||||
shards[i].setPosition(center.x-shards[i].getWidth()/2f, center.y-shards[i].getWidth()/2f);
|
shards[i].setPosition(center.x-shards[i].getWidth()/2f, center.y-shards[i].getWidth()/2f);
|
||||||
shards[i].move(delta, true);
|
shards[i].move(delta, true);
|
||||||
System.out.println("Shard " + i + ": " + shards[i].getCenter());
|
|
||||||
System.out.println("Sprite Pos: " + shards[i].getHitZone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getX() > RhythmBullet.GAME_AREA_WIDTH || getY() > RhythmBullet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
if (getX() > RhythmBullet.GAME_AREA_WIDTH || getY() > RhythmBullet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
||||||
|
@ -43,10 +43,6 @@ public class Pellet extends Entity implements Poolable {
|
|||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
|
|
||||||
if (getX() > RhythmBullet.GAME_AREA_WIDTH || getY() > RhythmBullet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
|
||||||
dead = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +56,7 @@ public class CreativeHUD extends Stage implements MiniListener {
|
|||||||
bassUMgraphWindow = new BassUMGraphWindow("Bass/UM Peak Values", core.getDefaultSkin());
|
bassUMgraphWindow = new BassUMGraphWindow("Bass/UM Peak Values", core.getDefaultSkin());
|
||||||
mGraphWindow = new MGraphWindow("Midrange Peak Values", core.getDefaultSkin());
|
mGraphWindow = new MGraphWindow("Midrange Peak Values", core.getDefaultSkin());
|
||||||
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
|
volumeWindow = new VolumeWindow("Volume adjustments", core.getDefaultSkin(), core.getPrefs());
|
||||||
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.em, gpa);
|
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.em, gpa.cm, gpa);
|
||||||
diffWindow = new DifficultyWindow(core.getDefaultSkin());
|
diffWindow = new DifficultyWindow(core.getDefaultSkin());
|
||||||
|
|
||||||
//Back button
|
//Back button
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package zero1hd.rhythmbullet.ui.windows;
|
package zero1hd.rhythmbullet.ui.windows;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
@ -9,10 +11,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.entity.EntityManager;
|
import zero1hd.rhythmbullet.entity.Entity;
|
||||||
|
import zero1hd.rhythmbullet.entity.EntityFrame;
|
||||||
import zero1hd.rhythmbullet.entity.EntityIndex;
|
import zero1hd.rhythmbullet.entity.EntityIndex;
|
||||||
|
import zero1hd.rhythmbullet.entity.EntityManager;
|
||||||
import zero1hd.rhythmbullet.entity.ally.Laser;
|
import zero1hd.rhythmbullet.entity.ally.Laser;
|
||||||
|
import zero1hd.rhythmbullet.entity.coordinator.Coordinator;
|
||||||
|
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame;
|
||||||
|
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
|
||||||
import zero1hd.rhythmbullet.entity.enemies.Bar;
|
import zero1hd.rhythmbullet.entity.enemies.Bar;
|
||||||
import zero1hd.rhythmbullet.entity.enemies.Flake;
|
import zero1hd.rhythmbullet.entity.enemies.Flake;
|
||||||
import zero1hd.rhythmbullet.entity.enemies.Pellet;
|
import zero1hd.rhythmbullet.entity.enemies.Pellet;
|
||||||
@ -23,17 +31,24 @@ public class SpawnerWindow extends Window {
|
|||||||
private EntityManager ec;
|
private EntityManager ec;
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
|
|
||||||
private List<EntityIndex> listOfEntities;
|
private HashMap<String, Float> params = new HashMap<>();
|
||||||
private ScrollPane scroller;
|
|
||||||
|
|
||||||
|
private Array<EntityFrame<? extends Entity>> entityFrames = new Array<>();
|
||||||
|
private List<EntityFrame<? extends Entity>> listOfEntities;
|
||||||
|
private ScrollPane entityListScroller;
|
||||||
|
|
||||||
|
private Array<CoordinatorFrame<? extends Coordinator>> coordinatorFrames = new Array<>();
|
||||||
|
private List<CoordinatorFrame<? extends Coordinator>> listOfCoordinators;
|
||||||
|
private ScrollPane coordinatorListScroller;
|
||||||
|
|
||||||
private Slider mod1;
|
private Slider mod1;
|
||||||
private Slider mod2;
|
private Slider mod2;
|
||||||
private Slider mod3;
|
private Slider mod3;
|
||||||
private Slider mod4;
|
private Slider mod4;
|
||||||
|
|
||||||
public SpawnerWindow(String title, Skin skin, EntityManager ec, Stage stageForEntities) {
|
public SpawnerWindow(String title, Skin skin, EntityManager em, CoordinatorManager cm, Stage stageForEntities) {
|
||||||
super(title, skin, "tinted");
|
super(title, skin, "tinted");
|
||||||
this.ec = ec;
|
this.ec = em;
|
||||||
stage = stageForEntities;
|
stage = stageForEntities;
|
||||||
|
|
||||||
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
||||||
@ -42,14 +57,29 @@ public class SpawnerWindow extends Window {
|
|||||||
mod4 = new Slider(1f, 12f, 0.01f, true, skin);
|
mod4 = new Slider(1f, 12f, 0.01f, true, skin);
|
||||||
|
|
||||||
listOfEntities = new List<>(skin);
|
listOfEntities = new List<>(skin);
|
||||||
listOfEntities.setItems(EntityIndex.values());
|
entityFrames.add(em.bar);
|
||||||
|
entityFrames.add(em.flake);
|
||||||
|
entityFrames.add(em.laser);
|
||||||
|
entityFrames.add(em.pellet);
|
||||||
|
entityFrames.add(em.shard);
|
||||||
|
entityFrames.add(em.voidCircle);
|
||||||
|
|
||||||
scroller = new ScrollPane(listOfEntities);
|
listOfEntities.setItems(entityFrames);
|
||||||
add(scroller).expandY().fillY().spaceRight(15f);
|
entityListScroller = new ScrollPane(listOfEntities, skin);
|
||||||
|
add(entityListScroller).height(350f).width(200f);
|
||||||
|
|
||||||
|
|
||||||
|
listOfCoordinators = new List<>(skin);
|
||||||
|
coordinatorFrames.add(cm.slowLeft);
|
||||||
|
coordinatorFrames.add(cm.slowRight);
|
||||||
|
|
||||||
|
listOfCoordinators.setItems(coordinatorFrames);
|
||||||
|
coordinatorListScroller = new ScrollPane(listOfCoordinators, skin);
|
||||||
|
add(coordinatorListScroller).height(350f).width(200f);
|
||||||
|
|
||||||
add(mod1, mod2, mod3, mod4);
|
add(mod1, mod2, mod3, mod4);
|
||||||
|
|
||||||
setSize(300f, 375f);
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -65,40 +95,33 @@ public class SpawnerWindow extends Window {
|
|||||||
coords.set(Gdx.input.getX(), Gdx.input.getY());
|
coords.set(Gdx.input.getX(), Gdx.input.getY());
|
||||||
stage.screenToStageCoordinates(coords);
|
stage.screenToStageCoordinates(coords);
|
||||||
|
|
||||||
|
Entity entity = listOfEntities.getSelected().buildEntity();
|
||||||
switch(listOfEntities.getSelected()) {
|
|
||||||
case LASER:
|
if (Gdx.input.isKeyPressed(Keys.ALT_LEFT)) {
|
||||||
Laser laser = ec.laser.buildEntity();
|
entity.setCoordinator(listOfCoordinators.getSelected().buildCoordinator());
|
||||||
laser.init(coords.x, coords.y, mod1.getValue());
|
|
||||||
stage.addActor(laser);
|
|
||||||
break;
|
|
||||||
case PELLET:
|
|
||||||
Pellet pellet = ec.pellet.buildEntity();
|
|
||||||
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
|
|
||||||
stage.addActor(pellet);
|
|
||||||
break;
|
|
||||||
case VOID_CIRCLE:
|
|
||||||
VoidCircle voidCircle = ec.voidCircle.buildEntity();
|
|
||||||
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
|
||||||
stage.addActor(voidCircle);
|
|
||||||
break;
|
|
||||||
case SHARD:
|
|
||||||
Shard shard = ec.shard.buildEntity();
|
|
||||||
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
|
||||||
stage.addActor(shard);
|
|
||||||
break;
|
|
||||||
case BAR:
|
|
||||||
Bar bar = ec.bar.buildEntity();
|
|
||||||
bar.init(coords.x, mod1.getValue());
|
|
||||||
stage.addActor(bar);
|
|
||||||
break;
|
|
||||||
case FLAKE:
|
|
||||||
Flake flake = ec.flake.buildEntity();
|
|
||||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
|
|
||||||
stage.addActor(flake);
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity.getClass() == Laser.class) {
|
||||||
|
Laser laser = (Laser) entity;
|
||||||
|
laser.init(coords.x, coords.y, mod1.getValue());
|
||||||
|
} else if (entity.getClass() == Pellet.class) {
|
||||||
|
Pellet pellet = (Pellet) entity;
|
||||||
|
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue());
|
||||||
|
} else if (entity.getClass() == VoidCircle.class) {
|
||||||
|
VoidCircle voidCircle = (VoidCircle) entity;
|
||||||
|
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
||||||
|
} else if (entity.getClass() == Shard.class) {
|
||||||
|
Shard shard = (Shard) entity;
|
||||||
|
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
||||||
|
} else if (entity.getClass() == Bar.class) {
|
||||||
|
Bar bar = (Bar) entity;
|
||||||
|
bar.init(coords.x, mod1.getValue());
|
||||||
|
} else if (entity.getClass() == Flake.class) {
|
||||||
|
Flake flake = (Flake) entity;
|
||||||
|
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
stage.addActor(entity);
|
||||||
}
|
}
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user