// Function that returns a possible match on this direction private Possible_Match Add_Poss(Vector2 check, TobleGem gem, Possible_Match p) { if (CheckDir(check, gem)) { p.third = GetGem((int)check.x, (int)check.y); return(p); } return(null); }
// Function that destroys and creates a brand new board public IEnumerator ResetBoard() { reseting = true; pm = null; yield return(new WaitForSeconds(1)); Narrator.instance.PlayNarrator(Shuffle_voice, false); StatusSound.instance.PlayStatus(Shuffle); yield return(new WaitForSeconds(0.5f)); DestroyBoard(); yield return(new WaitForSeconds(1)); CreateBoard(); reseting = false; }
void Start() { instance = GetComponent <BoardManager>(); BoardM_r = GetComponent <RectTransform>(); update = new List <TobleGem>(); flipped = new List <FlippedGems>(); destroyed = new List <TobleGem>(); fills = new int[8]; points_move = 0; combo = 1.0f; pm = null; reseting = false; CreateBoard(); UIManager.instance.ScreenSizeChangeEvent += Align_BoardM; Align_BoardM(); }
// Function that returns the list of possible matches of a TobleFood private List <Possible_Match> Find_PossibleAtThis(TobleGem gem) { List <Possible_Match> p_poss = new List <Possible_Match>(); // Foreach neighbour foreach (Vector2 dir in direction) { // Check if this neighbour is at range and if it has the same tag Vector2 check = new Vector2(gem.x, gem.y) + dir; if (CheckDir(check, gem)) { TobleGem c = GetGem((int)check.x, (int)check.y); Possible_Match p; Possible_Match p_vh = new Possible_Match(gem, c); // If this direction is Vertical or Horizontal if (dir.x == 0 || dir.y == 0) { // Check for i shape Vector2 checkUp = new Vector2(c.x, c.y) + dir * 2; //| g | c | - | p | p = Add_Poss(checkUp, c, p_vh); if (p != null) { p_poss.Add(p); } // Check for L shape if (dir.x == 0) { Vector2 checkRight = new Vector2(c.x, c.y) + dir + new Vector2(1, 0); // | - | p | p = Add_Poss(checkRight, c, p_vh); // | c | if (p != null) // | g | { p_poss.Add(p); } print(dir + new Vector2(-1, 0)); Vector2 checkLeft = new Vector2(c.x, c.y) + dir + new Vector2(-1, 0); // | p | - | p = Add_Poss(checkLeft, c, p_vh); // | c | if (p != null) // | g | { p_poss.Add(p); } } else { Vector2 checkRight = new Vector2(c.x, c.y) + dir + new Vector2(0, 1); // | g | c | - | p = Add_Poss(checkRight, c, p_vh); // | p | if (p != null) { p_poss.Add(p); } Vector2 checkLeft = new Vector2(c.x, c.y) + dir + new Vector2(0, -1); // | p | p = Add_Poss(checkLeft, c, p_vh); // | g | c | - | if (p != null) { p_poss.Add(p); } } } else // If this direction is Diagonal - Search for V shape { if (dir.x < 0) // Left { Vector2 checkLeft = new Vector2(gem.x, gem.y) + new Vector2(-2, 0); // | c | p = Add_Poss(checkLeft, gem, p_vh); // | p | - | g | if (p != null) // | c | { p_poss.Add(p); } } else // Right { Vector2 checkRight = new Vector2(gem.x, gem.y) + new Vector2(2, 0); // | c | p = Add_Poss(checkRight, gem, p_vh); // | g | - | p | if (p != null) // | c | { p_poss.Add(p); } } if (dir.y < 0) // Up { Vector2 checkUp = new Vector2(gem.x, gem.y) + new Vector2(0, -2); // | p | p = Add_Poss(checkUp, gem, p_vh); // | c | - | c | if (p != null) // | g | { p_poss.Add(p); } } else // Down { Vector2 checkDown = new Vector2(gem.x, gem.y) + new Vector2(0, 2); // | g | p = Add_Poss(checkDown, gem, p_vh); // | c | - | c | if (p != null) // | p | { p_poss.Add(p); } } } } } return(p_poss); }