示例#1
0
        /// <summary>
        /// Locates a bank booth in the Seers' Village bank
        /// </summary>
        /// <param name="bankBooth"></param>
        /// <returns>true if a bank booth is found</returns>
        internal bool LocateBankBoothSeersVillage(out Blob bankBooth)
        {
            bankBooth = null;
            List <Blob> possibleBankBooths = Vision.LocateObjects(RGBHSBRangeFactory.BankBoothSeersVillage(), MinBankBoothSize, MaxBankBoothSize);

            if (possibleBankBooths == null)
            {
                return(false);
            }

            List <Blob> bankBooths = new List <Blob>();

            foreach (Blob booth in possibleBankBooths)
            {
                double widthToHeight = booth.Width / (double)booth.Height;
                if (Numerical.WithinBounds(widthToHeight, 2.3, 3.2))
                {
                    bankBooths.Add(booth);
                }
            }

            if (bankBooths.Count != 9)
            {
                return(false);
            }
            bankBooths.Sort(new BlobHorizontalComparer());
            bankBooths.RemoveAt(5); //remove closed bank booths
            bankBooths.RemoveAt(4);
            bankBooths.RemoveAt(2);
            bankBooth = Blob.ClosestBlob(Screen.Center, bankBooths);
            return(true);
        }