Example #1
0
        public void ClickOnGameField(List <OsrsImage> gameObjects)
        {
            #region Determine Scan Boundaries

            var gameFieldCenterLocation = AddPoints(MenuControls.GameFieldView.MatchLocations.FirstOrDefault(), MenuControls.GameFieldView.ImageData.CenterOfImage);
            var gameFieldScanSection    = new ScanBoundaries();
            var xBuffer = 200;
            var yBuffer = 100;

            gameFieldScanSection.MinX = gameFieldCenterLocation.X - xBuffer > 0 ? gameFieldCenterLocation.X - xBuffer : 0;
            gameFieldScanSection.MinY = gameFieldCenterLocation.Y - yBuffer > 0 ? gameFieldCenterLocation.Y - yBuffer : 0;
            gameFieldScanSection.MaxX = gameFieldCenterLocation.X + xBuffer;
            gameFieldScanSection.MaxY = gameFieldCenterLocation.Y + yBuffer;

            #endregion

            var gameObjectsScanData = _imageProcessor.SearchScreenForImages(gameObjects, gameFieldScanSection, getSingleOccurrence: true);

            if (gameObjectsScanData.Any())
            {
                var gObj            = gameObjectsScanData.FirstOrDefault();
                var matchedLocation = gObj.MatchLocations.FirstOrDefault();

                var clickLocation = AddPoints(matchedLocation, gObj.ImageData.CenterOfImage);

                IoSimulator.ClickLocation(clickLocation);
                IoSimulator.PauseThread(600);
                IoSimulator.ClickLocation(clickLocation);
            }
        }
Example #2
0
        public void UseToolOnResources(List <OsrsImage> resources, OsrsImage tool, int pauseTime = 2000)
        {
            resources.Add(tool);

            #region Determine Scan Boundaries

            var scanBounds = new ScanBoundaries();

            var invLoc = MenuControls.Inventory.MatchLocations.FirstOrDefault();

            scanBounds.MinX = invLoc.X;
            scanBounds.MinY = invLoc.Y;
            scanBounds.MaxX = invLoc.X + MenuControls.Inventory.ImageData.ImageBitmap.Width;
            scanBounds.MaxY = invLoc.Y + MenuControls.Inventory.ImageData.ImageBitmap.Height;

            #endregion

            IoSimulator.ClickLocation(MenuControls.PackContents.MatchLocations.FirstOrDefault());
            var resourceScanData = _imageProcessor.SearchScreenForImages(resources, scanBounds);

            var toolData = resourceScanData.Where(x => x.ImageData.ImageName == tool.ImageName).FirstOrDefault();

            if (toolData != null)
            {
                var toolLocation = toolData.MatchLocations.FirstOrDefault();

                foreach (var r in resourceScanData.Where(x => x.ImageData.ImageName != tool.ImageName))
                {
                    IoSimulator.ClickLocation(toolLocation);

                    IoSimulator.PauseThread(2000);

                    IoSimulator.ClickLocation(r.MatchLocations.FirstOrDefault());

                    IoSimulator.PauseThread(2000);

                    IoSimulator.ClickLocation(MenuControls.PerformActionOnAll);

                    IoSimulator.PauseThread(pauseTime * r.MatchLocations.Count);
                }
            }
            else
            {
                // tool not in inventory
            }
        }
        public void PowerMine(int numOfIterations = 3)
        {
            var rocks   = _actionLib.AllImages.Where(x => x.ImageName.Contains("iron rocks")).ToList();
            var ironOre = _actionLib.AllImages.Where(x => x.ImageName == "iron ore.bmp").ToList();

            for (int j = 0; j < numOfIterations; j++)
            {
                _actionLib.DropAllItems(ironOre);

                for (int i = 0; i < 20; i++)
                {
                    IoSimulator.PauseThread(2300);
                    _actionLib.ClickOnGameField(rocks);
                }

                IoSimulator.PauseThread(2000);
            }
        }
Example #4
0
        public void DropAllItems(List <OsrsImage> itemIcons)
        {
            IoSimulator.ClickLocation(MenuControls.PackContents.MatchLocations.FirstOrDefault());

            var itemIconScanData = _imageProcessor.SearchScreenForImages(itemIcons);

            var allMatchedLocations = itemIconScanData.SelectMany(x => x.MatchLocations).ToList();
            var centerOfImage       = itemIconScanData.Select(x => x.ImageData.CenterOfImage).FirstOrDefault();

            foreach (var itemIconLocation in allMatchedLocations)
            {
                var paddedItemIconLocation = AddPoints(itemIconLocation, centerOfImage);

                IoSimulator.ClickLocation(paddedItemIconLocation, leftClick: false);

                IoSimulator.PauseThread(100);

                #region Determine Scan Boundaries
                var menuScanSection = new ScanBoundaries();

                var scanBuffer = 150;

                menuScanSection.MinX = paddedItemIconLocation.X - scanBuffer;
                menuScanSection.MinY = paddedItemIconLocation.Y - scanBuffer;
                menuScanSection.MaxX = paddedItemIconLocation.X + scanBuffer;
                menuScanSection.MaxY = paddedItemIconLocation.Y + scanBuffer;
                #endregion

                var dropScanData = _imageProcessor.SearchScreenForImages(MenuControls.RightClickMenu.Drop.ToList(), menuScanSection, getSingleOccurrence: true);

                if (dropScanData.Any())
                {
                    var dsdLocation = dropScanData.FirstOrDefault().MatchLocations.FirstOrDefault();

                    var paddedDropLocation = AddPoints(dsdLocation, MenuControls.RightClickMenu.Drop.CenterOfImage);

                    IoSimulator.ClickLocation(paddedDropLocation);
                }

                IoSimulator.PauseThread(750);
            }
        }