Esempio n. 1
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--;
        }
Esempio n. 2
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 });
        }
Esempio n. 3
0
    private void Streamer_GuestConnected(object sender, Parsec.ParsecGuest guest)
    {
        int iPlayer = GetFreePlayer();

        if (iPlayer == 0)
        {
            return;
        }
        SpawnPlayer(iPlayer, guest);
    }
Esempio n. 4
0
 public void SpawnPlayer(int player, Parsec.ParsecGuest guest)
 {
     if (m_Players == null)
     {
         return;
     }
     if (player >= 0 && player < m_Players.Length)
     {
         m_Players[player]                 = gameObject.AddComponent <PlayerManager>();
         m_Players[player].m_Instance      = Instantiate(m_PlayerObjectPrefab, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)) as GameObject;
         m_Players[player].m_PlayerNumber  = player;
         m_Players[player].m_AssignedGuest = guest;
         m_Players[player].Setup(null, null, null);
     }
 }
Esempio n. 5
0
    private void Streamer_GuestConnected(object sender, Parsec.ParsecGuest guest)
    {
        int iPlayer = GetFreePlayer();

        if (iPlayer == 0)
        {
            return;
        }
        CustomController csController = ReInput.controllers.CreateCustomController(0, "Parsec_" + guest.id);
        CustomController csKeyboard   = ReInput.controllers.CreateCustomController(1, "Parsec_" + guest.id);
        CustomController csMouse      = ReInput.controllers.CreateCustomController(2, "Parsec_" + guest.id);

        ParsecUnity.ParsecRewiredInput.AssignCustomControllerToUser(guest, csController);
        ParsecUnity.ParsecRewiredInput.AssignKeyboardControllerToUser(guest, csKeyboard);
        SpawnPlayer(iPlayer, guest, csController, csKeyboard, csMouse);
    }
Esempio n. 6
0
 private void Streamer_GuestDisconnected(object sender, Parsec.ParsecGuest guest)
 {
     if (m_Players == null)
     {
         return;
     }
     for (int i = 0; i < m_Players.Length; i++)
     {
         if (m_Players[i] != null && (m_Players[i].m_AssignedGuest.id == guest.id))
         {
             m_Players[i].BreakDown();
             Destroy(m_Players[i]);
             m_Players[i] = null;
         }
     }
 }
Esempio n. 7
0
 public InputDeviceCollection AddGuest(Parsec.ParsecGuest guest)
 {
     guests[guest.id] = new InputDeviceCollection();
     return(guests[guest.id]);
 }
Esempio n. 8
0
 private void Parsec_MouseMotion(object sender, Parsec.ParsecGuest guest, Parsec.ParsecMouseMotionMessage mouseMotion)
 {
     // Debug.Log($"Guest {guest.id} moved mouse {mouseMotion.x}, {mouseMotion.y}");
 }
Esempio n. 9
0
 private void Parsec_KeyboardInput(object sender, Parsec.ParsecGuest guest, Parsec.ParsecKeyboardMessage keyboard)
 {
     Debug.Log($"Guest {guest.id} {(keyboard.pressed ? "pressed" : "released")} key {keyboard.code}");
 }
Esempio n. 10
0
 private void Parsec_MouseButton(object sender, Parsec.ParsecGuest guest, Parsec.ParsecMouseButtonMessage mouseButton)
 {
     Debug.Log($"Guest {guest.id} {(mouseButton.pressed ? "clicked" : "released")} key {mouseButton.button}");
 }