Beispiel #1
0
        public void Streamer_GuestConnected(object sender, Parsec.ParsecGuest guest)
        {
            int parsecPlayerId = _parsecPlayerIdCount;

            _parsecPlayerIdCount++;
            if (rewiredPlayers.Count == 0)
            {
                Debug.LogWarning("ParsecManager : No rewired players to assign");
                return;
            }

            string           rewiredPlayerId      = _GetAvailableRewiredPlayer();
            CustomController csControllerJoystick = ReInput.controllers.CreateCustomController(0, "Parsec_" + guest.id);
            CustomController csControllerKeyboard = ReInput.controllers.CreateCustomController(1, "Parsec_" + guest.id);
            CustomController csControllerMouse    = ReInput.controllers.CreateCustomController(2, "Parsec_" + guest.id);

            ParsecInput.AssignGuestToPlayer(guest, parsecPlayerId);
            Player rewiredPlayer = ReInput.players.GetPlayer(rewiredPlayerId);

            ParsecRewiredInput.AssignCustomControllerToUser(guest, csControllerJoystick);
            ParsecRewiredInput.AssignKeyboardControllerToUser(guest, csControllerKeyboard);
            ParsecRewiredInput.AssignMouseControllerToUser(guest, csControllerMouse);
            rewiredPlayer.controllers.AddController(csControllerJoystick, true);
            rewiredPlayer.controllers.AddController(csControllerKeyboard, true);
            rewiredPlayer.controllers.AddController(csControllerMouse, true);
            _rewiredPlayerByGuestIds.Add(guest.id, rewiredPlayerId);
            _guestIdByRewiredPlayer.Add(rewiredPlayerId, guest.id);
            _customControllersByGuestIds.Add(guest.id, new CustomController[] { csControllerJoystick, csControllerKeyboard, csControllerMouse });
        }
Beispiel #2
0
        public void Streamer_GuestDisconnected(object sender, Parsec.ParsecGuest guest)
        {
            Debug.Log("A guest has disconnected.");
            guest.state = Parsec.ParsecGuestState.GUEST_DISCONNECTED;

            ParsecRewiredInput.UnassignGuest(guest);
            ParsecInput.UnassignGuest(guest);

            if (_rewiredPlayerByGuestIds.ContainsKey(guest.id))
            {
                string rewiredPlayerId = _rewiredPlayerByGuestIds[guest.id];
                if (_customControllersByGuestIds.ContainsKey(guest.id))
                {
                    Player rewiredPlayer = ReInput.players.GetPlayer(rewiredPlayerId);
                    foreach (CustomController controller in _customControllersByGuestIds[guest.id])
                    {
                        rewiredPlayer.controllers.RemoveController <CustomController>(controller.id);
                        ReInput.controllers.DestroyCustomController(controller);
                    }
                }

                _rewiredPlayerByGuestIds.Remove(guest.id);
                _customControllersByGuestIds.Remove(guest.id);
                _guestIdByRewiredPlayer.Remove(rewiredPlayerId);
            }

            _parsecPlayerIdCount--;
        }
Beispiel #3
0
 public void Setup(CustomController controller, CustomController keyboard, CustomController mouse)
 {
     ParsecInput.AssignGuestToPlayer(m_AssignedGuest, m_PlayerNumber);
     m_Movement = m_Instance.GetComponent <PlayerMovement>();
     if (m_Movement != null)
     {
         if (controller != null)
         {
             ParsecRewiredInput.AssignCustomControllerToUser(m_AssignedGuest, controller);
         }
         if (keyboard != null)
         {
             ParsecRewiredInput.AssignKeyboardControllerToUser(m_AssignedGuest, keyboard);
         }
         if (mouse != null)
         {
             ParsecRewiredInput.AssignMouseControllerToUser(m_AssignedGuest, mouse);
         }
         m_Movement.player = m_PlayerNumber;
         m_Movement.initReInput(controller, keyboard, mouse);
     }
 }