|
@@ -9,6 +9,7 @@ import me.hammerle.snuviscript.code.Script;
|
|
|
import me.hammerle.supersnuvi.Game;
|
|
|
import me.hammerle.supersnuvi.entity.Entity;
|
|
|
import me.hammerle.supersnuvi.entity.EntityBuilder;
|
|
|
+import me.hammerle.supersnuvi.rendering.Light;
|
|
|
import me.hammerle.supersnuvi.rendering.TileUpdater;
|
|
|
import me.hammerle.supersnuvi.tiles.Location;
|
|
|
import me.hammerle.supersnuvi.tiles.Tile;
|
|
@@ -17,12 +18,34 @@ import me.hammerle.supersnuvi.util.Utils;
|
|
|
|
|
|
public abstract class Level
|
|
|
{
|
|
|
+ // level data
|
|
|
+ private final TileUpdater tileUpdater = new TileUpdater();
|
|
|
+ // entity related
|
|
|
+ private final HashMap<Integer, Entity> entities = new HashMap<>();
|
|
|
+ private final LinkedList<Entity> spawnQueue = new LinkedList<>();
|
|
|
+ private Entity hero = null;
|
|
|
+ private int entityCounter = 0;
|
|
|
+ // controlling
|
|
|
+ private boolean shouldReset = false;
|
|
|
+ private boolean done = false;
|
|
|
+ // lighting
|
|
|
+ private float red = 1.0f;
|
|
|
+ private float green = 1.0f;
|
|
|
+ private float blue = 1.0f;
|
|
|
+ private Light[] lights = new Light[32];
|
|
|
+
|
|
|
+ public Level()
|
|
|
+ {
|
|
|
+ for(int i = 0; i < lights.length; i++)
|
|
|
+ {
|
|
|
+ lights[i] = new Light();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// -------------------------------------------------------------------------
|
|
|
// level data
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
- private final TileUpdater tileUpdater = new TileUpdater();
|
|
|
-
|
|
|
public abstract LevelData getData();
|
|
|
|
|
|
public String getName()
|
|
@@ -76,11 +99,6 @@ public abstract class Level
|
|
|
// entity related
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
- private final HashMap<Integer, Entity> entities = new HashMap<>();
|
|
|
- private final LinkedList<Entity> spawnQueue = new LinkedList<>();
|
|
|
- private Entity hero = null;
|
|
|
- private int entityCounter = 0;
|
|
|
-
|
|
|
public final Entity getHero()
|
|
|
{
|
|
|
return hero;
|
|
@@ -146,9 +164,6 @@ public abstract class Level
|
|
|
// controlling
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
|
|
- private boolean shouldReset = false;
|
|
|
- private boolean done = false;
|
|
|
-
|
|
|
public abstract void tick();
|
|
|
|
|
|
public final void finishLevel()
|
|
@@ -174,6 +189,12 @@ public abstract class Level
|
|
|
|
|
|
public final void reset()
|
|
|
{
|
|
|
+ // reset lights
|
|
|
+ for(Light l : lights)
|
|
|
+ {
|
|
|
+ l.reset();
|
|
|
+ }
|
|
|
+
|
|
|
onReset();
|
|
|
shouldReset = false;
|
|
|
done = false;
|
|
@@ -293,4 +314,35 @@ public abstract class Level
|
|
|
{
|
|
|
callEvent(name, null, null);
|
|
|
}
|
|
|
+
|
|
|
+ // -------------------------------------------------------------------------
|
|
|
+ // lighting
|
|
|
+ // -------------------------------------------------------------------------
|
|
|
+
|
|
|
+ public final void setAmbientLight(float r, float g, float b)
|
|
|
+ {
|
|
|
+ red = r;
|
|
|
+ green = g;
|
|
|
+ blue = b;
|
|
|
+ }
|
|
|
+
|
|
|
+ public final float getAmbientRed()
|
|
|
+ {
|
|
|
+ return red;
|
|
|
+ }
|
|
|
+
|
|
|
+ public final float getAmbientGreen()
|
|
|
+ {
|
|
|
+ return green;
|
|
|
+ }
|
|
|
+
|
|
|
+ public final float getAmbientBlue()
|
|
|
+ {
|
|
|
+ return blue;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Light getLight(int index)
|
|
|
+ {
|
|
|
+ return lights[index];
|
|
|
+ }
|
|
|
}
|