// Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.UpArrow))
     {
         ICommand command = new UpCommand(this.transform, this._speed);
         command.Execute();
         CommandManager.Instance.AddCommand(command);
     }
     else if (Input.GetKey(KeyCode.DownArrow))
     {
         ICommand command = new DownCommand(this.transform, this._speed);
         command.Execute();
         CommandManager.Instance.AddCommand(command);
     }
     else if (Input.GetKey(KeyCode.RightArrow))
     {
         ICommand command = new RightCommand(this.transform, this._speed);
         command.Execute();
         CommandManager.Instance.AddCommand(command);
     }
     else if (Input.GetKey(KeyCode.LeftArrow))
     {
         ICommand command = new LeftCommand(this.transform, this._speed);
         command.Execute();
         CommandManager.Instance.AddCommand(command);
     }
     else if (Input.GetKeyDown(KeyCode.Space))
     {
         CommandManager.Instance.Reverse();
     }
 }
    void Update()
    {
        if (Input.GetKey(KeyCode.UpArrow))
        {
            moveUp = new UpCommand(this.transform, _speed);
            moveUp.Execute();
            MoveGameManager.Instance.AddCommand(moveUp);
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            moveDown = new DownCommand(this.transform, _speed);
            moveDown.Execute();
            MoveGameManager.Instance.AddCommand(moveDown);
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            moveLeft = new LeftCommand(this.transform, _speed);
            moveLeft.Execute();
            MoveGameManager.Instance.AddCommand(moveLeft);
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            moveRight = new RightCommand(this.transform, _speed);
            moveRight.Execute();
            MoveGameManager.Instance.AddCommand(moveRight);
        }
    }
        private void OnDownInternal()
        {
            OnDown();

            var handler = Down;

            if (handler != null)
            {
                handler(_button, EventArgs.Empty);
            }

            if (DownCommand != null &&
                DownCommand.CanExecute(DownCommandParameter))
            {
                DownCommand.Execute(DownCommandParameter);
            }
        }
Exemple #4
0
        public void Update()
        {
            gamePadState = GamePad.GetState(PlayerIndex.One);
            ICommand command;
            ICommand idleCommand = new IdleMarioCommand(Game1.Instance);

            if (gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.B) || gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadRight) ||
                gamePadState.IsButtonDown(Buttons.DPadUp) || gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.ThumbSticks.Left.X > 0.5f || gamePadState.ThumbSticks.Left.X < -0.5f ||
                gamePadState.ThumbSticks.Left.Y > 0.5f || gamePadState.ThumbSticks.Left.X < -0.5f || gamePadState.IsButtonDown(Buttons.Back) || gamePadState.IsButtonDown(Buttons.Start))
            {
                if (gamePadState.IsButtonDown(Buttons.A))
                {
                    command = new UpCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.B))
                {
                    command = new FireBallCommand(Game1.Instance);
                    command.Execute();
                    command = new SprintCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadLeft))
                {
                    command = new LeftCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadRight))
                {
                    command = new RightCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadUp))
                {
                    command = new UpCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadDown))
                {
                    command = new DownCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.X > 0.5f)
                {
                    command = new RightCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.X < -0.5f)
                {
                    command = new LeftCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.Y > 0.5f)
                {
                    command = new UpCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.X < -0.5f)
                {
                    command = new DownCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.Back))
                {
                    command = new ExitCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.Start))
                {
                    command = new SwitchControllerCommand();
                    command.Execute();
                }
                if (!gamePadState.IsButtonDown(Buttons.DPadLeft) && !gamePadState.IsButtonDown(Buttons.DPadRight))
                {
                    command = new IdleMarioCommand(Game1.Instance);
                    command.Execute();
                }
            }
            else
            {
                idleCommand.Execute();
            }
        }
Exemple #5
0
 public void visit(DownCommand down)
 {
     down.Execute();
 }