private void sendPlayersUpdateClient() { if (!gameref.network.isClient()) { return; } List <Being> localList = new List <Being>(); foreach (Being player in gameref.players.Values) { if (player.isLocal) { localList.Add(player); } } NetOutgoingMessage msg = client.CreateMessage(); msg.Write((int)MessageType.PlayersUpdateClient); msg.Write((int)localList.Count); foreach (Being player in localList) { BeingNetworkState.writeState(msg, player); } client.SendMessage(msg, NetDeliveryMethod.ReliableUnordered); }
private void sendEnemiesUpdate() { NetOutgoingMessage stateUpdate = server.CreateMessage(); stateUpdate.Write((int)MessageType.EnemiesUpdate); stateUpdate.Write((int)gameref.spawnManager.enemies.Count); foreach (Enemy enemy in gameref.spawnManager.enemies.Values) { BeingNetworkState.writeState(stateUpdate, enemy); } serverSendToAllUnordered(stateUpdate); }
public void sendPlayersUpdateServer() { NetOutgoingMessage stateUpdate = server.CreateMessage(); stateUpdate.Write((int)MessageType.PlayersUpdate); stateUpdate.Write((int)gameref.players.Count); foreach (Being player in gameref.players.Values) { BeingNetworkState.writeState(stateUpdate, player); } serverSendToAllUnordered(stateUpdate); }