コード例 #1
0
ファイル: LobbyUI.cs プロジェクト: Neebzan/Bachelor-project
    public void AddLobbyEntry(ClientConnectedPlayer player)
    {
        LobbyEntry lobbyEntry = Instantiate(LobbyEntryPrefab, LobbyEntriesPanel.transform).GetComponent <LobbyEntry>();

        lobbyEntry.Username        = player.Username;
        player.PlayerPingUpdated  += lobbyEntry.OnConnectedPlayerPingUpdated;
        player.PlayerReady        += lobbyEntry.OnConnectedPlayerReadyUpdated;
        player.PlayerDisconnected += lobbyEntry.OnPlayerDisconnected;
    }
コード例 #2
0
ファイル: LobbyPadService.cs プロジェクト: scoizzle/LobbyPad
 public bool TryUpdate(LobbyEntry entry)
 {
     try {
         return(entries.Update(entry));
     }
     catch {
         return(false);
     }
 }
コード例 #3
0
ファイル: LobbyUI.cs プロジェクト: Neebzan/Bachelor-project
    public void AddLobbyEntry(Client client)
    {
        LobbyEntry scoreboardEntry = Instantiate(LobbyEntryPrefab, LobbyEntriesPanel.transform).GetComponent <LobbyEntry>();

        scoreboardEntry.Username     = client.Username;
        client.PlayerLatencyUpdated += scoreboardEntry.OnClientLatencyUpdated;
        client.PlayerReadyUpdated   += scoreboardEntry.OnClientReadyUpdated;
        client.PlayerDisconnected   += scoreboardEntry.OnPlayerDisconnected;
    }
コード例 #4
0
ファイル: LobbyPadService.cs プロジェクト: scoizzle/LobbyPad
 public bool TryRegister(LobbyEntry entry)
 {
     try {
         entries.Insert(new BsonValue(entry.Id), entry);
         return(true);
     }
     catch {
         return(false);
     }
 }
コード例 #5
0
ファイル: LobbyPadService.cs プロジェクト: scoizzle/LobbyPad
 public bool TryGetById(Guid id, out LobbyEntry entry)
 {
     try {
         entry = entries.FindById(new BsonValue(id));
         return(true);
     }
     catch {
         entry = default;
         return(false);
     }
 }
コード例 #6
0
    void OnPlayerConnect(NetworkPlayer player)
    {
        GameObject entryGameObject = Instantiate(playerEntryPrefab) as GameObject;
        LobbyEntry lobbyEntry      = entryGameObject.GetComponent <LobbyEntry>();

        lobbyEntry.transform.SetParent(transform);

        lobbyEntry.SetPlayer(player);
        lobbyEntry.UpdateEntry();

        lobbyEntries.Add(player, lobbyEntry);
    }
コード例 #7
0
ファイル: HomeController.cs プロジェクト: scoizzle/LobbyPad
        public IActionResult Register(string guid, string name, string phoneNumber, int partySize, string specialRequests)
        {
            if (Guid.TryParse(guid, out var id) && !string.IsNullOrWhiteSpace(name) && name.Length != 0)
            {
                var entry = new LobbyEntry {
                    Id              = id,
                    Name            = name,
                    PhoneNumber     = phoneNumber,
                    PartySize       = partySize,
                    SpecialRequests = specialRequests?.Trim() ?? string.Empty,
                    CreationTime    = DateTime.UtcNow,
                    Status          = LobbyEntryStatus.Waiting
                };

                _lobbyPad.TryRegister(entry);
            }

            return(RedirectToAction("Index"));
        }
コード例 #8
0
    private void AddLobbyEntry(string lobbyId, LobbyData lobbyData)
    {
        GameObject obj = Instantiate(lobbyEntryPrefab);

        obj.transform.parent = lobbyList.transform;

        LobbyEntry lobbyEntry = obj.GetComponent <LobbyEntry>();

        lobbyEntry.lobbyName.text   = lobbyData.lobbyName;
        lobbyEntry.lobbyStatus.text = lobbyData.lobbyStatus;
        lobbyEntry.playerCount.text = lobbyData.players.Count + "/" + lobbyData.maxPlayers;

        if (lobbyData.lobbyStatus == "Waiting")
        {
            lobbyEntry.OnJoin = () => { OnJoinLobby(lobbyId); };
        }
        else
        {
            lobbyEntry.joinButton.SetActive(false);
        }
    }