Exemple #1
0
        /*! \brief eventlistner for resume button
         */
        private void Button_resume_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                Memorygame mg = new Memorygame(File.ReadAllText(openFileDialog.FileName));
                this.Content = mg;
            }
        }
Exemple #2
0
 public Card(int type, double width, int size, WrapPanel wp, List <Card> pc, Memorygame _mg) // override constructor [USE THIS ONE]
 {
     this.type   = type;                                                                     // assign type given by main
     Content     = "test";                                                                   // temporary content
     Width       = width / size;                                                             // dynamic width according to amount of Cards given by size
     Height      = width / size;                                                             // dynamic height according to amount of Cards given by size
     this.Click += Button1_Click;                                                            // subscribes the click event to a function
     this.pc     = pc;
     this.wp     = wp;
     this._mg    = _mg;
 }
Exemple #3
0
        /*! \brief override constructor that takes arguements: type, width, size, wrappanel, list of cards, and memorygame instance
         */
        public Card(int type, double width, int size, WrapPanel wp, List <Card> pc, Memorygame _mg) // override constructor [USE THIS ONE]
        {
            defaultBG.ImageSource = new BitmapImage(new Uri("BG.png", UriKind.Relative));
            this.type             = type; // assign type given by main
            Width       = width / size;   // dynamic width according to amount of Cards given by size
            Height      = width / size;   // dynamic height according to amount of Cards given by size
            this.Click += Button1_Click;  // subscribes the click event to a function
            this.pc     = pc;
            this.wp     = wp;
            this._mg    = _mg;

            this.Background = defaultBG;
        }
        /*! \brief overridden constructor for getting player names
         */
        public Memorygame(List <string> players)
        {
            InitializeComponent(); // no clue what it does but dont remove it

            wp.Width  = 500;       // set wrappanel width
            wp.Height = 500;       // set wrappanel height

            turnCountdown.Width  = 300;
            turnCountdown.Height = 200;

            powerbutton.Width  = 300;
            powerbutton.Height = 200;
            powerbutton.Click += PowerButton_Click;

            playerNames = players;

            _mg = this;

            dt.Tick    += new EventHandler(timer_Tick);
            dt.Interval = new TimeSpan(0, 0, 1); // execute every second
            dt.Start();

            CreatePlayers();

            CreatePlayerScores();

            psList.Children.Add(turnCountdown);

            DP.Children.Add(psList);
            DP.Children.Add(wp);
            DP.Children.Add(powerbutton);
            DP.Children.Add(pmenu);

            Canvas.SetLeft(wp, 500);
            Canvas.SetLeft(powerbutton, 1200);

            CyclePlayers();
            AssignGrid();
            BuildPauseMenu();

            SetTheme();
            this.Content = DP; // give the content
        }
Exemple #5
0
        private void ButtonGameStart_Click(object sender, RoutedEventArgs e)
        {
            if (p1name.Text != "" && p1name.Text != "name. . ." && p1name.Text != null)
            {
                playerList.Add(p1name.Text);
            }
            if (p2name.Text != "" && p2name.Text != "name. . ." && p2name.Text != null)
            {
                playerList.Add(p2name.Text);
            }
            if (p3name.Text != "" && p3name.Text != "name. . ." && p3name.Text != null)
            {
                playerList.Add(p3name.Text);
            }
            if (p4name.Text != "" && p4name.Text != "name. . ." && p4name.Text != null)
            {
                playerList.Add(p4name.Text);
            }
            if (playerList.Count < 1)
            {
                MessageBox.Show("Fill in your name");
            }
            else
            {
                IEnumerable <string> comparel = playerList.Distinct();
                if (playerList.Count == comparel.Count())
                {
                    Memorygame mg = new Memorygame(playerList);
                    this.Content = mg;
                    comparel     = null;
                }
                else
                {
                    MessageBox.Show("names can't be the same, please change the duplicate name");
                    comparel = null;
                    playerList.Clear();
                }
            }


            //start the game here and send the list to the game
        }
Exemple #6
0
        public Memorygame(List <string> players)
        {
            InitializeComponent(); // no clue what it does but dont remove it

            wp.Width  = 500;       // set wrappanel width
            wp.Height = 500;       // set wrappanel height

            playerNames = players;

            _mg = this;

            CreatePlayers();

            CreatePlayerScores();

            DP.Children.Add(psList);
            DP.Children.Add(wp);

            CyclePlayers();
            AssignGrid();

            this.Content = DP; // give the content
        }
        /*! \brief overridden constructor
         */
        public Memorygame(string s)
        {
            InitializeComponent(); // no clue what it does but dont remove it

            wp.Width  = 500;       // set wrappanel width
            wp.Height = 500;       // set wrappanel height

            _mg = this;

            LoadGame(s); // loads the game from previous saved file
            CreatePlayerScores();

            turnCountdown.Width  = 300;
            turnCountdown.Height = 200;

            powerbutton.Width  = 300;
            powerbutton.Height = 200;
            powerbutton.Click += PowerButton_Click;

            dt.Tick    += new EventHandler(timer_Tick);
            dt.Interval = new TimeSpan(0, 0, 1); // execute every second
            dt.Start();

            psList.Children.Add(turnCountdown);

            DP.Children.Add(psList);
            DP.Children.Add(wp);
            DP.Children.Add(powerbutton);
            DP.Children.Add(pmenu);

            Canvas.SetLeft(wp, 500);
            Canvas.SetLeft(powerbutton, 1200);

            BuildPauseMenu();

            this.Content = DP; // give the content
        }
Exemple #8
0
 /*! \brief override constructor that takes MemoryGame instance
  */
 public ThemeSwap(Memorygame _mg)
 {
     this._mg = _mg;
     name     = "Theme Swap";
 }
Exemple #9
0
 /*! \brief override constructor that takes MemoryGame instance
  */
 public ShuffleCards(Memorygame _mg)
 {
     this._mg = _mg;
     name     = "Shuffle Cards";
 }
Exemple #10
0
        private void Button_start_Click(object sender, RoutedEventArgs e) // click event/function [works more like event]
        {
            Memorygame mg = new Memorygame();                             // instance of memorygame

            this.Content = mg;                                            // show memorygame page in content
        }
Exemple #11
0
 public ShuffleCards(Memorygame _mg)
 {
     this._mg = _mg;
 }