Exemple #1
0
        //Checking around each jewel in each list it is in.
        public void CheckAround(JewelList jewelList, Jewel jewel)
        {
            jewel.Checked = true;

            //Add the jewel and its list in the Found lists.
            FoundJewels.Add(new Point(jewelLists.IndexOf(jewelList), jewelList.jewelList.IndexOf(jewel)));
            Found.Add(jewel);
            FoundList.Add(jewelLists.IndexOf(jewelList));
            jewel.found = true;
            matchedJewels++;

            //Check in each direction. If jewel in that direction has the same Name (is the same jewel), rerun this function on that.
            foreach (var direction in directions)
            {
                int x = jewelLists.IndexOf(jewelList) + direction.X;
                int y = jewelList.jewelList.IndexOf(jewel) + direction.Y;
                if (x >= 0 && x < WorldSize.X && y >= 0 && y < WorldSize.Y)
                {
                    Jewel target = jewelLists[x].jewelList[y];
                    if (target.Checked == false && target.Name == jewel.Name)
                    {
                        CheckAround(jewelLists[x], jewelLists[x].jewelList[y]);
                    }
                }
            }
        }
        //Checking around each jewel in each list it is in.
        public void CheckAround(JewelList jewelList, Jewel jewel)
        {
            jewel.Checked = true;

            //Add the jewel and its list in the Found lists.
            FoundJewels.Add(new Point(jewelLists.IndexOf(jewelList), jewelList.jewelList.IndexOf(jewel)));
            Found.Add(jewel);
            FoundList.Add(jewelLists.IndexOf(jewelList));
            jewel.found = true;
            matchedJewels++;

            //Check in each direction. If jewel in that direction has the same Name (is the same jewel), rerun this function on that.
            foreach (var direction in directions)
            {
                int x = jewelLists.IndexOf(jewelList) + direction.X;
                int y = jewelList.jewelList.IndexOf(jewel) + direction.Y;
                if (x >= 0 && x < WorldSize.X && y >= 0 && y < WorldSize.Y)
                {
                    Jewel target = jewelLists[x].jewelList[y];
                    if (target.Checked == false && target.Name == jewel.Name)
                    {
                        CheckAround(jewelLists[x], jewelLists[x].jewelList[y]);
                    }
                }
            }
        }