コード例 #1
0
        //Cards call this function when clicked
        public static void CardCLicked(PlayCard sender)
        {
            //Sends the clicked card for the hard ai to rember
            AIhard.RemeberCard(sender);

            if (FirstTurn)
            {
                FirstTurn      = false;
                GameStarted    = true;
                Board.timeLeft = SaveGameSettings.Timer;
                Board.timer1.Start();
            }
            PickedCardsCount++;

            //When 2 cards have been picked locks cards and ends turn while checking if a pair has been chosen
            if (PickedCardsCount == 2)
            {
                CardClickAllowence(false);
                PickedCardsCount = 0;
                if (FunkcheckAdd.Checkpic())
                {
                    EndTurn(true);
                }
                else
                {
                    EndTurn(false);
                }
            }
        }
コード例 #2
0
        public static bool CheckCardListCARD2()
        {
            //foreach (PlayCard Card in RememberTag.list)
            foreach (PlayCard Carrd in RememberTag.list)
            {
                if (Card1.Tag == Carrd.Tag && Card1.ID != Carrd.ID && Carrd.Pic.Visible == true && Carrd.Turned == false)
                {
                    Card2 = Carrd;
                    Console.WriteLine("hejsan igen");
                    return(true);
                }
            }


            Card2 = CARDLIST.list[PickOne];
            return(false);
        }
コード例 #3
0
 public static void RemeberCard(PlayCard Card)
 {
     if (firsttime)
     {
         RememberTag.list.Clear();
         RememberTag.list.Add(Card);
         firsttime = false;
     }
     else
     {
         foreach (PlayCard listcard in RememberTag.list)
         {
             if (listcard.ID != Card.ID)
             {
                 RememberTag.list.Add(Card);
                 break;
             }
         }
     }
 }
コード例 #4
0
        public static void GenerateBoard(int x, Form form)
        {
            int maxBoardSize = 500;
            int cardMaxSize  = 100;
            int margin       = 10;

            int colums  = 0;
            int rowNr   = 0;
            int columNr = 0;

            Point generateStartPoint = new Point(10, 50);

            //Find a apropiate number of colums to create a field as square as possible
            colums = Convert.ToInt32(Math.Ceiling(Math.Sqrt(x)));

            //Calculate the card size depending on the max board size and the amount of columns
            //Then restrict the cards max size
            int cardSize = maxBoardSize / colums;

            if (cardSize > cardMaxSize)
            {
                cardSize = cardMaxSize;
            }
            //Generate tag list
            List <int> tagList = GenerateTags(x / 2);

            //Generate pictures
            PlayCard[] Cards = new PlayCard[x];
            int        i     = 0;

            while (i < x)
            {
                //If the end of the column count has been reached move down 1 row and reset colum counter
                if (columNr >= colums)
                {
                    rowNr++;
                    columNr = 0;
                }

                //Properties and deployment of picturebox
                PictureBox pic1 = new PictureBox();

                pic1.Location = new Point(generateStartPoint.X + columNr * (cardSize + margin), generateStartPoint.Y + rowNr * (cardSize + margin));
                pic1.Width    = cardSize;
                pic1.Height   = cardSize;
                pic1.Image    = Properties.Resources.Backside1;
                pic1.SizeMode = PictureBoxSizeMode.StretchImage;
                form.Controls.Add(pic1);
                PlayCard Card = new PlayCard(pic1);

                //Add a random tag from the tag list to the card
                Random random = new Random();
                int    curTag = random.Next(0, tagList.Count);
                Card.Tag = tagList[curTag];
                //Removes the used tag from the list
                tagList.RemoveAt(curTag);

                Cards[i] = Card;

                columNr++;
                i++;
            }
        }
コード例 #5
0
        //Calculate the max board size

        //Generates the board and returns an array of playcards
        public static PlayCard[] GenerateBoard(int x, SplitContainer container)
        {
            int maxBoardSize = 500;
            int cardMaxSize  = 100;
            int margin       = 10;

            int colums  = 0;
            int rowNr   = 0;
            int columNr = 0;

            //Check appropiate board generation style
            colums = BoardGenerationAssist.getColumnsFromPairs(x / 2);
            if (x / colums > 9)
            {
                colums = (int)Math.Ceiling(Math.Sqrt(x) + 1);
            }

            Point generateStartPoint = new Point(10, 10);

            maxBoardSize = container.Panel1.Width - 125;

            //Find a apropiate number of colums to create a field as square as possible
            //colums = Convert.ToInt32(Math.Ceiling(Math.Sqrt(x)) + 1);

            //Calculate the card size depending on the max board size and the amount of columns
            //Then restrict the cards max size
            int cardSize = maxBoardSize / colums;

            if (cardSize > cardMaxSize)
            {
                cardSize = cardMaxSize;
            }

            //Generate tag list
            List <int> tagList = GenerateTags(x / 2);

            //Generate pictures
            PlayCard[] Cards = new PlayCard[x];
            int        i     = 0;

            while (i < x)
            {
                //If the end of the column count has been reached move down 1 row and reset colum counter
                if (columNr >= colums)
                {
                    rowNr++;
                    columNr = 0;
                }

                //Properties and deployment of picturebox
                PictureBox pic1 = new PictureBox();

                pic1.Location  = new Point(generateStartPoint.X + columNr * (cardSize + margin), generateStartPoint.Y + rowNr * (cardSize + margin));
                pic1.Width     = cardSize;
                pic1.Height    = cardSize;
                pic1.Image     = Properties.Resources.Theme_SI_pic20;
                pic1.SizeMode  = PictureBoxSizeMode.StretchImage;
                pic1.BackColor = Color.Transparent;
                container.Panel1.Controls.Add(pic1);
                PlayCard Card = new PlayCard(pic1);


                //Add a tag from the random tag list to the card
                Card.Tag = tagList[0];

                //Add an id to the card
                Card.ID = i;
                //Removes the used tag from the list
                tagList.RemoveAt(0);

                Cards[i] = Card;

                columNr++;
                i++;
            }
            return(Cards);
        }