Ejemplo n.º 1
0
    //public int playerId = 0; // The Rewired player id of this character
    //
    //public float moveSpeed = 3.0f;
    //public float bulletSpeed = 15.0f;
    //public GameObject bulletPrefab;
    //
    //private Player player; // The Rewired Player
    //private CharacterController cc;
    //private Vector3 moveVector;
    //private bool fire;
    //
    //void Awake()
    //{
    //    // Get the Rewired Player object for this player and keep it for the duration of the character's lifetime
    //    player = ReInput.players.GetPlayer(playerId);
    //
    //    // Get the character controller
    //    cc = GetComponent<CharacterController>();
    //}
    //
    //void Update()
    //{
    //    GetInput();
    //    ProcessInput();
    //}
    //
    //private void GetInput()
    //{
    //    // Get the input from the Rewired Player. All controllers that the Player owns will contribute, so it doesn't matter
    //    // whether the input is coming from a joystick, the keyboard, mouse, or a custom controller.
    //
    //    moveVector.x = player.GetAxis("Move Horizontal"); // get input by name or action id
    //    moveVector.y = player.GetAxis("Move Vertical");
    //    fire = player.GetButtonDown("Fire");
    //}
    //
    //private void ProcessInput()
    //{
    //    // Process movement
    //    if (moveVector.x != 0.0f || moveVector.y != 0.0f)
    //    {
    //        cc.Move(moveVector * moveSpeed * Time.deltaTime);
    //    }
    //
    //    // Process fire
    //    if (fire)
    //    {
    //        GameObject bullet = (GameObject)Instantiate(bulletPrefab, transform.position + transform.right, transform.rotation);
    //        bullet.rigidbody.AddForce(transform.right * bulletSpeed, ForceMode.VelocityChange);
    //    }
    //}


    static public SinglePlayerInputs GetInputs(bool _p1)
    {
        Log();
        SinglePlayerInputs inputs = new SinglePlayerInputs();
        var playerId = RewiredJoystickAssigner.GetPlayerId(_p1);

        if (playerId < 0)
        {
            return(inputs);
        }
        Player player = ReInput.players.GetPlayer(playerId);

        float h;
        float v;

        float diag_TL_BR = player.GetAxisRaw("Move_Diagonal_TL_BR");
        float diag_TR_BL = player.GetAxisRaw("Move_Diagonal_TR_BL");

        //adjusting because d-pads are sometimes considered as HAT inputs, where the diagonals require their own axis....... I hate this
        if (Mathf.Abs(diag_TL_BR) > 0.1)
        {
            if (diag_TL_BR < 0)
            {
                h = -1f;
                v = 1f;
            }
            else
            {
                h = 1f;
                v = -1f;
            }
        }
        else if (Mathf.Abs(diag_TR_BL) > 0.1)
        {
            if (diag_TR_BL < 0)
            {
                h = 1f;
                v = 1f;
            }
            else
            {
                h = -1f;
                v = -1f;
            }
        }
        else
        {
            h = player.GetAxisRaw("Move_Horizontal");
            v = player.GetAxisRaw("Move_Vertical");
        }
        inputs.JoystickDirection = GetNumpadDirection(h, v, _p1);


        inputs.A = player.GetButton("Button_A");
        inputs.B = player.GetButton("Button_B");
        inputs.C = player.GetButton("Button_C");

        return(inputs);
    }
Ejemplo n.º 2
0
 static public RewiredJoystickAssigner GetAssigner()
 {
     if (assigner == null)
     {
         assigner = new RewiredJoystickAssigner();
     }
     return(assigner);
 }
Ejemplo n.º 3
0
        public override void Update(Inputs _inputs)
        {
            if (_inputs.Common_Inputs.F3)
            {
                Input.InputSources.InputSourceManager.GetInstance().P2_InputSource = new Input.AiPlayer(false, typeof(BasicDelayedAi));
            }
            if (_inputs.Common_Inputs.F2)
            {
                Input.InputSources.InputSourceManager.GetInstance().P1_InputSource = new Input.AiPlayer(true, typeof(BasicAi));
                Input.InputSources.InputSourceManager.GetInstance().P2_InputSource = new Input.AiPlayer(false, typeof(BasicDelayedAi));
            }
            if (_inputs.Common_Inputs.F5)
            {
                Input.InputSources.InputSourceManager.GetInstance().P2_InputSource = new Input.RemotePlayer();
                GameManager.Instance.IsOnlineMatch       = true;
                GameManager.Instance.NetplayState.IsHost = true;
                Communication.InitializeCommuncationSettings(true);
            }
            if (_inputs.Common_Inputs.F6)
            {
                Input.InputSources.InputSourceManager.GetInstance().P2_InputSource = new Input.RemotePlayer();
                GameManager.Instance.IsOnlineMatch       = true;
                GameManager.Instance.NetplayState.IsHost = false;
                Communication.InitializeCommuncationSettings(false);
            }
            if (_inputs.Common_Inputs.F12)
            {
                GameManager.Instance.CreateConfigFile();
            }
#if REWIRED
            if (_inputs.Common_Inputs.F4)
            {
                InputMappingInCourse = true;
                RewiredJoystickAssigner.UnbindPlayerIds();
            }
#endif
            MenuResult res;
#if REWIRED
            if (InputMappingInCourse)
            {
                if (RewiredJoystickAssigner.AssignPlayerIds())
                {
                    InputMappingInCourse = false;
                    System.Threading.Thread.Sleep(300);
                }
                res = MenuResult.Remain;
            }
            else
#endif
            {
                res = UpdateMenu(_inputs.P1_Inputs, _inputs.P2_Inputs);
            }
            HandleMenuResult(res);
        }
Ejemplo n.º 4
0
    public virtual string GetDebugInfo()
    {
        var output = "current state : " + this.GetType().Name + Environment.NewLine;

        if (InputMappingInCourse)
        {
            output += "P1 Joystick : " + RewiredJoystickAssigner.GetInputName(true) + Environment.NewLine;
            output += "P2 Joystick : " + RewiredJoystickAssigner.GetInputName(false) + Environment.NewLine;
        }

        return(output);
    }