示例#1
0
        public override void OnEnable()
        {
            base.OnEnable();
            _previousFrameInfo      = new CharacterInfo();
            _currentInfo            = new CharacterInfo();
            _partyBarPoints         = new PointGroup(PointExt.New(393, 47), PointExt.New(599, 52), PointExt.New(605, 45));
            _partyBarPointsOffseted = _partyBarPoints.OffsetCopy(0, 40);
            _previousFrameInfo      = new CharacterInfo();
            _hpBar = new ResourceBar(27, 217, 36, ResourceBar.EResourceType.Hp);
            _hpBar.ColorDiffTolerance = 5;
            _mpBar = new ResourceBar(27, 217, 53, ResourceBar.EResourceType.Mana);
            _mpBar.ColorDiffTolerance = 5;
            _partyBar   = new ResourceBar(406, 598, 49, ResourceBar.EResourceType.PartyMemberHp);
            _monsterBar = new ResourceBar(406, 598, 49, ResourceBar.EResourceType.MonsterHp);
            _monsterBar.NbConsistencyFrame = 1;

            CalculateAttributes();
            _currentInfo.InitialPosition = _currentInfo.Position;
            _previousFrameInfo.CopyFrom(_currentInfo);
        }
示例#2
0
        public List <Point> ProcessImage(int maxEncounters = 1)
        {
            List <Point> points     = new List <Point>();
            int          encounters = 0;
            PointGroup   pointGroup = group.OffsetCopy(0, 0);
            LockBitmap   lockB      = ImgUtils.GetLockBitmap(rect);

            lockB.LockBits();
            Point fartherDownRight = GetFartherPoint();
            int   x = 0;


            while (encounters < maxEncounters && (fartherDownRight.X + x) < lockB.Width)
            {
                int y = 0;
                while (encounters < maxEncounters && (fartherDownRight.Y + y) < lockB.Height)
                {
                    bool valid = true;
                    foreach (var pointDiff in pointDiffs)
                    {
                        Point p1   = GetCorrespondingPoint(pointGroup, pointDiff.Key.Item1, x, y);
                        Point p2   = GetCorrespondingPoint(pointGroup, pointDiff.Key.Item2, x, y);
                        Color c1   = lockB.GetPixel(p1.X, p1.Y);
                        Color c2   = lockB.GetPixel(p2.X, p2.Y);
                        int   diff = ColorUtils.ColorDiff(c1, c2);
                        if (diff != pointDiff.Value)
                        {
                            valid = false;
                            break;
                        }
                    }

                    if (valid) // Check color diffs
                    {
                        foreach (var colorDiff in colorDiffs)
                        {
                            foreach (var point in pointGroup.Points)
                            {
                                Point relative = new Point(point.X - x, point.Y - y);
                                if (relative == colorDiff.Key.Item1)
                                {
                                    int diff = ColorUtils.ColorDiff(lockB.GetPixel(point.X, point.Y), colorDiff.Key.Item2);
                                    if (diff != colorDiff.Value)
                                    {
                                        valid = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (valid)
                    {
                        encounters++;
                        points.Add(new Point(rect.X + x, rect.Y + y));
                    }

                    pointGroup.OffsetY(1);
                    ++y;
                }
                pointGroup.Offset(1, -y);
                ++x;
            }
            lockB.UnlockBits();


            return(points);
        }