public override void update(GameTime gameTime) { if (!started) { return; } Domain.Clean(); // Updates player names and icons if player is added to remote space on server int clientInDomain = 0; Domain.ForMatchingEntities <Sprite, Transform>((entity) => { clientInDomain++; }); var currentLives = lifeController.Lives; foreach (Entity icon in playerIcons) { icon.Delete(); } foreach (Entity playerName in playerNames) { playerName.Delete(); } foreach (Entity score in playerScores) { score.Delete(); } playerScores.Clear(); playerIcons.Clear(); playerNames.Clear(); var players = Connection.Lobby.Players; foreach (var player in players) { var lives = lifeController.GetClientLives(player.Id); playerIcons.Add(EntityUtility.CreateIcon(Domain, (int)player.Id)); playerNames.Add(EntityUtility.CreateMessage(Domain, player.Name, 0, 0, 16, origin: TextOrigin.Left)); playerScores.Add(EntityUtility.CreateMessage(Domain, lives.ToString(), 0, 0, 16, origin: TextOrigin.Left)); } Display(); }
public override void update(GameTime gameTime) { // Clearing domain domain.Clean(); // Updates chat if new message is added to remote space on server int messageInDomain = 0; domain.ForMatchingEntities <Text, Transform>((entity) => { messageInDomain++; }); lock (messages) { if (messageInDomain < messages.Count) { domain.ForMatchingEntities <Text, Transform>((entity) => { entity.Delete(); }); domain.ForMatchingEntities <Sprite, Transform>((entity) => { if (!(entity == ChatBox)) { entity.Delete(); } }); int maxDisplayedMesseges = 15; var LastMessages = messages.Skip(Math.Max(0, messages.Count() - maxDisplayedMesseges)).Take(maxDisplayedMesseges); foreach (var message in messages) { EntityUtility.CreateIcon(domain, (int)message.Sender.Id); EntityUtility.CreateMessage(domain, (string)message.Message, 0, 0, 14, origin: TextOrigin.Left); } } } // Display chat (DisplayChat ? new Action(Display) : Hide)(); }