private bool ColorMatch(GameNode node1, GameNode root, GameNode node2) { // THERES A BUG HERE if (Equals(node1, null) || Equals(node2, null)) { return(false);// is null } if (node1.GetColor() != node2.GetColor()) { return(false); // do neighbors match } if (node1.GetColor() != root.GetColor()) { return(false); // do the neighbors match the core? } return(true); }
private void MarkDestroyRec(GameNode groot) { _visited.Add(groot); foreach (GameNode neighbor in GetNeighbors(groot)) { //Debug.Log(_visited.Count); if (Equals(neighbor, null) || _visited.Contains(neighbor)) { continue; } if (groot.GetColor() == neighbor.GetColor()) { _to_destroy.Add(neighbor); if (!neighbor.IsDestroyed()) { MarkDestroyRec(neighbor); } } } }