示例#1
0
        private void HandleUpdateActivePlayers(NetworkMessage netMsg)
        {
            var playersUpdate = netMsg.ReadMessage <PlayersUpdateMessage>();

            Debug.Log("UPDATE ACTIVE PLAYERS:");
            foreach (var playerData in playersUpdate.Players)
            {
                var existingPlayer = activePlayers.Find(p => p.ID == playerData.ID);
                if (existingPlayer == null)
                {
                    existingPlayer = new NetworkPlayer()
                    {
                        ID            = playerData.ID,
                        Name          = playerData.Name,
                        CharacterType = playerData.CharacterType,
                        IsSelf        = playerData.ID == client.connection.connectionId
                    };
                    existingPlayer.Connection = (existingPlayer.IsSelf) ? client.connection : null;
                    activePlayers.Add(existingPlayer);
                    OnPlayerConnect?.Invoke(existingPlayer);
                }

                // todo, this is dumb
                existingPlayer.Name = playerData.Name;

                existingPlayer.Player.CritterController.transform.SetPositionAndRotation(playerData.Position, playerData.Rotation);

                Debug.Log("PLAYER #" + playerData.ID + " name" + playerData.Name);
            }


            OnActivePlayersUpdated?.Invoke();
        }
示例#2
0
        private void UpdateActivePlayers()
        {
            var message = PlayersUpdateMessage.Create(activePlayers);

            SendMessageToClients(GameMsgType.UpdateActivePlayers, message);

            OnActivePlayersUpdated?.Invoke();
        }
示例#3
0
 private void ForwardOnActivePlayersUpdated()
 {
     OnActivePlayersUpdated?.Invoke();
 }