/// <summary> /// Update the info shape. /// </summary> private void UpdateInfo() { int i, count = GradientSchemes.Length; InfoShape.BeginUpdate(); for (i = 0; i < count; i++) { InfoShape[1, i + 1].Text = CellCount[i].ToString(); } // Update the score InfoShape[0, i + 1].Text = string.Format("Score:{0}{1}", Environment.NewLine, Score); InfoShape.EndUpdate(); }
/// <summary> /// Clears all highlighted cells. /// </summary> public void ClearHighlightedCells() { int cellCount = m_CellsToClear.Count; if (cellCount == 0) { return; } string colorString = BoardShape[m_CellsToClear[0].X, m_CellsToClear[0].Y].StyleSheetName; colorString = colorString.Remove(colorString.Length - HighlightedSuffix.Length); CellCount[IndexOf(colorString)] -= cellCount; Score += cellCount * cellCount; for (int i = 0; i < cellCount; i++) { NPoint p = m_CellsToClear[i]; BoardShape[p.X, p.Y].StyleSheetName = String.Empty; } // Apply gravity ApplyGravity(); // Update the cell count info UpdateInfo(); // Clear the cells to clear list m_CellsToClear.Clear(); // Check for end of the game string status = String.Empty; if (AllClear()) { Score *= 2; status = "You've cleared all cells !!!" + Environment.NewLine; } if (status == String.Empty && GameOver()) { status = "Game Over !" + Environment.NewLine; } if (status != String.Empty) { status += "Your score is " + Score.ToString(); NTableShape gameOver = new NTableShape(); ((NDrawingDocument)BoardShape.Document).ActiveLayer.AddChild(gameOver); gameOver.BeginUpdate(); gameOver.CellPadding = new Nevron.Diagram.NMargins(2, 2, 8, 8); gameOver[0, 0].Text = status; NStyle.SetFillStyle(gameOver, new NAdvancedGradientFillStyle(AdvancedGradientScheme.Mahogany2, 5)); NTextStyle textStyle = (NTextStyle)InfoShape.ComposeTextStyle().Clone(); textStyle.FillStyle = new NColorFillStyle(Color.White); NStyle.SetTextStyle(gameOver, textStyle); gameOver.EndUpdate(); gameOver.Center = BoardShape.Center; } }