private void CheckNeighbor(GemController neighbor, Direction neighborDirection) { if (null == neighbor) { neighborChangedFlag &= (~neighborDirection); return; } if (!neighbor.IsActive) { return; } if (!neighbor.CurrentGemType.HasSameFlags(this.CurrentGemType)) { neighborChangedFlag &= (~neighborDirection); return; } PossibleMatch addedPossibleMatch = null; foreach (PossibleMatch possibleMatch in neighbor.PossibleMatches) { if (possibleMatch.AddGem(this)) { addedPossibleMatch = possibleMatch; } } if (addedPossibleMatch == null) { addedPossibleMatch = new PossibleMatch(this.CurrentGemType.GetSameFlags(neighbor.CurrentGemType)); addedPossibleMatch.AddGem(this); Logger.Instance.Message(this.ToString() + " adding neighbor " + neighbor.ToString() + " to " + addedPossibleMatch.ToString()); addedPossibleMatch.AddGem(neighbor); if (null != OnPossibleMatchAddedEvent) { OnPossibleMatchAddedEvent(this, addedPossibleMatch); } } neighborChangedFlag &= (~neighborDirection); }
private void BreakByType(GemType type) { if (null == gems) { Logger.Instance.Error("BreakByType(): gems not inited"); } PossibleMatch pm = new PossibleMatch(type, true); for (int x = 0; x < columnCount; x++) { for (int y = 0; y < rowCount; y++) { if (null != gems[x][y] && gems[x][y].CurrentGemType.HasSameFlags(type)) { pm.AddGem(gems[x][y]); } } } matchedMatches.Add(pm); }