Beispiel #1
0
 public static TCommand RotateWithVelocityForTime <TCommand>(this ISimpleMovementRules <TCommand> factory, Angle velocity, double time)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.Rotate(velocity, time)
     });
 }
Beispiel #2
0
 public static TCommand MovePathWithVelocity <TCommand>(this ISimpleMovementRules <TCommand> factory, double path, double velocity)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.MoveWithVelocity(path, velocity)
     });
 }
Beispiel #3
0
 public static TCommand Rotate <TCommand>(this ISimpleMovementRules <TCommand> factory, Angle angle)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.RotateWithVelocity(angle, factory.AngularVelocityLimit)
     });
 }
Beispiel #4
0
 public static TCommand RotateAngleWithVelocity <TCommand>(this ISimpleMovementRules <TCommand> factory, Angle angle, Angle velocity)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.RotateWithVelocity(angle, velocity)
     });
 }
Beispiel #5
0
 public static TCommand Move <TCommand>(this ISimpleMovementRules <TCommand> factory, double length)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.MoveWithVelocity(length, factory.LinearVelocityLimit)
     });
 }
Beispiel #6
0
 public static TCommand Stand <TCommand>(this ISimpleMovementRules <TCommand> factory, double time)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.Stand(time)
     });
 }
Beispiel #7
0
 public static Bot <TCommand> CreateSquareWalkingBot <TCommand>(this ISimpleMovementRules <TCommand> factory, int distance)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new Bot <TCommand>(turn =>
                               turn % 2 == 0 ?
                               factory.Move(distance) :
                               factory.Rotate(Angle.HalfPi)
                               ));
 }
Beispiel #8
0
        public static Bot <TCommand> CreateRandomWalkingBot <TCommand>(this ISimpleMovementRules <TCommand> factory, int distance)
            where TCommand : ISimpleMovementCommand, new()
        {
            var random = new Random();

            return(new Bot <TCommand>(turn =>
                                      turn % 2 == 0 ?
                                      factory.Move(distance) :
                                      factory.Rotate(Angle.FromGrad(random.NextDouble() * 360))
                                      ));
        }
Beispiel #9
0
        public static void AddSimpleMovementKeys <TCommand>(this ISimpleMovementRules <TCommand> factory, KeyboardController <TCommand> pool, string controllerId)
            where TCommand : ISimpleMovementCommand, new()
        {
            var dt = 0.1;

            if (controllerId == TwoPlayersId.Left)
            {
                pool.Add(Keys.W, () => new TCommand {
                    SimpleMovement = SimpleMovement.Move(factory.LinearVelocityLimit, dt)
                });
                pool.Add(Keys.S, () => new TCommand {
                    SimpleMovement = SimpleMovement.Move(-factory.LinearVelocityLimit, dt)
                });
                pool.Add(Keys.A, () => new TCommand {
                    SimpleMovement = SimpleMovement.Rotate(factory.AngularVelocityLimit, dt)
                });
                pool.Add(Keys.D, () => new TCommand {
                    SimpleMovement = SimpleMovement.Rotate(-factory.AngularVelocityLimit, dt)
                });
            }

            if (controllerId == TwoPlayersId.Right)
            {
                pool.Add(Keys.I, () => new TCommand {
                    SimpleMovement = SimpleMovement.Move(factory.LinearVelocityLimit, dt)
                });
                pool.Add(Keys.K, () => new TCommand {
                    SimpleMovement = SimpleMovement.Move(-factory.LinearVelocityLimit, dt)
                });
                pool.Add(Keys.J, () => new TCommand {
                    SimpleMovement = SimpleMovement.Rotate(factory.AngularVelocityLimit, dt)
                });
                pool.Add(Keys.L, () => new TCommand {
                    SimpleMovement = SimpleMovement.Rotate(-factory.AngularVelocityLimit, dt)
                });
            }
        }
Beispiel #10
0
 public static Bot <TCommand> CreateStandingBot <TCommand>(this ISimpleMovementRules <TCommand> factory)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new Bot <TCommand>(turn => factory.Stand(1)));
 }
		public SimpleMovementUnit(IActor actor)
		{
			this.actor = actor;
            rules = Compatibility.Check<ISimpleMovementRules>(this, actor.Rules);
            actor.World.Clocks.AddTrigger(new TimerTrigger(ApplyCommand, commandRenewmentRate));
		}
Beispiel #12
0
 public SimpleMovementUnit(IActor actor)
 {
     this.actor = actor;
     rules      = Compatibility.Check <ISimpleMovementRules>(this, actor.Rules);
     actor.World.Clocks.AddTrigger(new TimerTrigger(ApplyCommand, commandRenewmentRate));
 }