private void OnSubmitSubscription(object sender, RoutedEventArgs e) { if (_login.Text.Trim() != "" && _password.Text.Trim() != "") { try { mainWindow.ChannelFactory = new DuplexChannelFactory<IBomberService>(mainWindow, "BomberServiceEndpoint"); mainWindow.Server = mainWindow.ChannelFactory.CreateChannel(); var account = new AccountDC() { Login = _login.Text, Password = _password.Text }; var player = new PlayerDC() { Pseudonym = _pseudonym.Text, PlayerDescription = _playerDescription.Text, }; if (player.Pseudonym.Trim() == "") player.Pseudonym = account.Login; mainWindow.Server.CreateAccount(account, player); mainWindow.IsEnabled = false; } catch { MessageBox.Show("Conexion failure... Please try again later."); } } else { MessageBox.Show("Please choose a login and password before submitting."); } }
public FriendshipRequestPage(MainWindow mainWindow, BomberContracts_WCF.PlayerDC playerDC) { InitializeComponent(); this.mainWindow = mainWindow; this.playerDC = playerDC; var playerDCViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("playerDCViewSource"))); playerDCViewSource.Source = new List<PlayerDC>() { playerDC }; }
private void OnSearchFriends(object sender, RoutedEventArgs e) { PlayerDC refPlayer = new PlayerDC() { Pseudonym = _pseudo.Text, Login = _login.Text }; mainWindow.Server.SearchFriends(refPlayer); }
private void LoadProfil() { profil = new PlayerDC() { NumberOfVictories = mainWindow.Player.NumberOfVictories, Pseudonym = mainWindow.Player.Pseudonym, PlayerDescription = mainWindow.Player.PlayerDescription }; playerDCViewSource.Source = new List<PlayerDC>() { profil }; playerDCViewSource.View.Refresh(); }
public void LoadPlayerInfos(PlayerDC p) { if (p != null) { if (p.PlayerStatus == "Offline") p.IsConnected = false; else p.IsConnected = true; } playerDCViewSource.Source = new List<PlayerDC>() { p }; friend = p; }
public FriendshipRequestPage(MainWindow mainWindow, BomberContracts_WCF.PlayerDC playerDC) { InitializeComponent(); this.mainWindow = mainWindow; this.playerDC = playerDC; var playerDCViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("playerDCViewSource"))); playerDCViewSource.Source = new List <PlayerDC>() { playerDC }; }
public static PlayerDC PlayerToPlayerDC(Player p) { PlayerDC playerDC = new PlayerDC() { PlayerDescription = p.PlayerDescription, PlayerId = p.PlayerId, PlayerStatus = p.PlayerStatus, Pseudonym = p.Pseudonym }; using (var db = new BomberDbContext()) { var q = (from pl in db.Players where pl.PlayerId == playerDC.PlayerId select pl).ToList<Player>(); if (q.Count > 0) { var player = q.ElementAt(0); playerDC.Login = player.Account.Login; } } return playerDC; }
public void NotifyFriendProfilChange(PlayerDC playerDC) { var q = (from f in friends where f.PlayerId == playerDC.PlayerId select f).ToList(); if (q.Count > 0) { var f = q.ElementAt(0); f.Pseudonym = playerDC.Pseudonym; f.PlayerDescription = playerDC.PlayerDescription; var selectedFriend = playerDCListView.SelectedItem; LoadFriends(); allowSelection = false; playerDCListView.SelectedItem = selectedFriend; friendPage.friend = selectedFriend as PlayerDC; if (_contentFrame.Content == friendPage) friendPage.LoadPlayerInfos(friendPage.friend); } }
public void NotifyFriendshipEstablishment(PlayerDC playerDC) { var q = (from r in friendshipRequests where r.PlayerId == playerDC.PlayerId select r).ToList(); if (q.Count > 0) { RemoveFriendshipRequestFromList(q.ElementAt(0)); } q = (from f in friends where f.PlayerId == playerDC.PlayerId select f).ToList(); if (q.Count == 0) { addFriendsPage.playerDCViewSource.Source = new List<PlayerDC>(); addFriendsPage.playerDCViewSource.View.Refresh(); var newFriendsList = new List<PlayerDC>() { playerDC }; friends = newFriendsList.Concat(friends); LoadFriends(); playerDCViewSource.View.Refresh(); } }
public void NotifyFriendshipEnding(PlayerDC playerDC) { var q = (from f in friends where f.PlayerId == playerDC.PlayerId select f).ToList(); if (q.Count > 0) { var newFriendsList = friends.ToList(); newFriendsList.Remove(q.ElementAt(0)); friends = newFriendsList; playerDCViewSource.Source = friends; playerDCViewSource.View.Refresh(); } }
public void AcceptFriendshipRequest(PlayerDC playerDC) { using (var db = new BomberDbContext()) { var q = (from p in db.Players where p.PlayerId == Player.PlayerId select p).ToList(); var q1 = (from p in db.Players where p.PlayerId == playerDC.PlayerId select p).ToList(); if (q.Count > 0 && q1.Count > 0) { var thisPlayer = q.ElementAt(0); var player = q1.ElementAt(0); thisPlayer.PlayersRequestingFriendship.Remove(player); if (!thisPlayer.Friends.Contains(player)) thisPlayer.Friends.Add(player); if (!player.Friends.Contains(thisPlayer)) player.Friends.Add(thisPlayer); db.SaveChanges(); Callback.NotifyFriendshipEstablishment(playerDC); if (Sessions.Keys.Contains(player.PlayerId)) Sessions[player.PlayerId].Callback.NotifyFriendshipEstablishment(EntityContractTranslator.PlayerToPlayerDC(thisPlayer)); } } }
public void PlayerPositionReplicationEventHandler(ConversationDC conv, PlayerDC player) { Callback.UpdatePlayerPosition(conv, player); }
public void UpdatePlayerPosition(ConversationDC conv, PlayerDC player) { Game.GameContentManager.UpdatePlayerPosition(player.Login, player.PlayerPositionX, player.PlayerPositionY); }
public void TriggerPlayerPositionReplicationEvent(PlayerDC p) { PlayerPositionReplicationEvent(new ConversationDC() { ConversationId = Parent.Conv.ConversationId }, p); }
public void TriggerLeaveEvent(PlayerDC player) { LeaveEvent(new PlayerDC { PlayerId = player.PlayerId }, new ConversationDC { ConversationId = Conv.ConversationId }); }
public void SaveProfil(PlayerDC profil) { using (var db = new BomberDbContext()) { var q = (from p in db.Players where p.PlayerId == Player.PlayerId select p).ToList<Player>(); if (q.Count > 0) { var thisPlayer = q.ElementAt(0); thisPlayer.Pseudonym = profil.Pseudonym; thisPlayer.PlayerDescription = profil.PlayerDescription; db.SaveChanges(); foreach (var friend in thisPlayer.Friends) { if (Sessions.Keys.Contains(friend.PlayerId)) { Sessions[friend.PlayerId].Callback.NotifyFriendProfilChange(EntityContractTranslator.PlayerToPlayerDC(thisPlayer)); } } } } }
private void LeaveConvEventHandler(PlayerDC player, ConversationDC conv) { Callback.RemovePlayerFromParty(player, conv); }
public void TriggerJoinEvent(PlayerDC player) { JoinEvent(player, Conv); }
private void JoinConvEventHandler(PlayerDC player, ConversationDC conv) { //TODO }
public void ReplicatePlayerPosition(int convID, string playerLogin, int posX, int posY) { var playerNewCoord = new PlayerDC() { Login = playerLogin, PlayerPositionX = posX, PlayerPositionY = posY }; Conversations[convID].Game.TriggerPlayerPositionReplicationEvent(playerNewCoord); }
public void PlayerDeathReplicationEventHandler(ConversationDC conv, PlayerDC player) { Callback.KillPlayer(conv, player); }
public void RemovePlayerFromParty(PlayerDC player, ConversationDC conv) { if (player.PlayerId == Player.PlayerId) { DropConversation(conv); return; } var selectedConv = conversationDCListView.SelectedItem as ConversationDC; var q = (from c in conversations where c.ConversationId == conv.ConversationId select c).ToList(); if (q.Count > 0) { var c = q.ElementAt(0); var q1 = (from p in c.Participants where p.PlayerId == player.PlayerId select p).ToList(); if (q1.Count > 0) { c.Participants = c.Participants.ToList(); ((List<PlayerDC>)c.Participants).Remove(q1.ElementAt(0)); c.ParticipantsNames = " " + c.Host.Pseudonym + " (Host) \n "; foreach (var p in c.Participants) { c.ParticipantsNames += p.Pseudonym + ", "; } c.ParticipantsNames = c.ParticipantsNames.Remove(c.ParticipantsNames.Length - 2); partyPage.LoadConversation(); ConversationsListViewSource.View.Refresh(); } } }
public void RemoveFriend(PlayerDC friend) { using (var db = new BomberDbContext()) { var q = (from p in db.Players where p.PlayerId == Player.PlayerId select p).ToList(); var q1 = (from p in db.Players where p.PlayerId == friend.PlayerId select p).ToList(); if (q.Count > 0 && q1.Count > 0) { var thisPlayer = q.ElementAt(0); var friendPlayer = q1.ElementAt(0); thisPlayer.Friends.Remove(friendPlayer); friendPlayer.Friends.Remove(thisPlayer); db.SaveChanges(); Callback.NotifyFriendshipEnding(EntityContractTranslator.PlayerToPlayerDC(friendPlayer)); if (Sessions.Keys.Contains(friendPlayer.PlayerId)) Sessions[friendPlayer.PlayerId].Callback.NotifyFriendshipEnding(EntityContractTranslator.PlayerToPlayerDC(thisPlayer)); } } }
public void RemoveFriendshipRequestFromList(PlayerDC p) { friendshipRequests.Remove(p); FriendshipRequestsViewSource.Source = friendshipRequests; FriendshipRequestsViewSource.View.Refresh(); if (playerDCListView1.Items.Count != 0 && playerDCListView1.SelectedItem as PlayerDC != null) friendshipRequestPage = new FriendshipRequestPage(this, playerDCListView1.SelectedItem as PlayerDC); else _contentFrame.Content = null; }
public void ReceiveProfil(PlayerDC myProfil, IEnumerable<PlayerDC> friendShipRequests, IEnumerable<ConversationDC> playerConvDCs) { Player = myProfil; homePage = new HomePage(this); FriendshipRequestsViewSource.Source = friendShipRequests; this.friendshipRequests = friendShipRequests.ToList<PlayerDC>(); foreach (var c in playerConvDCs) { InitializeConversation(c); } Server.RequestFriends(); }
public void KillPlayer(ConversationDC conv, PlayerDC player) { Game.GameContentManager.KillPlayer(player.Login); }
public void NotifyFriendshipRequest(PlayerDC playerDC) { friendshipRequests.Add(playerDC); FriendshipRequestsViewSource.Source = friendshipRequests; FriendshipRequestsViewSource.View.Refresh(); }
public void TriggerPlayerDeathEvent(PlayerDC player) { PlayerDeathEvent(new ConversationDC() { ConversationId = Parent.Conv.ConversationId }, player); }
public void NotifyPlayerStatusChange(PlayerDC friend) { var q = from f in friends where f.PlayerId == friend.PlayerId select f; if (q.Count() > 0) { var f = q.ToList().ElementAt(0); var previousStatus = f.PlayerStatus; f.PlayerStatus = friend.PlayerStatus; LoadFriends(); friendPage.LoadPlayerInfos(friendPage.friend); if (previousStatus == "Offline" && NotifyConnexion) new NotificationWindow(f.Pseudonym + "\nhas connected!"); } }
public void TriggerKickEvent(PlayerDC player) { KickEvent(player, Conv); }
private void KickFromConvEventHandler(PlayerDC player, ConversationDC conv) { //TODO }