예제 #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]);
                    }
                }
            }
        }
예제 #2
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]);
                    }
                }
            }
        }
예제 #3
0
 //When the mouse is pressed.
 public void MouseClick(Point ms)
 {
     //If nothing is falling.
     if (NoneFalling())
     {
         Point mousePosition = new Point(ms.X, ms.Y);
         //If nothing is selected, location of the mouse will determine the selected jewel. If outside map, return. Nothing selected.
         if (selected == false)
         {
             selectedPlace = new Point(ms.X / jewelSize, (int)WorldSize.Y - 1 - (ms.Y / jewelSize));
             if (ms.X / jewelSize > jewelLists.Count || ms.X / jewelSize < 0 || (int)WorldSize.Y - 1 - (ms.Y / jewelSize) > jewelLists[0].jewelList.Count || (int)WorldSize.Y - 1 - (ms.Y / jewelSize) < 0)
             {
                 return;
             }
             Selected = jewelLists[ms.X / jewelSize].jewelList[(int)WorldSize.Y - 1 - (ms.Y / jewelSize)];
             selected = true;
         }
         else if (selected == true)
         {
             //If selected, check in each direction. If pressed on jewel in any direction, switch place on them.
             //And turn on appropriate booleans.
             foreach (var direction in directions)
             {
                 if (selectedPlace.X + direction.X >= jewelLists.Count || selectedPlace.X + direction.X < 0 || selectedPlace.Y + direction.Y >= jewelLists[0].jewelList.Count || selectedPlace.Y + direction.Y < 0)
                 {
                     //... And this is just a fail-safe to make sure the game doesn't check outside the course.
                 }
                 else
                 {
                     if (jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].CollisionRectangle().Contains(mousePosition))
                     {
                         string rememberName = Selected.Name;
                         jewelLists[selectedPlace.X].jewelList[selectedPlace.Y].Name = jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Name;
                         jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Name = rememberName;
                         jewelLists[selectedPlace.X].jewelList[selectedPlace.Y].Load(jewelLists[selectedPlace.X].jewelList[selectedPlace.Y].Name);
                         jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Load(jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Name);
                         //SwitchLocationsOfJewels(switchTargets[0], switchTargets[1]);
                         //SwitchLocationsOfJewels(selectedPlace, new Point(selectedPlace.X + direction.X, selectedPlace.Y + direction.Y));
                         Checkie          = true;
                         Switched         = true;
                         switchTargets[0] = selectedPlace;
                         switchTargets[1] = new Point(selectedPlace.X + direction.X, selectedPlace.Y + direction.Y);
                         break;
                     }
                 }
             }
             selected = false;
         }
     }
     //Turn game back to neutral state.
     ResetCheck();
 }
예제 #4
0
        public void CheckAround(List<Jewel> jewels, Jewel jewel)
        {
            jewel.Checked = true;
            jewel.found = true;
            numberFound++;
            int lineX = JewelLines.IndexOf(jewels);
            int lineY = jewels.IndexOf(jewel);

            foreach (var direction in directions)
            {
                int X = lineX + direction.X;
                int Y = lineY + direction.Y;
                if (X > 0 && Y > 0 && X < gridSize.X && Y < gridSize.Y)
                {
                    if (JewelLines[X][Y].Checked == false && JewelLines[X][Y].Name == jewel.Name)
                    {
                        CheckAround(JewelLines[X], JewelLines[X][Y]);
                    }
                }
            }

            /*if (JewelLines[lineX - 1][lineY].Checked == false && JewelLines[lineX - 1][lineY].Name == jewel.Name)
            {
                CheckAround(JewelLines[lineX - 1], JewelLines[lineX - 1][lineY]);
            }
            if (JewelLines[lineX + 1][lineY].Checked == false && JewelLines[lineX + 1][lineY].Name == jewel.Name)
            {
                CheckAround(JewelLines[lineX + 1], JewelLines[lineX + 1][lineY]);
            }
            if (JewelLines[lineX][lineY - 1].Checked == false && JewelLines[lineX][lineY - 1].Name == jewel.Name)
            {
                CheckAround(JewelLines[lineX], JewelLines[lineX][lineY - 1]);
            }
            if (JewelLines[lineX][lineY + 1].Checked == false && JewelLines[lineX][lineY + 1].Name == jewel.Name)
            {
                CheckAround(JewelLines[lineX], JewelLines[lineX][lineY + 1]);
            }*/
        }
예제 #5
0
        public void CheckAround(List <Jewel> jewels, Jewel jewel)
        {
            jewel.Checked = true;
            jewel.found   = true;
            numberFound++;
            int lineX = JewelLines.IndexOf(jewels);
            int lineY = jewels.IndexOf(jewel);

            foreach (var direction in directions)
            {
                int X = lineX + direction.X;
                int Y = lineY + direction.Y;
                if (X > 0 && Y > 0 && X < gridSize.X && Y < gridSize.Y)
                {
                    if (JewelLines[X][Y].Checked == false && JewelLines[X][Y].Name == jewel.Name)
                    {
                        CheckAround(JewelLines[X], JewelLines[X][Y]);
                    }
                }
            }

            /*if (JewelLines[lineX - 1][lineY].Checked == false && JewelLines[lineX - 1][lineY].Name == jewel.Name)
             * {
             *  CheckAround(JewelLines[lineX - 1], JewelLines[lineX - 1][lineY]);
             * }
             * if (JewelLines[lineX + 1][lineY].Checked == false && JewelLines[lineX + 1][lineY].Name == jewel.Name)
             * {
             *  CheckAround(JewelLines[lineX + 1], JewelLines[lineX + 1][lineY]);
             * }
             * if (JewelLines[lineX][lineY - 1].Checked == false && JewelLines[lineX][lineY - 1].Name == jewel.Name)
             * {
             *  CheckAround(JewelLines[lineX], JewelLines[lineX][lineY - 1]);
             * }
             * if (JewelLines[lineX][lineY + 1].Checked == false && JewelLines[lineX][lineY + 1].Name == jewel.Name)
             * {
             *  CheckAround(JewelLines[lineX], JewelLines[lineX][lineY + 1]);
             * }*/
        }
예제 #6
0
 //Remove a jewel.
 public void RemoveJewel(Jewel jewel, int index)
 {
     jewelList.Remove(jewel);
 }
예제 #7
0
 //Remove a jewel.
 public void RemoveJewel(Jewel jewel, int index)
 {
     jewelList.Remove(jewel);
 }
예제 #8
0
 //When the mouse is pressed.
 public void MouseClick(Point ms)
 {
     //If nothing is falling.
     if (NoneFalling())
     {
         Point mousePosition = new Point(ms.X, ms.Y);
         //If nothing is selected, location of the mouse will determine the selected jewel. If outside map, return. Nothing selected.
         if (selected == false)
         {
             selectedPlace = new Point(ms.X / jewelSize, (int)WorldSize.Y - 1 - (ms.Y / jewelSize));
             if (ms.X / jewelSize > jewelLists.Count || ms.X / jewelSize < 0 || (int)WorldSize.Y - 1 - (ms.Y / jewelSize) > jewelLists[0].jewelList.Count || (int)WorldSize.Y - 1 - (ms.Y / jewelSize) < 0)
             {
                 return;
             }
             Selected = jewelLists[ms.X / jewelSize].jewelList[(int)WorldSize.Y - 1 - (ms.Y / jewelSize)];
             selected = true;
         }
         else if (selected == true)
         {
             //If selected, check in each direction. If pressed on jewel in any direction, switch place on them.
             //And turn on appropriate booleans.
             foreach (var direction in directions)
             {
                 if (selectedPlace.X + direction.X >= jewelLists.Count || selectedPlace.X + direction.X < 0 || selectedPlace.Y + direction.Y >= jewelLists[0].jewelList.Count || selectedPlace.Y + direction.Y < 0)
                 {
                     //... And this is just a fail-safe to make sure the game doesn't check outside the course.
                 }
                 else
                 {
                     if (jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].CollisionRectangle().Contains(mousePosition))
                     {
                         string rememberName = Selected.Name;
                         jewelLists[selectedPlace.X].jewelList[selectedPlace.Y].Name = jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Name;
                         jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Name = rememberName;
                         jewelLists[selectedPlace.X].jewelList[selectedPlace.Y].Load(jewelLists[selectedPlace.X].jewelList[selectedPlace.Y].Name);
                         jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Load(jewelLists[selectedPlace.X + direction.X].jewelList[selectedPlace.Y + direction.Y].Name);
                         //SwitchLocationsOfJewels(switchTargets[0], switchTargets[1]);
                         //SwitchLocationsOfJewels(selectedPlace, new Point(selectedPlace.X + direction.X, selectedPlace.Y + direction.Y));
                         Checkie = true;
                         Switched = true;
                         switchTargets[0] = selectedPlace;
                         switchTargets[1] = new Point(selectedPlace.X + direction.X, selectedPlace.Y + direction.Y);
                         break;
                     }
                 }
             }
             selected = false;
         }
     }
     //Turn game back to neutral state.
     ResetCheck();
 }