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
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -23,10 +24,12 @@ public class TestBehaviour extends Component {
|
|||||||
try {
|
try {
|
||||||
System.out.println("Offset: X:" + x + " Y:" + y);
|
System.out.println("Offset: X:" + x + " Y:" + y);
|
||||||
Entity entity = blockContainer.getBlock(new Coordinate(x, y));
|
Entity entity = blockContainer.getBlock(new Coordinate(x, y));
|
||||||
if (entity != null)
|
|
||||||
|
if (entity != null) {
|
||||||
System.out.println(entity.getClass().getSimpleName());
|
System.out.println(entity.getClass().getSimpleName());
|
||||||
|
}
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.yes.yes.entities.machines;
|
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.*;
|
||||||
import com.yes.yes.utils.exceptions.AlreadyExistsException;
|
|
||||||
import javafx.scene.shape.Circle;
|
import javafx.scene.shape.Circle;
|
||||||
|
|
||||||
public class TestMachine extends Entity {
|
public class TestMachine extends Entity {
|
||||||
@@ -13,7 +12,6 @@ public class TestMachine extends Entity {
|
|||||||
|
|
||||||
public TestMachine(BlockContainer blockContainer) {
|
public TestMachine(BlockContainer blockContainer) {
|
||||||
this();
|
this();
|
||||||
this.addBehaviour(new TestBehaviour(this, blockContainer));
|
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.yes.yes.entities.machines;
|
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.BlockContainer;
|
||||||
import com.yes.yes.utils.Entity;
|
import com.yes.yes.utils.Entity;
|
||||||
import javafx.scene.shape.Circle;
|
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
|
|
||||||
public class TestMachine2 extends Entity {
|
public class TestMachine2 extends Entity {
|
||||||
@@ -14,7 +13,6 @@ public class TestMachine2 extends Entity {
|
|||||||
|
|
||||||
public TestMachine2(BlockContainer blockContainer) {
|
public TestMachine2(BlockContainer blockContainer) {
|
||||||
this();
|
this();
|
||||||
this.addBehaviour(new TestBehaviour(this, blockContainer));
|
this.addBehaviour(new PlaceBehaviour(this, blockContainer));
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user