コード例 #1
0
        public void ClickOnBoard(int indexOfObject)
        {
            if (!PexesoService.InGame)
            {
                return;
            }
            Card clickedCard = PexesoService.GameCards[indexOfObject];

            if (clickedCard.Status == StatusCardEnum.Founded || clickedCard.Status == StatusCardEnum.Uncovered)
            {
                return;
            }
            PexesoService.InProcess = true;
            var uncoveredCard = PexesoService.GameCards.Find(card => card.Status == StatusCardEnum.Uncovered);

            clickedCard.Status = StatusCardEnum.Uncovered;
            UpdateCardStatus(clickedCard, PexesoService.GetCardIndex(clickedCard));

            if (PexesoService.CompareCards(clickedCard, uncoveredCard))
            {
                Thread.Sleep(1000);
            }
            Score = PexesoService.Score.ToString();

            UpdateCardStatus(clickedCard, PexesoService.GetCardIndex(clickedCard));
            if (uncoveredCard != null)
            {
                UpdateCardStatus(uncoveredCard, PexesoService.GetCardIndex(uncoveredCard));
            }
            PexesoService.InProcess = false;
        }
コード例 #2
0
        private void ChoseSecondCardTimerTick(object sender, EventArgs e)
        {
            if (PexesoService.ChoseSecondCardTimeLeft() == -1)
            {
                // Failed for secnd card
                ChoseSecondCardTimer = 0;
                return;
            }

            ChoseSecondCardTimer = 100 - PexesoService.ChoseSecondCardTimeLeft();
        }
コード例 #3
0
        private void LoadCardsToBorder()
        {
            Rectangles.Clear();
            Pictures.Clear();
            int widht  = 8;
            int height = 8;

            PexesoService.StartPexeso(height, widht);
            int x   = 2;
            int y   = 2;
            int row = 0;

            foreach (var a in PexesoService.GameCards)
            {
                Canvas.SetLeft(a.Img, x);
                Canvas.SetTop(a.Img, y);
                // Rectangle
                SolidColorBrush pomCo = new SolidColorBrush()
                {
                    Color   = Colors.Black,
                    Opacity = 1
                };
                SolidColorBrush pomCoB = new SolidColorBrush()
                {
                    Color = Colors.BlueViolet
                };
                Rectangle pomR = new Rectangle()
                {
                    Width  = PexesoService.PictureWidth,
                    Height = PexesoService.PictureHeight,
                    Fill   = pomCo,
                    Stroke = pomCoB,
                };
                Canvas.SetLeft(pomR, x);
                Canvas.SetTop(pomR, y);
                Rectangles.Add(pomR);
                Pictures.Add(a.Img);

                a.PositionX = x;
                a.PositionY = y;
                a.Status    = StatusCardEnum.Covered;
                x          += PexesoService.PictureWidth + 5;
                if (Pictures.Count % widht == 0)
                {
                    row++;
                    x  = 2;
                    y += PexesoService.PictureHeight + 5;
                }
                if (row == height)
                {
                    break;
                }
            }
        }
コード例 #4
0
        private void InActiveTimerTick(object sender, EventArgs e)
        {
            if (PexesoService.TimeLeftForTurn() == -1)
            {
                // End Game

                InActiveTime = 0;
                return;
            }

            InActiveTime = 100 - PexesoService.TimeLeftForTurn();
        }
コード例 #5
0
        private void RoundTImeTick(object sender, EventArgs e)
        {
            double pomInS = PexesoService.RoundTime();

            RoundTime = $"Time: {(int)pomInS / 60:D2}:{(int)pomInS % 60:D2}";
        }