예제 #1
0
        private void GameServer_NewClient(int clientId, string username, bool isReady)
        {
            if (GameServer.Instance.Clients.GetClientById(clientId) == null)
            {
                var me = GameServer.Instance.Clients.Me;
                if (username == me.Username)
                {
                    var clientUsernames = GameServer.Instance.Clients.Select(c => c.Username).ToList();

                    if (clientUsernames.Contains(me.Username))
                    {
                        var concat = 1;
                        while (clientUsernames.Contains(me.Username + concat))
                        {
                            concat++;
                        }

                        me.Username += concat;
                    }
                }

                var client = new Client(clientId)
                {
                    Username = username,
                    IsReady = isReady
                };

                GameServer.Instance.GameManager.AddClient(client);
            }
        }
예제 #2
0
 public void AddClient(Client client)
 {
     GameServer.Instance.Clients.AddClient(client);
 }