mirror of
https://github.com/Stefan-5422/School-Programming-Projekt-022022.git
synced 2026-09-04 00:46:01 +02:00
Update Test Machines;
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.yes.yes.behaviours;
|
||||
|
||||
import com.yes.yes.utils.BlockContainer;
|
||||
import com.yes.yes.utils.Component;
|
||||
import com.yes.yes.utils.Coordinate;
|
||||
import com.yes.yes.utils.Entity;
|
||||
|
||||
public class PlaceBehaviour extends Component {
|
||||
|
||||
public PlaceBehaviour(Entity entity, BlockContainer blockContainer) {
|
||||
super(entity, blockContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize()
|
||||
{
|
||||
for (int x = -1; x < 2; x++) {
|
||||
for (int y = -1; y < 2; y++) {
|
||||
try {
|
||||
Entity entity = blockContainer.getBlock(new Coordinate(x, y));
|
||||
|
||||
if (entity != null) {
|
||||
entity.trigger("placed", parent);
|
||||
System.out.println(entity.getClass().getSimpleName());
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class TestBehaviour extends Component {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,8 +24,10 @@ public class TestBehaviour extends Component {
|
||||
try {
|
||||
System.out.println("Offset: X:" + x + " Y:" + y);
|
||||
Entity entity = blockContainer.getBlock(new Coordinate(x, y));
|
||||
if (entity != null)
|
||||
|
||||
if (entity != null) {
|
||||
System.out.println(entity.getClass().getSimpleName());
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.yes.yes.entities.machines;
|
||||
|
||||
import com.yes.yes.behaviours.TestBehaviour;
|
||||
import com.yes.yes.behaviours.PlaceBehaviour;
|
||||
import com.yes.yes.utils.*;
|
||||
import com.yes.yes.utils.exceptions.AlreadyExistsException;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
public class TestMachine extends Entity {
|
||||
@@ -13,7 +12,6 @@ public class TestMachine extends Entity {
|
||||
|
||||
public TestMachine(BlockContainer blockContainer) {
|
||||
this();
|
||||
this.addBehaviour(new TestBehaviour(this, blockContainer));
|
||||
update();
|
||||
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.yes.yes.entities.machines;
|
||||
|
||||
import com.yes.yes.behaviours.TestBehaviour;
|
||||
import com.yes.yes.behaviours.PlaceBehaviour;
|
||||
import com.yes.yes.utils.BlockContainer;
|
||||
import com.yes.yes.utils.Entity;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
|
||||
public class TestMachine2 extends Entity {
|
||||
@@ -14,7 +13,6 @@ public class TestMachine2 extends Entity {
|
||||
|
||||
public TestMachine2(BlockContainer blockContainer) {
|
||||
this();
|
||||
this.addBehaviour(new TestBehaviour(this, blockContainer));
|
||||
update();
|
||||
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user