created World Objects + updated some gameobjects to it.
parent
22c4518675
commit
d713bd69d5
|
|
@ -3,19 +3,16 @@ package xyz.valnet.hadean.gameobjects;
|
|||
import xyz.valnet.engine.graphics.Drawing;
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.hadean.Layers;
|
||||
import xyz.valnet.hadean.Tile;
|
||||
import xyz.valnet.hadean.util.Action;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
|
||||
public class Log extends GameObject implements ITileThing, ISelectable, IHaulable {
|
||||
public class Log extends WorldObject implements ITileThing, ISelectable, IHaulable {
|
||||
|
||||
private Camera camera;
|
||||
private Terrain terrain;
|
||||
|
||||
private int x, y;
|
||||
|
||||
private boolean haul = false;
|
||||
|
||||
public Log(int x, int y) {
|
||||
|
|
@ -86,22 +83,22 @@ public class Log extends GameObject implements ITileThing, ISelectable, IHaulabl
|
|||
@Override
|
||||
public Vector2i[] getWorablePositions() {
|
||||
return new Vector2i[] {
|
||||
new Vector2i(x + 1, y),
|
||||
new Vector2i(x - 1, y),
|
||||
new Vector2i(x, y + 1),
|
||||
new Vector2i(x, y - 1)
|
||||
new Vector2i((int)x + 1, (int)y),
|
||||
new Vector2i((int)x - 1, (int)y),
|
||||
new Vector2i((int)x, (int)y + 1),
|
||||
new Vector2i((int)x, (int)y - 1)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2i getLocation() {
|
||||
return new Vector2i(x, y);
|
||||
return new Vector2i((int)x, (int)y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Log take() {
|
||||
haul = false;
|
||||
Tile tile = terrain.getTile(x, y);
|
||||
Tile tile = terrain.getTile((int)x, (int)y);
|
||||
tile.remove(this);
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import xyz.valnet.engine.graphics.Drawing;
|
|||
import xyz.valnet.engine.math.Vector2f;
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.engine.shaders.SimpleShader;
|
||||
import xyz.valnet.hadean.Tile;
|
||||
import xyz.valnet.hadean.pathfinding.AStarPathfinder;
|
||||
|
|
@ -24,12 +23,10 @@ import xyz.valnet.hadean.pathfinding.Path;
|
|||
import xyz.valnet.hadean.util.Action;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
|
||||
public class Pawn extends GameObject implements ISelectable {
|
||||
public class Pawn extends WorldObject implements ISelectable {
|
||||
|
||||
private IHaulable carrying = null;
|
||||
|
||||
private float x = 0.5f + (int)(Math.random() * Terrain.WORLD_SIZE), y = 0.5f + (int)(Math.random() * Terrain.WORLD_SIZE);
|
||||
|
||||
private float counter = 0;
|
||||
|
||||
private Path path;
|
||||
|
|
@ -47,6 +44,8 @@ public class Pawn extends GameObject implements ISelectable {
|
|||
camera = get(Camera.class);
|
||||
terrain = get(Terrain.class);
|
||||
pathfinder = new AStarPathfinder(terrain);
|
||||
x = 0.5f + (int)(Math.random() * Terrain.WORLD_SIZE);
|
||||
y = 0.5f + (int)(Math.random() * Terrain.WORLD_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ import xyz.valnet.hadean.Tile;
|
|||
import xyz.valnet.hadean.util.Action;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
|
||||
public class Stockpile extends GameObject implements ITileThing, ISelectable {
|
||||
public class Stockpile extends WorldObject implements ITileThing, ISelectable {
|
||||
|
||||
private int x, y;
|
||||
private Camera camera;
|
||||
private Terrain terrain;
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ public class Stockpile extends GameObject implements ITileThing, ISelectable {
|
|||
}
|
||||
|
||||
public Tile getTile() {
|
||||
return terrain.getTile(x, y);
|
||||
return terrain.getTile((int)x, (int)y);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ package xyz.valnet.hadean.gameobjects;
|
|||
import xyz.valnet.engine.graphics.Drawing;
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
import xyz.valnet.hadean.Layers;
|
||||
import xyz.valnet.hadean.util.Action;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
|
||||
public class Tree extends GameObject implements ITileThing, ISelectable, IWorkable {
|
||||
public class Tree extends WorldObject implements ITileThing, ISelectable, IWorkable {
|
||||
private Camera camera;
|
||||
|
||||
private boolean chopFlag = false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package xyz.valnet.hadean.gameobjects;
|
||||
|
||||
import xyz.valnet.engine.scenegraph.GameObject;
|
||||
|
||||
public class WorldObject extends GameObject {
|
||||
|
||||
protected float x;
|
||||
protected float y;
|
||||
|
||||
}
|
||||
|
|
@ -29,17 +29,11 @@ import xyz.valnet.hadean.gameobjects.tabs.MenuTab;
|
|||
|
||||
public class GameScene extends SceneGraph {
|
||||
|
||||
// generic
|
||||
// private List<IRenderable> renderables = new ArrayList<IRenderable>();
|
||||
|
||||
|
||||
// specific
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void construct() {
|
||||
|
||||
objects.add(new Terrain());
|
||||
|
||||
for(int i = 0; i < 5; i ++) {
|
||||
objects.add(new Pawn());
|
||||
}
|
||||
|
|
@ -52,6 +46,4 @@ public class GameScene extends SceneGraph {
|
|||
objects.add(new MenuTab());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue