示例#1
0
 private void Update()
 {
     PossibleCells = _gamePreset.OCellSprites
                     .Select(x => new KeyValuePair <ImageContainer, CellType>(new ImageContainer(x), CellType.OCell))
                     .Union(_gamePreset.XCellSprites
                            .Select(x => new KeyValuePair <ImageContainer, CellType>(new ImageContainer(x), CellType.XCell)))
                     .Union(_gamePreset.FreeCellSprites
                            .Select(x => new KeyValuePair <ImageContainer, CellType>(new ImageContainer(x), CellType.Free)))
                     .ToList();
     TurnImage  = new ImageContainer(_gamePreset.TurnSprite);
     StartImage = new ImageContainer(_gamePreset.StartSprite);
     OnGameStateUpdated?.Invoke();
 }
示例#2
0
        private void Monitoring()
        {
            Update();
            var isBoardUpdated = false;

            while (_isMonitoringRinning)
            {
                var searchScreenObj = GetScreenShot();
                var turnPoint       = searchScreenObj.Find(TurnImage, 1, 0);
                if (turnPoint != Point.Empty)
                {
                    isBoardUpdated = UpdateBoard(searchScreenObj);
                    if (IsGameStarted)
                    {
                        MakeTurn();
                    }
                }
                else if (IsGameStarted)
                {
                    var startPoint = searchScreenObj.Find(StartImage, 1, 0);
                    if (startPoint != Point.Empty)
                    {
                        if (!Directory.Exists(ScreensDir))
                        {
                            Directory.CreateDirectory(ScreensDir);
                        }

                        var screen     = Screen.FromHandle(_winHandle);
                        var screenShot = SearchHelper.CaptureScreen(SearchHelper.MagicShift, SearchHelper.MagicShift,
                                                                    screen.Bounds.Width, screen.Bounds.Height, _winHandle);
                        var fileName = $"{DateTime.Now.ToString("yyyy.MM.dd HH.mm.ss")}.bmp";
                        fileName = Path.Combine(Environment.CurrentDirectory, ScreensDir, fileName);
                        screenShot.Save(fileName);
                        startPoint.X -= _gamePreset.StartSprite.Width / 2;
                        startPoint.Y -= _gamePreset.StartSprite.Height / 2;
                        Mouse.ClickIt(startPoint, MouseSpeed, Mouse.Buttons.Left);
                    }
                }

                if (isBoardUpdated)
                {
                    OnGameStateUpdated?.Invoke();
                }
                Thread.Sleep(Delay);
            }
        }
示例#3
0
        private void Monitoring()
        {
            Update();
            while (_isMonitoringRinning)
            {
                var searchScreenObj = GetScreenShot();
                var isBoardUpdated  = UpdateBoard(searchScreenObj);
                if (IsGameStarted)
                {
                    MakeTurn();
                }

                if (isBoardUpdated)
                {
                    OnGameStateUpdated?.Invoke();
                }
                Thread.Sleep(Delay);
            }
        }
示例#4
0
 private void Update()
 {
     PossibleCells = new List <KeyValuePair <ImageContainer, CellType> >
     {
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.BombCellSprite), CellType.Bomb),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.BlastCellSprite), CellType.Blast),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.BonusCellSprite), CellType.Bonus),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.EmptyCellSprite), CellType.Empty),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.FlagCellSprite), CellType.Flag),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.FreeCellSprite), CellType.Free),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell1Sprite), CellType.Cell1),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell2Sprite), CellType.Cell2),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell3Sprite), CellType.Cell3),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell4Sprite), CellType.Cell4),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell5Sprite), CellType.Cell5),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell6Sprite), CellType.Cell6),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell7Sprite), CellType.Cell7),
         new KeyValuePair <ImageContainer, CellType>(new ImageContainer(_gamePreset.Cell8Sprite), CellType.Cell8)
     };
     TurnImage  = new ImageContainer(_gamePreset.RestartSprite);
     StartImage = new ImageContainer(_gamePreset.StartSprite);
     OnGameStateUpdated?.Invoke();
 }