예제 #1
0
        public bool JoinGame(string _matchID, GameObject _player, out int playerIndex)
        {
            playerIndex = -1;

            if (matchIDs.Contains(_matchID) && !CheckPlayer(_player, _matchID))
            {
                for (int i = 0; i < matches.Count; i++)
                {
                    if (matches[i].matchID == _matchID)
                    {
                        if (!matches[i].inMatch && !matches[i].matchFull)
                        {
                            matches[i].players.Add(_player);
                            roomListManager.FillList(matches[i].players.ToArray(), _matchID);

                            _player.GetComponent <PlayerNetwork> ().currentMatch = matches[i];
                            playerIndex = matches[i].players.Count;

                            if (matches[i].players.Count == maxMatchPlayers)
                            {
                                matches[i].matchFull = true;
                            }

                            break;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                Debug.Log("Players in Room: " + roomListManager.roomData[0].roomPlayers.Length);
                Debug.Log($"Match joined");
                return(true);
            }
            else
            {
                Debug.Log($"Match ID does not exist");
                return(false);
            }
        }