Beispiel #1
0
 public ResultForm(GameBoardForm board)
 {
     this.startForm = board.startForm;
     this.game      = board.Game;
     InitializeComponent();
     this.winner_label.Text      = game.Winner.Name + " har vunnit!";
     this.winner_label.ForeColor = game.Winner.Color;
     GenerateLables();
 }
Beispiel #2
0
        public GameBoardForm(StartForm startForm)
        {
            this.startForm = startForm;
            var settings = startForm.settings;

            this.Game = new Game(settings);
            this.Text = Game.CurrentPlayer.Name;

            InitializeComponent();


            thinkTimer.Interval = settings.PlayersTurnTimer * 1000;
            cardTimer.Interval  = settings.ShowCardTimer * 1000;


            int total   = settings.CardNumber;
            int columns = (int)Math.Ceiling(Math.Sqrt(total));


            int xOffset = 85;
            int yOffset = 85;

            for (int i = 0; i < total; i++)
            {
                var y       = yOffset * (i / columns) + 30;
                var x       = xOffset * (i % columns) + 20;
                var control = new MemoryCardControl(this);

                thinkTimer.Tick += new EventHandler(control.HandleThinkTimer);
                cardTimer.Tick  += new EventHandler(control.HandleCardtimer);
                control.Location = new System.Drawing.Point(x, y);
                this.Controls.Add(control);
            }
            closedCardList = this.Controls.OfType <MemoryCardControl>().ToList();

            var px = xOffset * columns + 30;
            var py = 40;

            for (int i = 0; i < settings.Playerlist.Length; i++)
            {
                var player      = Game.Players[i];
                var playerlabel = new Label();
                playerlabel.Text      = player.Name + " :  " + player.Score.ToString();
                playerlabel.Location  = new System.Drawing.Point(px, py);
                playerlabel.Name      = player.Name;
                playerlabel.ForeColor = player.Color;
                this.Controls.Add(playerlabel);

                py += 22;
            }

            this.Size = new Size(columns * xOffset + 150, (total + columns - 1) / columns * yOffset + 90);

            Shuffle();
        }
Beispiel #3
0
        private void cmb_AI_SelectedIndexChanged(object sender, EventArgs e)
        {
            StartForm frm    = new StartForm();
            var       player = this.cmb_AI.Text;

            if (int.Parse(player) == 10)
            {
                cmb_spelare.Hide();
                frm.Refresh();
            }
            if (int.Parse(player) <= 9)
            {
                cmb_spelare.Show();
                frm.Refresh();
            }
        }