Пример #1
0
 public void AddOrUpdate(PlayerModel player)
 {
     var existing = players.FirstOrDefault(x => x.id == player.id);
     if (existing == null)
     {
         players.Add(player);
     }
     else
     {
         player.CopyProperties(existing);
     }
 }
Пример #2
0
        private void onFetchComplete(PlayerModel player, SocketKey key)
        {
            if (player == null)
            {
                debug.LogError("Failed Fetching Player", key);
            }
            else
            {
                debug.Log("Player Fetched", key);
                var playerModel = playersModel.GetByClientId(key.clientId);
                //kinda nasty save of the couple properties that need to be saved on the original player model
                //that won't be coming across the wire
                var clientId = playerModel.clientId;
                var token = playerModel.token;
                player.CopyProperties(playerModel);

                playerModel.clientId = clientId;
                playerModel.token = token;
                playerModel.isLocal = true;

                socketService.Disconnect(key.clientId, "auth");
            }
        }