Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // AI
- public void setTree(Tree tree) {
- this.tree = tree;
- }
- private void chopTrees() throws SuspendExecution {
- while (started) {
- Tree tree = (this.tree != null ? this.tree : unit.getWorld().getNearestTree(new Point(unit.getX(),unit.getY())));
- if (tree == null) {
- unit.stopChopping();
- return;
- }
- moveTo(tree.getPosition());
- if (!chop(tree))
- continue;
- WoodStorage storage = unit.getWorld().getNearestWoodStorage(unit.getPosition());
- Point p1 = storage.getDeliveryPoint();
- Point p2 = storage.getPosition();
- p2.translate(p1.x,p1.y);
- moveTo(p2);
- storeInto(storage);
- if (this.tree != null) {
- this.tree = null;
- unit.stopChopping();
- }
- }
- }
- // Unit
- public void startChopping() {
- unitAI.startAI();
- }
- public void stopChopping() {
- unitAI.stopAI();
- }
- public void chop(Tree tree) {
- unitAI.setTree(tree);
- startChopping();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement