Beispiel #1
0
        public void ChatLocally(string username, string text)
        {
            var player         = (Player)_state.Actors.Single(act => act.Id == username);
            var playersInRange = WorldUtils.GetActorsInRange(_state, player, player.FieldOfView).OfType <Player>();

            var formattedMessage = $"[{username}]: {text}";

            foreach (var otherPlayers in playersInRange)
            {
                otherPlayers.ChatHistory.Add(formattedMessage);
            }
        }
Beispiel #2
0
        public WorldState GetStateScope(Player player)
        {
            var actorsInRange = WorldUtils.GetActorsInRange(this, player, player.FieldOfView);

            var disconnectedPlayers = Actors.Where(actor => actor is Player ply && !ConnectedPlayers.Contains(ply));

            return(new WorldState
            {
                Maps = Maps,
                Actors = actorsInRange.Except(disconnectedPlayers).ToList()
            });
        }