Improved berserker AI.
This commit is contained in:
parent
db9af3fd05
commit
f9668d4333
@ -5,6 +5,7 @@ import com.saltosion.gladiator.components.CCombat;
|
|||||||
import com.saltosion.gladiator.components.CPhysics;
|
import com.saltosion.gladiator.components.CPhysics;
|
||||||
import com.saltosion.gladiator.listeners.AIListener;
|
import com.saltosion.gladiator.listeners.AIListener;
|
||||||
import com.saltosion.gladiator.util.Direction;
|
import com.saltosion.gladiator.util.Direction;
|
||||||
|
import com.saltosion.gladiator.util.Log;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class BerserkerAI implements AIListener {
|
public class BerserkerAI implements AIListener {
|
||||||
@ -41,8 +42,8 @@ public class BerserkerAI implements AIListener {
|
|||||||
c0.inputs.put(Direction.LEFT, false);
|
c0.inputs.put(Direction.LEFT, false);
|
||||||
c0.inputs.put(Direction.UP, false);
|
c0.inputs.put(Direction.UP, false);
|
||||||
c0.inputs.put(Direction.DOWN, false);
|
c0.inputs.put(Direction.DOWN, false);
|
||||||
if (dist < c0.getSwingSize().x) {
|
if (dist < c0.getSwingSize().x + c0.getSwingSize().y) {
|
||||||
if (Math.random() < 0.5) {
|
if (Math.random() < 0.8) {
|
||||||
switch ((int) Math.ceil(Math.random() * 4)) {
|
switch ((int) Math.ceil(Math.random() * 4)) {
|
||||||
default:
|
default:
|
||||||
case 1:
|
case 1:
|
||||||
@ -58,16 +59,21 @@ public class BerserkerAI implements AIListener {
|
|||||||
c0.inputs.put(Direction.DOWN, true);
|
c0.inputs.put(Direction.DOWN, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (p0.getPosition().x + p0.getSize().x / 3 < p1.getPosition().x - p1.getSize().x / 3) {
|
} else {
|
||||||
|
if (p0.getPosition().x + p0.getSize().x / 3 < p1.getPosition().x - p1.getSize().x / 3) {
|
||||||
c0.inputs.put(Direction.RIGHT, true);
|
c0.inputs.put(Direction.RIGHT, true);
|
||||||
} else if (p0.getPosition().x - p0.getSize().x / 3 > p1.getPosition().x + p1.getSize().x / 3) {
|
} else if (p0.getPosition().x - p0.getSize().x / 3 > p1.getPosition().x + p1.getSize().x / 3) {
|
||||||
c0.inputs.put(Direction.LEFT, true);
|
c0.inputs.put(Direction.LEFT, true);
|
||||||
} else if (p0.getPosition().y < p0.getPosition().y) {
|
}
|
||||||
|
if (p0.getPosition().y < p1.getPosition().y) {
|
||||||
|
Log.info("asd");
|
||||||
c0.inputs.put(Direction.UP, true);
|
c0.inputs.put(Direction.UP, true);
|
||||||
} else if (p0.getPosition().y > p0.getPosition().y) {
|
} else if (p0.getPosition().y > p1.getPosition().y) {
|
||||||
|
Log.info("asd");
|
||||||
c0.inputs.put(Direction.DOWN, true);
|
c0.inputs.put(Direction.DOWN, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user