예제 #1
0
 private void TryToAssignDefaultDevice(UserDevice userDevice)
 {
     if (defaultDevicesExpected == null || defaultDevicesExpected.Count == 0)
     {
         return;
     }
     for (int i = defaultDevicesExpected.Count - 1; i >= 0; i--)
     {
         if (!InputManager.Instance.IsDeviceUsed(userDevice.deviceIndex) && userDevice.deviceType == defaultDevicesExpected[i].deviceType)
         {
             var skin         = characterSkins.GetSkinData(defaultDevicesExpected[i].characterSkinIndex);
             var devotionName = characterNames.GetDevotionName(defaultDevicesExpected[i].devotionNameIndex);
             var spiritName   = characterNames.GetSpiritName(defaultDevicesExpected[i].spiritNameIndex);
             var charToolType = defaultDevicesExpected[i].charToolType;
             if (InputManager.Instance.RegisterPlayer(userDevice.deviceIndex, skin, devotionName, spiritName, charToolType))
             {
                 PlayerSessionData psData = InputManager.Instance.GetPlayerByDevice(userDevice.deviceIndex);
                 charAssembler.CreateCharacter(psData);
                 defaultDevicesExpected.RemoveAt(i);
                 return;
             }
         }
     }
     return;
 }
예제 #2
0
        private PlayerSessionData CreatePlayerWithDevice(int deviceIndex, CharacterSkinData skinData = null, string devotionName = "", string spiritName = "", CharToolType charToolType = CharToolType.None)
        {
            PlayerSessionData playerSessionData = new PlayerSessionData(activePlayers.Count, deviceIndex, gameplayInputManagers[deviceIndex], playerUIInputManagers[deviceIndex]);

            playerSessionData.skin         = skinData;
            playerSessionData.devotionName = devotionName;
            playerSessionData.spiritName   = spiritName;
            playerSessionData.charToolType = charToolType;
            activePlayers.Add(playerSessionData);
            OnPlayerRegistered?.Invoke(playerSessionData);
            return(playerSessionData);
        }
예제 #3
0
 public void RemovePlayer(int playerIndex)
 {
     if (activePlayers.Count > playerIndex)
     {
         var psData = activePlayers[playerIndex];
         activePlayers.RemoveAt(playerIndex);
         OnPlayerRemoved?.Invoke(psData);
         for (int i = playerIndex; i < maxNumberOfPlayers; i++)
         {
             if (i < activePlayers.Count && activePlayers[i] != null)
             {
                 PlayerSessionData pData = activePlayers[i];
                 pData.playerIndex = i;
                 OnPlayerChangedIndex?.Invoke(pData, i + 1);
             }
         }
     }
 }