Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Game extends GridContainer {
- private World world = new World(this);
- private HUD hud = new HUD(this);
- public Game() {
- add(world, 0, 0);
- add(hud, 0, 1);
- }
- }
- class World extends GridContainer {
- private final Game game;
- private UnitManager unitManager = new UnitManager();
- private ResourceManager resourceManager = new ResourceManager();
- private LandManager landManager = new LandManager();
- public World(Game game) {
- this.game = game;
- //add land from land manager; logic still being worked out
- }
- }
- class HUD extends GridContainer {
- private final Game game;
- //CurrentLandBox landBox;
- //ActionBox actionBox;
- //...
- public HUD(Game game) {
- this.game = game;
- //add boxes
- }
- }
- class LandManager {
- //similar to UnitManager
- }
- class ResourceManager {
- //similar to UnitManager
- }
- class UnitManager {
- private ArrayList<Explorer> explorers = new ArrayList<>();
- private ArrayList<Inspector> inspectors = new ArrayList<>();
- public void update() {
- explorers.forEach(explorer -> {
- explorer.update();
- });
- inspectors.forEach(inspector -> {
- inspector.update();
- });
- }
- }
- class Land extends VComponent {
- private HashSet<Resource> resources = new HashSet<>();
- private LandType type;
- public void update() {
- //update resources
- }
- public void render(Graphics g) {
- g.setColor(type.color);
- g.fillRect(getX(), getY(), getWidth(), getHeight());
- }
- public static enum LandType {
- UNIDENTIFIED(Color.LIGHT_GREY),
- FLATLAND(Color.GREEN);
- public final Color color;
- LandType(Color color) {
- this.color = color;
- }
- }
- }
- abstract class VComponent {
- private int x, y, width, height;
- protected final void setBounds(int x, int y, int width, int height) { }
- protected final void setSize(int width, int height) { }
- protected final void setLocation(int x, int y) { }
- public int getWidth() {
- return width;
- }
- public int getHeight() {
- return height;
- }
- public int getX() {
- return x;
- }
- public int getY() {
- return y;
- }
- public abstract void update();
- public abstract void render(Graphics g);
- }
- abstract class VContainer extends VComponent {
- protected ArrayList<VComponent> components = new ArrayList<>();
- public void update() {
- components.forEach(comp -> {
- comp.update();
- });
- }
- public final void render(Graphics g) {
- components.forEach(comp -> {
- comp.render(g);
- });
- }
- public abstract void add(VComponent comp);
- }
- class GridContainer extends VContainer {
- public void add(VComponent comp) {
- //default; loops through list, find empty space, placeComponent
- }
- public void add(VComponent comp, int x, int y) {
- add(comp, x, y, 1, 1);
- }
- public void add(VComponent comp, int x, int y, int rowSpan, int colSpan) {
- //logic to find placement
- }
- private void placeComponent(VComponent comp, int x, int y, int rowSpan, int colSpan) {
- //places component in a wrapped instance containing grid properties
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement