public UserControl_Coop(Group_Model group, HomePage_ViewModel homePageViewModel) { InitializeComponent(); this.GroupName.Text = "Joindre le groupe: <" + group.createGroup.name + ">" + " SVP"; DataContext = new Coop_ViewModel(this, homePageViewModel, group); //DataContext = new TemplateView_ViewModel<UserControl_Coop>(this, homePageViewModel, group); }
public UserControl_Solo(Group_Model group, HomePage_ViewModel homePageViewModel) { InitializeComponent(); this.GroupName.Text = "Veuillez joindre le groupe: <" + group.createGroup.name + ">"; DataContext = new Solo_ViewModel(this, homePageViewModel, group); //DataContext = new TemplateView_ViewModel<UserControl_Solo>(this, homePageViewModel, group); }
public void pAB(dynamic view, dynamic p, Group_Model group) { view.AB.Content = (string)p.A.B.user.username; Player_Model player = new Player_Model((string)p.A.B.user.username, (string)p.A.B.type, (string)p.A.B.role, "A.B", (bool)p.A.B.ready); group.listPlayers[1] = player; }
public Coop_ViewModel(UserControl_Coop coopView, HomePage_ViewModel homePageViewModel, Group_Model group) { this._coopView = coopView; this._homePageViewModel = homePageViewModel; this._group = group; this._basicMode = new BasicMode(homePageViewModel, group); ReturnToGroupsList = new GeneralCommands <object>(this._basicMode.RetunToGroups_List, this._basicMode.CanRetunToGroups_List); ReadyToStart = new GeneralCommands <object>(this._basicMode.ReadyTo_Start, this._basicMode.CanBeReadyTo_Start); AddPlayerCommand = new GeneralCommands <object>(this._basicMode.AddPlayer, this._basicMode.CanAddPlayer); this._basicMode.EmitGroup(); SocketService.MySocket.On("list groups", (data) => { JArray jsonArray = JArray.Parse(data.ToString()); foreach (object i in jsonArray) { dynamic p = JObject.Parse(i.ToString()); if (p.mode == "COOP" && p.name == group.createGroup.name) { this._homePageViewModel.HomePageView.Dispatcher.Invoke(() => { this.DisplayPlayerName(p); this.DisableReadyButtons(p); }); } } }); }
public Group_Model BuildSoloGroup(dynamic g) { Player_Model pAA = this.CreatePlayer(g.A.A); this._listPlayers = new List <Player_Model> { pAA }; Group_Model group = new Group_Model((string)g.id, new CreateGroup_Server((string)g.name, (string)g.difficulty, (string)g.mode), this._listPlayers); return(group); }
public Solo_ViewModel(UserControl_Solo soloView, HomePage_ViewModel homePageViewModel, Group_Model group) { this._soloView = soloView; this._homePageViewModel = homePageViewModel; this._group = group; this._basicMode = new BasicMode(homePageViewModel, group); ReturnToGroupsList = new GeneralCommands <object>(this._basicMode.RetunToGroups_List, this._basicMode.CanRetunToGroups_List); ReadyToStart = new GeneralCommands <object>(this._basicMode.ReadyTo_Start, this._basicMode.CanBeReadyTo_Start); AddPlayerCommand = new GeneralCommands <object>(this._basicMode.AddPlayer, this._basicMode.CanAddPlayer); this._basicMode.EmitGroup(); this.ListenListGroups(); }
public Group_Model BuildCoopGroup(dynamic g) { Player_Model pAA = this.CreatePlayer(g.A.A); Player_Model pAB = this.CreatePlayer(g.A.B); Player_Model pAC = this.CreatePlayer(g.A.C); Player_Model pAD = this.CreatePlayer(g.A.D); this._listPlayers = new List <Player_Model> { pAA, pAB, pAC, pAD }; Group_Model group = new Group_Model((string)g.id, new CreateGroup_Server((string)g.name, (string)g.difficulty, (string)g.mode), this._listPlayers); return(group); }
public void ListenToGroups() { SocketService.MySocket.On("list groups", (data) => { this._gameRoomView.Dispatcher.Invoke(() => { this._gameRoomView.stakGroups.Children.Clear(); this._listGroups.Clear(); Console.WriteLine(data); JArray jsonArray = JArray.Parse(data.ToString()); foreach (object i in jsonArray) { dynamic g = JObject.Parse(i.ToString()); switch ((string)g.mode) { case "CLASSIC": this._specificGroup = this.BuildClassicGroup(g); break; case "SOLO": this._specificGroup = this.BuildSoloGroup(g); break; case "COOP": this._specificGroup = this.BuildCoopGroup(g); break; case "TOURNAMENT": this._specificGroup = this.BuildTournamenGroup(g); break; } this._listGroups.Add(this._specificGroup); this._gameRoomView.stakGroups.Children.Add(new UserControl_Group(this._homePageViewModel, this._specificGroup)); } }); }); }
public TemplateView_ViewModel(T view, HomePage_ViewModel homePageViewModel, Group_Model group) { this._view = view; this._homePageViewModel = homePageViewModel; this._group = group; BasicMode basic = new BasicMode(homePageViewModel, group); ReturnToGroupsList = new GeneralCommands <object>(basic.RetunToGroups_List, basic.CanRetunToGroups_List); ReadyToStart = new GeneralCommands <object>(basic.ReadyTo_Start, basic.CanBeReadyTo_Start); AddPlayerCommand = new GeneralCommands <object>(basic.AddPlayer, basic.CanAddPlayer); SocketService.MySocket.On("list groups", (data) => { JArray jsonArray = JArray.Parse(data.ToString()); foreach (object i in jsonArray) { dynamic p = JObject.Parse(i.ToString()); if (p.mode == "COOP") { this._homePageViewModel.HomePageView.Dispatcher.Invoke(() => { //BasicMode basicMode = new BasicMode(view, p, this._group); //this.CheckGameCoopState(p); }); } if (p.mode == "SOLO") { this._homePageViewModel.HomePageView.Dispatcher.Invoke(() => { //BasicMode basicMode = new BasicMode(view, p, this._group); //this.CheckGameSoloState(p); }); } } }); }
public Tournament_ViewModel(UserControl_Tournament tournamentView, HomePage_ViewModel homePageViewModel, Group_Model group) { this._tournamentView = tournamentView; this._homePageViewModel = homePageViewModel; this._group = group; this._basicMode = new BasicMode(homePageViewModel, group); ReturnToGroupsList = new GeneralCommands <object>(this._basicMode.RetunToGroups_List, this._basicMode.CanRetunToGroups_List); ReadyToStart = new GeneralCommands <object>(this._basicMode.ReadyTo_Start, this._basicMode.CanBeReadyTo_Start); AddPlayerCommand = new GeneralCommands <object>(this._basicMode.AddPlayer, this._basicMode.CanAddPlayer); //this.AddExistingPlayers(); var groupp = JsonConvert.SerializeObject(new ModeDifficulty_Server(GlobalUser.Mode, GlobalUser.Difficulty)); SocketService.MySocket.Emit("list groups", groupp); SocketService.MySocket.On("list groups", (data) => { tournamentView.Dispatcher.Invoke(() => { JArray jsonArray = JArray.Parse(data.ToString()); foreach (object i in jsonArray) { dynamic p = JObject.Parse(i.ToString()); if (p.mode == "TOURNAMENT" && p.name == group.createGroup.name) { this._homePageViewModel.HomePageView.Dispatcher.Invoke(() => { this.ClearStacks(); this.DisplayerPlayerName(p); this.DisplayStacks(); }); } } }); }); }
public UserControl_Classic(Group_Model group, HomePage_ViewModel homePageViewModel) { InitializeComponent(); this.GroupName.Text = "Veuillez choisir une place dans le groupe: <" + group.createGroup.name + ">"; DataContext = new Classic_ViewModel(this, homePageViewModel, group); }
public Classic_ViewModel(UserControl_Classic classicView, HomePage_ViewModel homePageViewModel, Group_Model group) { this._classicView = classicView; this._homePageViewModel = homePageViewModel; this._group = group; this._basicMode = new BasicMode(homePageViewModel, group); ReturnToGroupsList = new GeneralCommands <object>(this._basicMode.RetunToGroups_List, this._basicMode.CanRetunToGroups_List); ReadyToStart = new GeneralCommands <object>(this._basicMode.ReadyTo_Start, this._basicMode.CanBeReadyTo_Start); AddPlayerCommand = new GeneralCommands <object>(AddPlayer, CanAddPlayer); this._basicMode.EmitGroup(); SocketService.MySocket.Off("list groups"); SocketService.MySocket.On("list groups", (data) => { this._classicView.Dispatcher.Invoke(() => { JArray jsonArray = JArray.Parse(data.ToString()); foreach (object i in jsonArray) { dynamic p = JObject.Parse(i.ToString()); #region CLASSIC if (p.mode == "CLASSIC" && p.name == group.createGroup.name) { if (p.A.A is object) { this._classicView.AA.Content = (string)p.A.A.user.username; this.ProfilePicAA = this._basicMode.DisplayAvatar(this._basicMode.SaveAvatarPhoto((object)p.A.A)); Player_Model player = new Player_Model((string)p.A.A.user.username, (string)p.A.A.type, (string)p.A.A.role, "A.A", (bool)p.A.A.ready); this._group.listPlayers[0] = player; if ((string)p.A.A.user.username == GLOBAL_USER && p.A.B == null) { this._classicView.AB.IsEnabled = true; this._classicView.AB.Content = "Ajouter un joueur virtuel AB"; this.VABisOn = true; this._classicView.BB.IsEnabled = true; } } else { this._classicView.AA.Content = "+ Joueur: Devineur"; this.ProfilePicAA = null; this._group.listPlayers[0] = null; } if (p.A.B is object) { Player_Model player = new Player_Model((string)p.A.B.user.username, (string)p.A.B.type, (string)p.A.B.role, "A.B", (bool)p.A.B.ready); this._group.listPlayers[1] = player; if (p.A.B.type == "REAL") { this._classicView.AB.Content = (string)p.A.B.user.username; this.ProfilePicAB = this._basicMode.DisplayAvatar(this._basicMode.SaveAvatarPhoto((object)p.A.B)); } else { this._classicView.AB.Content = VIRTUAL_AB; this._classicView.AvatarAB.ImageSource = this._basicMode.DisplayAvatar(System.Environment.CurrentDirectory.Replace("\\bin\\Debug", "/Assets/profile_virtual_player.png")); this._classicView.AB.IsEnabled = true; this._classicView.BB.IsEnabled = true; } } else if (p.A.B == null && this.VABisOn == false) { this._classicView.AB.Content = "+ Joueur: Auteur"; this.ProfilePicAB = null; this._group.listPlayers[1] = null; } if (p.B.A is object) { this._classicView.BA.Content = (string)p.B.A.user.username; this.ProfilePicBA = this._basicMode.DisplayAvatar(this._basicMode.SaveAvatarPhoto((object)p.B.A)); Player_Model player = new Player_Model((string)p.B.A.user.username, (string)p.B.A.type, (string)p.B.A.role, "B.A", (bool)p.B.A.ready); this._group.listPlayers[2] = player; if ((string)p.B.A.user.username == GLOBAL_USER && p.B.B == null) { this._classicView.BB.IsEnabled = true; this._classicView.BB.Content = "Ajouter un joueur virtuel BB"; this.VBBisON = true; this._classicView.AB.IsEnabled = true; } } else { this._classicView.BA.Content = "+ Joueur: Devineur"; this.ProfilePicBA = null; this._group.listPlayers[2] = null; } if (p.B.B is object) { Player_Model player = new Player_Model((string)p.B.B.user.username, (string)p.B.B.type, (string)p.B.B.role, "B.B", (bool)p.B.B.ready); this._group.listPlayers[3] = player; if (p.B.B.type == "REAL") { this._classicView.BB.Content = (string)p.B.B.user.username; this.ProfilePicBB = this._basicMode.DisplayAvatar(this._basicMode.SaveAvatarPhoto((object)p.B.B)); } else { this._classicView.BB.Content = VIRTUAL_BB; this._classicView.BB.IsEnabled = true; this._classicView.AvatarBB.ImageSource = this._basicMode.DisplayAvatar(System.Environment.CurrentDirectory.Replace("\\bin\\Debug", "/Assets/profile_virtual_player.png")); this._classicView.AB.IsEnabled = true; } } else if (p.B.B == null && this.VBBisON == false) { this._classicView.BB.Content = "+ Joueur: Auteur"; this._group.listPlayers[3] = null; this.ProfilePicBB = null; } this.EnablePlayersButtons(p); this.DisableReadyButton(p); } #endregion } }); }); }
public Group_ViewModel(HomePage_ViewModel homePageViewModel, Group_Model group) { this._homePageViewModel = homePageViewModel; this._group = group; EnterGroup = new GeneralCommands <object>(Enter_Group, CanEnter_Group); }
public UserControl_Group(HomePage_ViewModel homePageViewModel, Group_Model group) { InitializeComponent(); this.GroupName.Content = "Le nom du groupe: " + group.createGroup.name; DataContext = new Group_ViewModel(homePageViewModel, group); }
public UserControl_Tournament(Group_Model group, HomePage_ViewModel homePageViewModel) { InitializeComponent(); DataContext = new Tournament_ViewModel(this, homePageViewModel, group); this.GroupTitle.Text = "Veuillez joindre le tournoi : <" + group.createGroup.name + ">"; }
public BasicMode(HomePage_ViewModel homePageViewModel, Group_Model group) { this._homePageViewModel = homePageViewModel; this._group = group; }