Exemple #1
0
 public void HandleInput(AbstractFigure hero, Key input)
 {
     if (input == Key.Q)
     {
         hero.ChangeState(new IdleState());
     }
 }
        public void Update(AbstractFigure hero)
        {
            ICommand command = null;

            switch (input)
            {
            case Key.Left:
                command = new MoveCommand(hero, new Vector(-20, 0));
                break;

            case Key.Up:
                command = new MoveCommand(hero, new Vector(0, -20));
                break;

            case Key.Right:
                command = new MoveCommand(hero, new Vector(20, 0));
                break;

            case Key.Down:
                command = new MoveCommand(hero, new Vector(0, 20));
                break;
            }

            if (command != null)
            {
                command.Execute();
            }
        }
Exemple #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var createWindow = new CreateWindow();

            if (createWindow.ShowDialog() == true)
            {
                var factory = new FigureFactory();

                for (int i = 0; i < createWindow.Count; i++)
                {
                    AbstractFigure figure = null;

                    if (createWindow.Type == FigureType.Circle)
                    {
                        figure = factory.CreateCircle();
                    }
                    else if (createWindow.Type == FigureType.Rectangle)
                    {
                        figure = factory.CreateRectangle();
                    }

                    map.Add(figure);
                }

                UpdateFigures();
            }
        }
 public void HandleInput(AbstractFigure hero, Key input)
 {
     if (input == Key.Up ||
         input == Key.Down ||
         input == Key.Left ||
         input == Key.Right)
     {
         hero.ChangeState(new MovementState(input));
     }
     else if (input == Key.Q)
     {
         hero.ChangeState(new ChangeColorState());
     }
 }
Exemple #5
0
        public void Update(AbstractFigure hero)
        {
            var command = new ChangeColorCommand(hero);

            command.Execute();
        }
 public MoveCommand(AbstractFigure hero, Vector vector)
 {
     this.hero   = hero;
     this.vector = vector;
 }
 public void Add(AbstractFigure part)
 {
     parts.Add(part);
 }
Exemple #8
0
 public void Update(AbstractFigure hero)
 {
 }