예제 #1
0
        internal void NewMessage(PlayerActor player, string message)
        {
            RemotePlayer p;

            connectedPlayers.TryGetValue(player.LastUpdatedBy, out p);
            if (p == null)
            {
                return; //Just In Case
            }
            ConcurrentDictionary <RemotePlayer, List <string> > areamessages;

            _broadcaster.sentMessages.TryGetValue(p.areaname, out areamessages);

            if (areamessages == null)
            {
                Debug.WriteLine("Invalid areaname '{0}' on player", p.areaname);
                return;
            }

            //TODO: Possible race condition on messages list?
            //if NewMessage is called with the same PlayerActor
            //multiple times concurrently ... somehow
            List <string> messages;

            if (areamessages.TryGetValue(p, out messages))
            {
                messages.Add(player.name + ": " + message);
            }
            else
            {
                messages = new List <string>();
                messages.Add(player.name + ": " + message);

                areamessages.TryAdd(p, messages);
            }
            _broadcaster.newMessage = true;
        }
예제 #2
0
 public void NewMessage(PlayerActor p, string message)
 {
     p.LastUpdatedBy = Context.ConnectionId;
     _broadcaster.game.NewMessage(p, message);
 }
예제 #3
0
 public void UpdateModel(PlayerActor player)
 {
     player.LastUpdatedBy = Context.ConnectionId;
     // Update the shape model within our broadcaster
     _broadcaster.game.UpdateShape(player);
 }
예제 #4
0
 public void UpdateBattle(PlayerActor player, BattleAction action)
 {
     player.LastUpdatedBy = Context.ConnectionId;
     _broadcaster.game.UpdateBattle(player, action);
 }
예제 #5
0
 public void SendUpdatedStatus(string connectionId, PlayerActor player)
 {
     _hubContext.Clients.Client(connectionId).updateMyStatus(player.inventory, player.stats);
 }