public bool CanExecute(object parameter = null) { Tractor.Direction direction = tractor.CurrentDirection; if (direction == Tractor.Direction.Up) { y--; } if (direction == Tractor.Direction.Down) { y++; } if (direction == Tractor.Direction.Left) { x--; } if (direction == Tractor.Direction.Right) { x++; } if (x < 0 || x > map.MapWidth - 1 || y < 0 || y > map.MapHeight - 1) { return(false); } if (map.MapString[x, y] == "B" || map.MapString[x, y] == "X") { return(false); } return(true); }
public void Execute(object parameter = null) { Tractor.Direction direction = tractor.CurrentDirection; x = tractor.X; y = tractor.Y; int speed = 0; if (tractor.IsToolDown) { speed = 1; } else { speed = 2; } if (direction == Tractor.Direction.Up) { y -= speed; } if (direction == Tractor.Direction.Down) { y += speed; } if (direction == Tractor.Direction.Left) { x -= speed; } if (direction == Tractor.Direction.Right) { x += speed; } //Storyboard storyboard = new Storyboard(); //storyboard.Duration = new Duration(TimeSpan.FromSeconds(3.0)); //DoubleAnimationUsingPath rotateAnimation = new DoubleAnimationUsingPath() //{ // // From = 0, // Source = PathAnimationSource.X, // PathGeometry // Duration = storyboard.Duration //}; //Storyboard.SetTarget(rotateAnimation, o.ImageControl); //Storyboard.SetTargetProperty(rotateAnimation, new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)")); //storyboard.Children.Add(rotateAnimation); //Storyboard.SetTarget(rotateAnimation, o.ImageControl); //Storyboard.SetTargetProperty(rotateAnimation, new PropertyPath("(UIElement.RenderTransform).(RotateTransform.Angle)")); //storyboard.Children.Add(rotateAnimation); //storyboard.Begin(); }