示例#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)
     });
 }
示例#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)
     });
 }
示例#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)
     });
 }
示例#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)
     });
 }
示例#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)
     });
 }
示例#6
0
 public static TCommand Stand <TCommand>(this ISimpleMovementRules <TCommand> factory, double time)
     where TCommand : ISimpleMovementCommand, new()
 {
     return(new TCommand {
         SimpleMovement = SimpleMovement.Stand(time)
     });
 }
示例#7
0
        public void DefineKeyboardControl(IKeyboardController _pool, string controllerId)
        {
            var pool = Compatibility.Check <KeyboardController <MoveAndGripCommand> >(this, _pool);

            this.AddGripKeys(pool, controllerId);
            this.AddSimpleMovementKeys(pool, controllerId);
            pool.StopCommand = () => new MoveAndGripCommand {
                SimpleMovement = SimpleMovement.Stand(0.1)
            };
        }
 public UnitResponse ProcessCommand(object _command)
 {
     var command = Compatibility.Check<ISimpleMovementCommand>(this, _command);
     Debugger.Log(DebuggerMessageType.Workflow, "Command accepted in SMUnit");
     var c = command.SimpleMovement;
     if (c == null)
     {
         currentMovement = null;
         return UnitResponse.Denied();
     }
     currentMovement = c;
     ApplyCommand(actor.World.Clocks.CurrentTime);
     return UnitResponse.Accepted(command.SimpleMovement.Duration);
 }
示例#9
0
        public UnitResponse ProcessCommand(object _command)
        {
            var command = Compatibility.Check <ISimpleMovementCommand>(this, _command);

            Debugger.Log("Command accepted in SMUnit");
            var c = command.SimpleMovement;

            if (c == null)
            {
                currentMovement = null;
                return(UnitResponse.Denied());
            }
            currentMovement = c;
            ApplyCommand(actor.World.Clocks.CurrentTime);
            return(UnitResponse.Accepted(command.SimpleMovement.Duration));
        }
示例#10
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)
                });
            }
        }