1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package me.hammerle.supersnuvi.entity.components.ai;
- import me.hammerle.supersnuvi.entity.Entity;
- import me.hammerle.supersnuvi.tiles.Location;
- import me.hammerle.supersnuvi.util.Face;
- public class WalkController extends Controller
- {
- private float motion;
-
- public WalkController(Entity ent, float motion)
- {
- super(ent);
- this.motion = motion;
- }
- @Override
- public void tick()
- {
- if(ent.getHealth().isDead())
- {
- return;
- }
- ent.setMotionX(motion);
- }
- /*@Override
- public void onCollideWithEntity(Entity ent, Face face)
- {
- switchDirection(face);
- }
- @Override
- public void onCollideWithTile(Location loc, Face face)
- {
- switchDirection(face);
- }*/
-
- private void switchDirection(Face face)
- {
- if(face == Face.LEFT)
- {
- motion = -Math.abs(motion);
- }
- else if(face == Face.RIGHT)
- {
- motion = Math.abs(motion);
- }
- }
- }
|