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);
                        });
                    }
                }
            });
        }
Beispiel #2
0
        public GamesRoom_ViewModel(UserControl_GamesRoom gameRoomView, HomePage_ViewModel homePageViewModel)
        {
            this._gameRoomView      = gameRoomView;
            this._homePageViewModel = homePageViewModel;

            ReturnToHomePage = new GeneralCommands <object>(ReturnToHome, CanReturnToHome);
            OpenCreateGroup  = new GeneralCommands <object>(OpenCreate_Group, CanOpenCreate_Group);

            this.ListenToGroups();
            this.ConnectToGroups();
        }
        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 GameMode_ViewModel(HomePage_ViewModel homePageViewModel)
 {
     this._homePageViewModel = homePageViewModel;
     ChooseGameMode          = new GeneralCommands <object>(ShowModeDiff, CanShowModeDiff);
 }
Beispiel #6
0
        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);
 }