public static void Lesson9(PuzzleBox box, MasterGrid grid) { introText = "" + "Okay! Let's combine what we've learned about sets\n" + "and bonus bubbles. See those three green bubbles\n" + "in the upper right?:" + "If we can match our two green bubbles at the\n" + "bottom with them, we can pop 5 bubbles at once!:" + "They'll also get replaced by two bonus bubbles,\n" + "which we can use to get another set!"; successText = "Nice! That was worth a lot of points!"; failureText = "" + "Oops! This one is tricky. Don't forget to use\n" + "The shoulder buttons for rotations and the\n" + "triggers to push and pull the bubbles.:" + "Try and get match the bubbles in the upper\n" + "right first!"; restrictions = ControlRestrictions.None; Clear(box, grid); grid[3, 0] = new PuzzleNode(Color.Green); grid[4, 1] = new PuzzleNode(Color.Green); grid[4, 2] = new PuzzleNode(Color.Green); grid[0, 2] = new PuzzleNode(Color.Green); box[1, 2, 1] = new PuzzleNode(Color.Green); box[1, 2, 2] = new PuzzleNode(Color.Green); }
public static void Lesson7(PuzzleBox box, MasterGrid grid) { introText = "" + "Another advanced topic is bonus bubbles! You\n" + "may have noticed that when you match bubbles,\n" + "new ones slide in to take their place.:" + "But what happens if you match against two\n" + "bubbles in different tentacles at the same\n" + "time?:" + "This will create a bonus bubble of the same\n" + "color. Matching bonus bubbles will multiply\n" + "the score of the set by 2!:" + "Try rotating this orange bubble into the\n" + "lower left corner!"; successText = "" + "Great! In addition to this bubble being\n" + "worth bonus points, you popped 3 outer\n" + "bubbles with just one inner bubble.:" + "That's a useful skill!"; failureText = "" + "Oops! Try popping the bubbles in the lower\n" + "left corner first. This will give you a bonus\n" + "bubble!"; restrictions = ControlRestrictions.None; Clear(box, grid); grid[0, 3] = new PuzzleNode(Color.Orange); grid[1, 4] = new PuzzleNode(Color.Orange); grid[4, 1] = new PuzzleNode(Color.Orange); box[0, 2, 2] = new PuzzleNode(Color.Orange); }
public static void Lesson8(PuzzleBox box, MasterGrid grid) { introText = "" + "This technique will be especially important in\n" + "Challenge Mode. Try to match all the bubbles\n" + "here.:" + "To do so, you'll need to get the bonus bubbles\n" + "first again! Focus on the corners that contain\n" + "two bubbles of the same color.:" + "Also, don't forget the basics. Remember you can\n" + "use the left and right triggers to push and pull\n" + "the bubbles."; successText = "" + "Perfect! You're almost ready to get started\n" + "for real."; failureText = "" + "Oops! Remember, if you match one bubble against\n" + "two tentacles at the same time, it will be\n" + "replaced by a bonus bubble.:" + "You can reuse the bonus bubbles to make more\n" + "matches. Try getting the bonus bubbles first!"; restrictions = ControlRestrictions.None; Clear(box, grid); box[0, 1, 2] = new PuzzleNode(Color.Yellow); box[0, 0, 0] = new PuzzleNode(Color.Magenta); grid[3, 0] = new PuzzleNode(Color.Magenta); grid[4, 1] = new PuzzleNode(Color.Magenta); grid[1, 4] = new PuzzleNode(Color.Magenta); grid[0, 1] = new PuzzleNode(Color.Yellow); grid[1, 0] = new PuzzleNode(Color.Yellow); grid[3, 4] = new PuzzleNode(Color.Yellow); }
public static void Lesson5(PuzzleBox box, MasterGrid grid) { introText = "" + "This next lesson is tricky. Notice the two\n" + "yellow bubbles in Mister Jellyfish's body?:" + "They're right next to each other, but they\n" + "haven't popped!:" + "That's because to pop bubbles, you need to\n" + "match bubbles from the Jellyfish's body with\n" + "the bubbles in the tentacles.:" + "Try to align these two yellow bubbles with the\n" + "yellow bubble in the tentacle to form a\n" + "straight line."; successText = "" + "You got it. Remember, sets of bubbles will\n" + "only pop if they form a straight line. So be\n" + "careful!"; failureText = "" + "Almost! Only sets of bubbles that form a\n" + "straight line will match."; Clear(box, grid); grid[0, 1] = new PuzzleNode(Color.Yellow); box[0, 2, 2] = new PuzzleNode(Color.Yellow); box[0, 2, 1] = new PuzzleNode(Color.Yellow); restrictions = ControlRestrictions.None; }
public static void Lesson6(PuzzleBox box, MasterGrid grid) { introText = "" + "Scoring big sets is tricky. Lets practice some\n" + "more. Try to match all of the bubbles using sets\n" + "of 3 or more!"; successText = "" + "Awesome! These combos are worth way more points\n" + "than just matching two bubbles at a time.:" + "If you want to be a great Jellyfish doctor,\n" + "you'll need to master spotting when you can\n" + "match these kinds of sets!"; failureText = "" + "Oops! Remember, you need to rotate the bubbles\n" + "so that all of the same colored bubbles are in\n" + "a straight line!:" + "Use the Right Control Stick to look around and\n" + "get a better view of things!:" + "Finally, don't forget about using the Shoulder\n" + "Buttons for rotations."; Clear(box, grid); restrictions = ControlRestrictions.None; grid[1, 0] = new PuzzleNode(Color.Green); grid[0, 2] = new PuzzleNode(Game.jellyBlue); grid[4, 3] = new PuzzleNode(Color.Yellow); box[2, 0, 2] = new PuzzleNode(Color.Green); box[2, 1, 2] = new PuzzleNode(Color.Green); box[2, 2, 2] = new PuzzleNode(Color.Green); box[1, 2, 0] = new PuzzleNode(Game.jellyBlue); box[1, 2, 1] = new PuzzleNode(Game.jellyBlue); box[0, 0, 2] = new PuzzleNode(Color.Yellow); box[0, 1, 2] = new PuzzleNode(Color.Yellow); }
public static void Lesson4(PuzzleBox box, MasterGrid grid) { introText = "" + "Now let's try and put it together! To match\n" + "these bubbles, you'll need to use the Left and\n" + "Right Triggers to push and pull them.:" + "But, you'll also need to use the Left Control\n" + "Stick and Shoulder Buttons to rotate them!:" + "Try and match all the bubbles!"; successText = "" + "That's perfect!"; failureText = "BUG!"; Clear(box, grid); restrictions = ControlRestrictions.None; grid[0, 1] = new PuzzleNode(Color.Green); grid[2, 0] = new PuzzleNode(Color.Orange); grid[4, 2] = new PuzzleNode(Color.Magenta); grid[3, 4] = new PuzzleNode(Game.jellyBlue); grid[4, 1] = new PuzzleNode(Color.Yellow); grid[1, 4] = new PuzzleNode(Color.Red); box[0, 0, 0] = new PuzzleNode(Color.Red); box[2, 2, 2] = new PuzzleNode(Color.Yellow); box[1, 2, 2] = new PuzzleNode(Color.Magenta); box[0, 2, 0] = new PuzzleNode(Game.jellyBlue); box[0, 0, 1] = new PuzzleNode(Color.Green); box[2, 1, 1] = new PuzzleNode(Color.Orange); }
// Replaces all marked orbs with new random orbs. public static bool Replace(PuzzleBox box, MasterGrid grid) { bool anythingChanged = false; AddBoxToGrid(box, grid); for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (grid[x, y].marked == true) { grid[x, y] = ReplaceHelper(x, y, grid); anythingChanged = true; } } } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (grid[x, y].marked == true) { grid[x, y] = grid[x, y].replace_orb; grid[x, y].marked = true; } } } SetBoxFromGrid(box, grid); return(anythingChanged); }
public static void Lesson2(PuzzleBox box, MasterGrid grid) { controlLessonIndex = 0; introText = "" + "Instead of using the Left Control Stick, you\n" + "can use the Left and Right Shoulder Buttons.\n" + "Try it now!:" + "Good! This will perform a different type of\n" + "rotation. Use the Shoulder Buttons to match\n" + "these bubbles!"; successText = "" + "Nice! If you can master all 6 types of these\n" + "rotations, you'll do great!"; restrictions = ControlRestrictions.ShouldersOnly; Clear(box, grid); grid[0, 1] = new PuzzleNode(Color.Yellow); grid[3, 4] = new PuzzleNode(Color.Green); grid.queues[0, 1][1] = new PuzzleNode(Color.Magenta); grid.queues[0, 1][0] = new PuzzleNode(Color.Red); grid.queues[3, 4][1] = new PuzzleNode(Color.Red); grid.queues[3, 4][0] = new PuzzleNode(Color.Magenta); grid[2, 4] = new PuzzleNode(Color.Orange); grid.queues[2, 4][1] = new PuzzleNode(Game.jellyBlue); box[0, 0, 2] = new PuzzleNode(Color.Yellow); box[0, 0, 0] = new PuzzleNode(Color.Green); box[0, 1, 2] = new PuzzleNode(Color.Orange); box[0, 1, 0] = new PuzzleNode(Game.jellyBlue); }
public static void Lesson3(PuzzleBox box, MasterGrid grid) { controlLessonIndex = 0; introText = "" + "In addition, you can use the Left and Right\n" + "Triggers to push and pull the bubbles in the\n" + "Jellyfish's body. Try it now!:" + "Great! That way, you can change which layer of\n" + "bubbles aligns with the tentacles.:" + "Now, use the Left and Right Triggers to match\n" + "the bubbles!"; successText = "" + "Great! With the Left Control Stick, Shoulder\n" + "Buttons, and Triggers, you can reorient the\n" + "bubbles however you want!:" + "If you need a reminder of the controls, take a\n" + "look around the top and bottom left of the\n" + "screen for a review."; Clear(box, grid); restrictions = ControlRestrictions.TriggersOnly; grid[0, 1] = new PuzzleNode(Color.Red); grid.queues[0, 1][1] = new PuzzleNode(Color.Magenta); grid[3, 0] = new PuzzleNode(Color.Yellow); grid[4, 3] = new PuzzleNode(Game.jellyBlue); grid[1, 4] = new PuzzleNode(Color.Green); box[0, 0, 0] = new PuzzleNode(Color.Magenta); box[1, 0, 0] = new PuzzleNode(Color.Red); box[2, 2, 0] = new PuzzleNode(Color.Green); box[1, 0, 2] = new PuzzleNode(Color.Yellow); box[2, 2, 2] = new PuzzleNode(Game.jellyBlue); }
public static void Lesson1(PuzzleBox box, MasterGrid grid) { controlLessonIndex = 1; introText = "" + "Look at all these bubbles inside Mister\n" + "Jellyfish! The colored ones are toxic! Let's\n" + "see if we can get rid of them.:" + "You can use the Left Control Stick to rotate\n" + "the bubbles in Mister Jellyfish's body.\n" + "Try it now!:" + "Perfect! Try to match up the colored bubbles\n" + "in his body with the bubbles in his tentacles!"; successText = "" + "Great job! When you aligned the bubbles in\n" + "his body with the bubbles in his tentacles,\n" + "the bubbles popped!"; Clear(box, grid); restrictions = ControlRestrictions.StickOnly; grid[0, 1] = new PuzzleNode(Color.Yellow); grid[3, 4] = new PuzzleNode(Color.Green); grid.queues[0, 1][1] = new PuzzleNode(Color.Magenta); grid.queues[0, 1][0] = new PuzzleNode(Color.Red); grid.queues[3, 4][1] = new PuzzleNode(Color.Red); grid.queues[3, 4][0] = new PuzzleNode(Color.Magenta); grid[2, 4] = new PuzzleNode(Color.Orange); grid.queues[2, 4][1] = new PuzzleNode(Game.jellyBlue); box[0, 0, 2] = new PuzzleNode(Color.Yellow); box[0, 0, 0] = new PuzzleNode(Color.Green); box[0, 1, 2] = new PuzzleNode(Color.Orange); box[0, 1, 0] = new PuzzleNode(Game.jellyBlue); }
public static void Lesson0(PuzzleBox box, MasterGrid grid) { Clear(box, grid); box[1, 2, 2] = new PuzzleNode(Color.Red); box[0, 2, 2] = new PuzzleNode(Color.Red); grid[3, 0] = new PuzzleNode(Color.Red); }
public static void LoadLevel(string fileName, PuzzleBox box, MasterGrid grid) { String loadPath = "LevelData\\" + fileName; try { r = new StreamReader(TitleContainer.OpenStream(loadPath)); } catch (Exception e) { Console.WriteLine(e); } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (grid.queues[x, y] != null) { grid.queues[x, y] = new List <PuzzleNode>(); } } } for (;;) { String s = r.ReadLine(); if (s == null) { return; } string[] data = s.Split(','); if (data[0] == "WIN") { } if (data[0] == "LOSE") { } if (data[0] == "BOX") { int x = Convert.ToInt32(data[1]); int y = Convert.ToInt32(data[2]); int z = Convert.ToInt32(data[3]); box[x, y, z] = new PuzzleNode(data[4]); } else if (data[0] == "GRID") { int x = Convert.ToInt32(data[1]); int y = Convert.ToInt32(data[2]); grid[x, y] = new PuzzleNode(data[3]); } else if (data[0] == "QUEUE") { int x = Convert.ToInt32(data[1]); int y = Convert.ToInt32(data[2]); int z = Convert.ToInt32(data[3]); grid.queues[x, y].Add(new PuzzleNode(data[4])); } } }
private static void SetBoxFromGrid(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { box[box.activeZ, y, x] = grid[x + boxOffset, y + boxOffset]; } } }
private static void AddBoxToGrid(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { grid[x + boxOffset, y + boxOffset] = box[box.activeZ, y, x]; } } }
public static void Lesson10(PuzzleBox box, MasterGrid grid) { introText = "Almost done! Lets do one more.:" + "There are three blue bubbles in the back right \n" + "of Mister Jellyfish. There also 5 blue bubbles \n" + "in the right tentacles.:" + "If you can bring all three of those blue bubbles \n" + "to the front, you can get 3 bonus bubbles to use \n" + "for a second set!"; successText = "" + "Super! Looks like you're ready to get to work.\n" + "First, lets go over a few more quick things!:" + "There are three different types of Jellyfish\n" + "surgery to choose from, each of which poses\n" + "unique challenges.:" + "In Emergency mode, you'll race against the clock\n" + "to pop as many bubbles as you can.:" + "Scoring sets of 3 or more bubbles at a time is\n" + "key to getting a high score.:" + "Operation mode is similar, but you can relax and\n" + "take your time. However, you'll have a limited\n" + "number of moves to work with.:" + "Time isn't a factor, but you'll need to plan\n" + "your moves carefully and be efficient to get\n" + "a good score.:" + "Finally, Challenge mode will give you some\n" + "tricky puzzles to solve.:" + "You'll need to use what you've learned here to\n" + "pop all of the bubbles in each patient. If you make\n" + "a wrong move, you might get stuck!:" + "Luckily, in Challenge mode, you can press B to\n" + "undo your last move if you make a mistake.:" + "You'll be awarded a rating after each patient.\n" + "If you earn 3 stars, your patient will make a\n" + "full recovery and return to the sea!:" + "Try to save them all!\n"; failureText = "" + "Oops! Try to rotate all three blue bubbles in\n" + "back to the front right. Then use the three\n" + "bonus bubbles to make a second set.:" + "Don't forget you can use the Right Control Stick\n" + "to get a better view of bubbles in the back!"; restrictions = ControlRestrictions.None; Clear(box, grid); box[2, 0, 2] = new PuzzleNode(Game.jellyBlue); box[2, 1, 2] = new PuzzleNode(Game.jellyBlue); box[2, 2, 2] = new PuzzleNode(Game.jellyBlue); grid[3, 0] = new PuzzleNode(Game.jellyBlue); grid[3, 4] = new PuzzleNode(Game.jellyBlue); grid[4, 1] = new PuzzleNode(Game.jellyBlue); grid[4, 2] = new PuzzleNode(Game.jellyBlue); grid[4, 3] = new PuzzleNode(Game.jellyBlue); grid[1, 4] = new PuzzleNode(Game.jellyBlue); }
public static void SaveLevel(PuzzleBox box, MasterGrid grid) { try { w = new StreamWriter(TitleContainer.OpenStream(savePath)); } catch (Exception e) { Console.WriteLine(e); } for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { PuzzleNode p = box[x, y, z]; w.WriteLine("BOX," + x + "," + y + "," + z + "," + p.ToString()); } } } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { PuzzleNode p = grid[x, y]; w.WriteLine("GRID," + x + "," + y + "," + p.ToString()); } } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (grid.queues[x, y] != null) { for (int z = 0; z < grid.queues[x, y].Count; z++) { PuzzleNode p = grid.queues[x, y][z]; w.WriteLine("QUEUE," + x + "," + y + "," + z + "," + p.ToString()); } } } } w.Flush(); w.Close(); }
public PuzzleBox Copy() { PuzzleBox newBox = new PuzzleBox(); for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { for (int z = 0; z < size; z++) { newBox[x, y, z] = arr[x, y, z].Copy(); } } } newBox.activeZ = activeZ; return(newBox); }
// Clears state. Called when returning to ready state. public static void Clear(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { box[x, y, z].ClearMarking(); } } } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { //if (x == 0 || x == gridSize-1 || y == 0 || y == gridSize-1) if (grid.queues[x, y] != null) { for (int i = 0; i < grid[x, y].replace_distance; i++) { grid.queues[x, y].RemoveAt(0); if (Game.currentSettings.refillQueues) { PuzzleNode p = new PuzzleNode(); while (p.color == grid.queues[x, y][grid.queues[x, y].Count - 1].color) { p = new PuzzleNode(); } grid.queues[x, y].Add(p); } else { grid.queues[x, y].Add(new PuzzleNode(Color.Gray)); } } for (int i = 0; i < grid.queues[x, y].Count; i++) { grid.queues[x, y][i].ClearMarking(); } } grid[x, y].ClearMarking(); } } }
public static void UpdateToggleState(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { if (box[x, y, z].toggleOrb) { Color temp = box[x, y, z].color; box[x, y, z].color = box[x, y, z].toggleColor; box[x, y, z].toggleColor = temp; } } } } }
public static void LessonBonus(PuzzleBox box, MasterGrid grid) { introText = "" + "We'll learn some advanced techniques soon,\n" + "but matching bubbles like this is the core\n" + "skill for any Jellyfish surgeon.:" + "So let's practice this some more!\n" + "Also, you can use the Right Control Stick at any\n" + "time to shift the camera angle.:" + "I like to set the camera so that all 27 bubbles\n" + "in the body are visible at the same time.:" + "But you should do whatever feels comfortable!\n" + "Now, match those bubbles!"; successText = "" + "Way to go! You're getting the hang of it!\n" + "Let's talk about some more advanced topics!"; failureText = "BUG!"; Clear(box, grid); restrictions = ControlRestrictions.None; grid[2, 0] = new PuzzleNode(Color.Red); grid[3, 0] = new PuzzleNode(Color.Orange); grid[3, 4] = new PuzzleNode(Color.Orange); grid.queues[3, 4][0] = new PuzzleNode(Game.jellyBlue); grid[0, 1] = new PuzzleNode(Color.Magenta); grid.queues[3, 0][1] = new PuzzleNode(Game.jellyBlue); grid[1, 0] = new PuzzleNode(Game.jellyBlue); grid[0, 2] = new PuzzleNode(Color.Yellow); grid.queues[0, 2][0] = (new PuzzleNode(Color.Red)); grid[4, 2] = new PuzzleNode(Color.Green); grid[2, 4] = new PuzzleNode(Color.Yellow); grid.queues[4, 2][0] = (new PuzzleNode(Color.Yellow)); grid.queues[4, 2][1] = (new PuzzleNode(Color.Red)); box[1, 1, 0] = new PuzzleNode(Color.Red); box[1, 0, 2] = new PuzzleNode(Color.Magenta); box[0, 2, 2] = new PuzzleNode(Game.jellyBlue); box[0, 1, 2] = new PuzzleNode(Color.Yellow); box[0, 0, 1] = new PuzzleNode(Color.Green); box[2, 0, 0] = new PuzzleNode(Color.Orange); box[2, 2, 2] = new PuzzleNode(Color.Orange); }
public static bool AllGray(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { if (box[x, y, z].color != Color.Gray && box[x, y, z].color != Game.currentSettings.dangerColor) { return(false); } if (box[x, y, z].toggleColor != Color.Gray && box[x, y, z].toggleColor != Game.currentSettings.dangerColor) { return(false); } } } } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (grid.queues[x, y] != null) { for (int i = 0; i < grid.queues[x, y].Count; i++) { if (grid.queues[x, y][i].color != Color.Gray && grid.queues[x, y][i].color != Game.currentSettings.dangerColor) { return(false); } } } if (grid[x, y].color != Color.Gray && grid[x, y].color != Game.currentSettings.dangerColor) { return(false); } } } return(true); }
public static void UpdateTimeCountdown(PuzzleBox box, MasterGrid grid, int elapsedTime) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { if (box[x, y, z].timeCountdownOrb) { box[x, y, z].countdown -= elapsedTime; if (box[x, y, z].countdown <= 0) { box[x, y, z].timeCountdownOrb = false; box[x, y, z].color = Color.Gray; } } } } } }
public static void UpdateMoveCountdown(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { if (box[x, y, z].moveCountdownOrb) { box[x, y, z].countdown--; if (box[x, y, z].countdown == 0) { box[x, y, z].moveCountdownOrb = false; box[x, y, z].color = Color.Gray; } } } } } }
// Completely randomizes the entire box and grid. public static void Reset(PuzzleBox box, MasterGrid grid) { for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { //if (box[x, y, z].moveCountdownOrb == true) box[x, y, z].color = Color.Gray; //if (box[x, y, z].timeCountdownOrb == true) box[x, y, z].color = Color.Gray; box[x, y, z] = new PuzzleNode(); box[x, y, z].marked = true; //} } } } Random r = new Random(); for (int i = 0; i < Game.currentSettings.grayOrbStart;) { int x = r.Next(3); int y = r.Next(3); int z = r.Next(3); if (box[x, y, z].color != Color.Gray) { box[x, y, z] = new PuzzleNode(Color.Gray); box[x, y, z].marked = true; i++; } } for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { grid[x, y] = new PuzzleNode(); grid[x, y].marked = true; } } }
public static int GetMaxReplaceDistance(PuzzleBox box, MasterGrid grid) { AddBoxToGrid(box, grid); int max_distance = 0; for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (IsWildCard(grid[x, y]) == true && max_distance == 0) { max_distance = 1; } if (grid[x, y].replace_distance > max_distance) { max_distance = grid[x, y].replace_distance; } } } SetBoxFromGrid(box, grid); return(max_distance); }
//Puzzle Load public static void LoadLesson(int index, PuzzleBox box, MasterGrid grid) { active = true; introIndex = 0; successIndex = 0; failureIndex = 0; controlLessonIndex = -5; phase = TutorialPhase.Intro; switch (index) { case (0): Lesson1(box, grid); break; case (1): Lesson2(box, grid); break; case (2): Lesson3(box, grid); break; case (3): Lesson4(box, grid); break; case (4): LessonBonus(box, grid); break; case (5): Lesson5(box, grid); break; case (6): Lesson6(box, grid); break; case (7): Lesson7(box, grid); break; case (8): Lesson8(box, grid); break; case (9): Lesson9(box, grid); break; case (10): Lesson10(box, grid); break; default: return; } if (loaded == true) { Mark(box, grid); } else { loaded = true; } }
public static void Mark(PuzzleBox box, MasterGrid grid) { box.Mark(); grid.Mark(); }
// Checks if any valid move exists. public static bool HasValidMove(PuzzleBox box, MasterGrid grid) { List <Color> sideColorsBox1 = new List <Color>(); List <Color> sideColorsBox2 = new List <Color>(); List <Color> cornerColorsBox = new List <Color>(); List <Color> faceColorsBox = new List <Color>(); List <Color> sideColorsGrid = new List <Color>(); List <Color> cornerColorsGrid = new List <Color>(); // Get potential box colors for (int x = 0; x < boxSize; x++) { for (int y = 0; y < boxSize; y++) { for (int z = 0; z < boxSize; z++) { PuzzleNode p = box[x, y, z]; int centerCount = 0; if (x == 1) { centerCount++; } if (y == 1) { centerCount++; } if (z == 1) { centerCount++; } if (centerCount == 0) { cornerColorsBox.Add(p.color); if (p.toggleOrb) { cornerColorsBox.Add(p.toggleColor); } } if (centerCount == 1) { sideColorsBox1.Add(p.color); sideColorsBox2.Add(p.color); if (p.toggleOrb) { sideColorsBox1.Add(p.toggleColor); sideColorsBox2.Add(p.toggleColor); } } if (centerCount == 2) { faceColorsBox.Add(p.color); if (p.toggleOrb) { faceColorsBox.Add(p.toggleColor); } } } } } // Get potential grid colors cornerColorsGrid.Add(grid[1, 0].color); if (grid[1, 0].toggleOrb) { cornerColorsGrid.Add(grid[1, 0].toggleColor); } cornerColorsGrid.Add(grid[3, 0].color); if (grid[3, 0].toggleOrb) { cornerColorsGrid.Add(grid[3, 0].toggleColor); } sideColorsGrid.Add(grid[2, 0].color); if (grid[2, 0].toggleOrb) { cornerColorsGrid.Add(grid[2, 0].toggleColor); } sideColorsGrid.Add(grid[2, 4].color); if (grid[2, 4].toggleOrb) { cornerColorsGrid.Add(grid[2, 4].toggleColor); } cornerColorsGrid.Add(grid[1, 4].color); if (grid[1, 4].toggleOrb) { cornerColorsGrid.Add(grid[1, 4].toggleColor); } cornerColorsGrid.Add(grid[3, 4].color); if (grid[3, 4].toggleOrb) { cornerColorsGrid.Add(grid[3, 4].toggleColor); } cornerColorsGrid.Add(grid[0, 1].color); if (grid[0, 1].toggleOrb) { cornerColorsGrid.Add(grid[0, 1].toggleColor); } cornerColorsGrid.Add(grid[0, 3].color); if (grid[0, 3].toggleOrb) { cornerColorsGrid.Add(grid[0, 3].toggleColor); } sideColorsGrid.Add(grid[0, 2].color); if (grid[0, 2].toggleOrb) { cornerColorsGrid.Add(grid[0, 2].toggleColor); } sideColorsGrid.Add(grid[4, 2].color); if (grid[4, 2].toggleOrb) { cornerColorsGrid.Add(grid[4, 2].toggleColor); } cornerColorsGrid.Add(grid[4, 1].color); if (grid[4, 1].toggleOrb) { cornerColorsGrid.Add(grid[4, 1].toggleColor); } cornerColorsGrid.Add(grid[4, 3].color); if (grid[4, 3].toggleOrb) { cornerColorsGrid.Add(grid[4, 3].toggleColor); } foreach (Color c in faceColorsBox) { if (c == Color.Gray || c == Game.currentSettings.dangerColor) { continue; } if (sideColorsGrid.Contains(c)) { return(true); } } foreach (Color c in sideColorsBox1) { if (c == Color.Gray || c == Game.currentSettings.dangerColor) { continue; } if (cornerColorsGrid.Contains(c) || sideColorsGrid.Contains(c)) { return(true); } } foreach (Color c in cornerColorsBox) { if (c == Color.Gray || c == Game.currentSettings.dangerColor) { continue; } if (cornerColorsGrid.Contains(c)) { return(true); } } return(false); }
//Identifies all scoring matches and marks them. public static List <ScoringSet> Solve(PuzzleBox box, MasterGrid grid) { Matcher.AddBoxToGrid(box, grid); List <ScoringSet> scoringSets = new List <ScoringSet>(); // Marking orbs #region InitialOrbMarking // Marking vertical lines for (int x = boxOffset; x < boxOffset + boxSize; x++) { int start_index = 0; int end_index = 0; PuzzleNode lastNode = new PuzzleNode(Color.Black); for (int y = 0; y < gridSize; y++) { if (grid[x, y] == null) { continue; } if (PuzzleNode.Match(lastNode, grid[x, y])) { lastNode = grid[x, y]; end_index++; } else { lastNode = grid[x, y]; if (StartEndHelper(start_index, end_index)) { ScoringSet s; if (start_index < boxOffset) { s = CreateScoreHelperVert(start_index, end_index, x, grid[x, start_index]); } else { s = CreateScoreHelperVert(start_index, end_index, x, grid[x, y]); } for (int i = start_index; i < end_index; i++) { s.multiplier *= grid[x, i].bonus; MarkHelperVert(start_index, end_index, i, grid[x, i]); } scoringSets.Add(s); } start_index = y; end_index = y + 1; } } if (StartEndHelper(start_index, end_index)) { ScoringSet s = CreateScoreHelperVert(start_index, end_index, x, grid[x, end_index - 1]); for (int i = start_index; i < end_index; i++) { s.multiplier *= grid[x, i].bonus; MarkHelperVert(start_index, end_index, i, grid[x, i]); } scoringSets.Add(s); } } // Marking horizontal lines for (int y = boxOffset; y < boxOffset + boxSize; y++) { int start_index = 0; int end_index = 0; PuzzleNode lastNode = new PuzzleNode(Color.Black); for (int x = 0; x < gridSize; x++) { if (grid[x, y] == null) { continue; } if (PuzzleNode.Match(lastNode, grid[x, y])) { lastNode = grid[x, y]; end_index++; } else { lastNode = grid[x, y]; if (StartEndHelper(start_index, end_index)) { ScoringSet s; if (start_index < boxOffset) { s = CreateScoreHelperHoriz(start_index, end_index, y, grid[start_index, y]); } else { s = CreateScoreHelperHoriz(start_index, end_index, y, grid[x, y]); } for (int i = start_index; i < end_index; i++) { s.multiplier *= grid[i, y].bonus; MarkHelperHoriz(start_index, end_index, i, grid[i, y]); } scoringSets.Add(s); } start_index = x; end_index = x + 1; } } if (StartEndHelper(start_index, end_index)) { ScoringSet s = CreateScoreHelperHoriz(start_index, end_index, y, grid[end_index - 1, y]); for (int i = start_index; i < end_index; i++) { s.multiplier *= grid[i, y].bonus; MarkHelperHoriz(start_index, end_index, i, grid[i, y]); } scoringSets.Add(s); } } #endregion // Extend wildcard markings #region ExtendWildcardMarkings for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (IsWildCard(grid[x, y])) { for (int i = x + 1; i < gridSize; i++) { if (grid[i, y].marked) { grid[i, y].replace_right = true; } else { break; } } for (int i = x - 1; i >= 0; i--) { if (grid[i, y].marked) { grid[i, y].replace_left = true; } else { break; } } for (int i = y + 1; i < gridSize; i++) { if (grid[x, i].marked) { grid[x, i].replace_bottom = true; } else { break; } } for (int i = y - 1; i >= 0; i--) { if (grid[x, i].marked) { grid[x, i].replace_top = true; } else { break; } } } } } #endregion // Mark non-scoring orbs as needing to be replaced #region MarkNonScoringOrbsForReplacement for (int x = boxOffset; x < boxOffset + boxSize; x++) { for (int y = 0; y < gridSize; y++) { if (grid[x, y].replace_bottom && !IsWildCard(grid[x, y])) { for (int i = y; i < gridSize; i++) { grid[x, i].marked = true; grid[x, i].replace_bottom = true; grid[x, i].replace_distance = grid[x, y].replace_distance; } break; } } for (int y = gridSize - 1; y >= 0; y--) { if (grid[x, y].replace_top && !IsWildCard(grid[x, y])) { for (int i = y; i >= 0; i--) { grid[x, i].marked = true; grid[x, i].replace_top = true; grid[x, i].replace_distance = grid[x, y].replace_distance; } break; } } } for (int y = boxOffset; y < boxOffset + boxSize; y++) { for (int x = 0; x < gridSize; x++) { if (grid[x, y].replace_right && !IsWildCard(grid[x, y])) { for (int i = x; i < gridSize; i++) { grid[i, y].marked = true; grid[i, y].replace_right = true; grid[i, y].replace_distance = grid[x, y].replace_distance; } break; } } for (int x = gridSize - 1; x >= 0; x--) { if (grid[x, y].replace_left && !IsWildCard(grid[x, y])) { for (int i = x; i >= 0; i--) { grid[i, y].marked = true; grid[i, y].replace_left = true; grid[i, y].replace_distance = grid[x, y].replace_distance; } break; } } } #endregion // fix replace distances #region FixReplaceDistances for (int x = 0; x < gridSize; x++) { for (int y = 0; y < gridSize; y++) { if (IsWildCard(grid[x, y])) { if (grid[x, y].replace_right) { for (int i = x; i < gridSize; i++) { if (grid[i, y].marked) { grid[i, y].replace_distance--; } else { break; } } } if (grid[x, y].replace_left) { for (int i = x; i >= 0; i--) { if (grid[i, y].marked) { grid[i, y].replace_distance--; } else { break; } } } if (grid[x, y].replace_bottom) { for (int i = y; i < gridSize; i++) { if (grid[x, i].marked) { grid[x, i].replace_distance--; } else { break; } } } if (grid[x, y].replace_top) { for (int i = y; i >= 0; i--) { if (grid[x, i].marked) { grid[x, i].replace_distance--; } else { break; } } } } } } #endregion Matcher.SetBoxFromGrid(box, grid); return(scoringSets); }
public static void Clear(PuzzleBox box, MasterGrid grid) { box.Blank(); grid.Blank(); }