Esempio n. 1
0
    public override void Execute(CommandParameter _parameter)
    {
        base.Execute(_parameter);
        MoveCommandParameter param = (MoveCommandParameter)_parameter;

        switch (param.Direction)
        {
        case Direction.LEFT:
            param.Player.MoveLeft();
            break;

        case Direction.RIGHT:
            param.Player.MoveRight();
            break;
        }
    }
Esempio n. 2
0
 protected override void OnPressed(Collider2D _collider)
 {
     base.OnPressed(_collider);
     if (_collider == m_leftButton.GetComponent <Collider2D>())
     {
         MoveCommand          command = new MoveCommand();
         MoveCommandParameter param   = new MoveCommandParameter(MoveCommand.Direction.LEFT, m_player);
         CommandManager.instance.AddCommand(command, param);
     }
     if (_collider == m_rightButton.GetComponent <Collider2D>())
     {
         MoveCommand          command = new MoveCommand();
         MoveCommandParameter param   = new MoveCommandParameter(MoveCommand.Direction.RIGHT, m_player);
         CommandManager.instance.AddCommand(command, param);
     }
 }
Esempio n. 3
0
 bool CheckInput(string _input)
 {
     if (Input.GetKeyDown(_input))
     {
         MoveCommand          command = new MoveCommand();
         MoveCommandParameter param;
         if (_input == m_inputRight)
         {
             param = new MoveCommandParameter(MoveCommand.Direction.RIGHT, m_player);
         }
         else
         {
             param = new MoveCommandParameter(MoveCommand.Direction.LEFT, m_player);
         }
         CommandManager.instance.AddCommand(command, param);
         return(true);
     }
     else if (Input.GetKeyUp(_input))
     {
         return(true);
     }
     return(false);
 }