Exemplo n.º 1
0
 public void interact(IActor actor)
 {
     if (canInteract(actor)) {
         ICommand command = new PickUpCommand(actor, item);
         command.execute();
     }
 }
Exemplo n.º 2
0
    public Command HandleInput()
    {
        if (Input.GetAxis("Jump") != 0)
        {
            // Significa que estoy queriendo saltar.
            CmdJump = new JumpCommand();
            return(CmdJump);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            CmdCrouch = new CrouchCommand();
            return(CmdCrouch);
        }

        if (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)
        {
            CmdIdle = new IdleCommand();
            return(CmdIdle);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            CmdPickUp = new PickUpCommand();
            return(CmdPickUp);
        }

        if (((Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)))
        {
            CmdMove = new MoveCommand();
            MoveCommand.rotation    = Input.GetAxis("Horizontal");
            MoveCommand.translation = Input.GetAxis("Vertical");
            return(CmdMove);
        }

        return(null);       // Si presiono algo que no sea lo que esta arriba GG.
    }
Exemplo n.º 3
0
        private void BeginCommand(GameCommand gameCommand)
        {
            // Figure out what to do.
            FrameCommand command = null;

            switch (gameCommand)
            {
            case GameCommand.Up:
                // Started accelerating upwards, update directions if something changed.
                AddAccelerationDirection(Directions.Up);
                break;

            case GameCommand.Down:
                // Started accelerating downwards, update directions if something changed.
                AddAccelerationDirection(Directions.Down);
                break;

            case GameCommand.Left:
                // Started accelerating leftwards, update directions if something changed.
                AddAccelerationDirection(Directions.Left);
                break;

            case GameCommand.Right:
                // Started accelerating rightwards, update directions if something changed.
                AddAccelerationDirection(Directions.Right);
                break;

            case GameCommand.Rotate:
                // Rotation changed and we should send the new target rotation.
                command = new PlayerInputCommand(
                    PlayerInputCommand.PlayerInputCommandType.Rotate,
                    new Vector2(_targetRotation, 0));
                break;

            case GameCommand.Accelerate:
                // Acceleration vector changed and we should send the new one.
                command = new PlayerInputCommand(
                    PlayerInputCommand.PlayerInputCommandType.Accelerate,
                    _accelerationVector);
                break;

            case GameCommand.Stabilize:
                // Enable stabilizers if not toggling.
                if (!Settings.Instance.StabilizeToggles && !_stabilizing)
                {
                    command      = new PlayerInputCommand(PlayerInputCommand.PlayerInputCommandType.BeginStabilizing);
                    _stabilizing = true;
                }
                break;

            case GameCommand.Shield:
                // Enable shield if not toggling.
                if (!Settings.Instance.ShieldToggles && !_shielding)
                {
                    command    = new PlayerInputCommand(PlayerInputCommand.PlayerInputCommandType.BeginShielding);
                    _shielding = true;
                }
                break;

            case GameCommand.ZoomIn:
                // Zoom camera in.
                if (IsConnected)
                {
                    _game.Client.GetSystem <CameraSystem>().ZoomIn();
                }
                break;

            case GameCommand.ZoomOut:
                // Zoom camera out.
                if (IsConnected)
                {
                    _game.Client.GetSystem <CameraSystem>().ZoomOut();
                }
                break;

            case GameCommand.Shoot:
                // Shoot.
                if (!_shooting)
                {
                    command   = new PlayerInputCommand(PlayerInputCommand.PlayerInputCommandType.BeginShooting);
                    _shooting = true;
                }
                break;

            case GameCommand.Use:
                // TODO
                break;

            case GameCommand.PickUp:
                // Pick up nearby items.
                command = new PickUpCommand();
                break;

            case GameCommand.Back:
                // TODO
                break;

            case GameCommand.Menu:
                // TODO
                break;

            case GameCommand.Inventory:
                // TODO
                break;

            case GameCommand.Character:
                // TODO
                break;

            case GameCommand.ToggleGraphs:
                // Toggle performance and network graph display.
                _game.GraphsVisible = !_game.GraphsVisible;
                break;

            case GameCommand.Console:
                // Toggle console.
                _game.GameConsole.IsOpen = !_game.GameConsole.IsOpen;
                break;

            case GameCommand.TestCommand:
                //Testing time

                /*
                 * var move = new MoveCamera
                 * {
                 *  Player = 0,
                 *  Position = new List<MoveCamera.Positions>(),
                 *  Return = true,
                 *  ReturnSpeed = 10
                 * };
                 * var positions = new MoveCamera.Positions {Speed = 10, Zoom = 0.3f};
                 * move.Position.Add(positions);
                 * positions = new MoveCamera.Positions {Destination = new FarPosition(51000, 49000), Speed = 10};
                 * move.Position.Add(positions);
                 * move.Position.Add(
                 *  new MoveCamera.Positions {Destination = new FarPosition(51000, 49000), Speed = 100, Zoom = 0.7f});
                 * _game.Client.GetSystem<CameraMovementSystem>().Move(move);
                 */
                break;
            }

            // If we did something, push it.
            if (command != null && IsConnected && !_game.Client.Paused && !_game.GameConsole.IsOpen)
            {
                _game.Client.Controller.PushLocalCommand(command);
            }
        }