示例#1
0
 public bool AddPlayer(Player player)
 {
     if (Game.Players.Contains(player.Id))
     {
         _participants.Add(player);
         player.MessageRecieved += OnMessageRecieved;
         player.NameChanged += OnNameChanged;
         return true;
     }
     return false;
 }
示例#2
0
 public void RemovePlayer(Player player)
 {
     _participants.Remove(player);
 }
示例#3
0
 private void OnNameChanged(Player player, string newName)
 {
 }
示例#4
0
        private void ProcessMessage(Player player, string input)
        {
            var receivedEvent = JsonConvert.DeserializeObject<EventWrapper>(input);

            using (var db = MvcApplication.Store.OpenSession())
            {
                switch (receivedEvent.EventType)
                {
                    case EventType.Message:
                        var message = JsonConvert.DeserializeObject<MessageEvent>(receivedEvent.EventBody);
                        if (SceneIsActive(message.SceneId))
                        {
                            message.GameId = Game.Id;
                            SendMessage(receivedEvent);
                        }
                        break;
                }

                db.SaveChanges();
            }
        }
示例#5
0
 private void OnMessageRecieved(Player player, string wireMessage)
 {
     ProcessMessage(player, wireMessage);
 }