/// <summary> /// Register event for cell changed. /// </summary> /// <param name="e">CellEventArgs e.</param> protected virtual void OnCurrentCellChanged(CellEventArgs e) { if (this.CurrentCellChanged != null) { this.CurrentCellChanged(this, e); } }
/// <summary> /// Changes the cell to BlownCell. /// </summary> /// <param name="posX">X position of the cell.</param> /// <param name="posY">Y position of the cell.</param> private void MakeCellBlown(int posX, int posY) { ICell cell = CellFactory.CreateCell(CellType.BlownCell); cell.X = posX; cell.Y = posY; this.PlayField[posX, posY] = cell; ////Raise event to update the cell view. CellEventArgs e = new CellEventArgs(cell); this.OnCellRedefined(e); }
/// <summary> /// Register event for cell changed. /// </summary> /// <param name="e">CellEventArgs e.</param> protected virtual void OnCellRedefined(CellEventArgs e) { if (this.CellRedefined != null) { this.CellRedefined(this, e); } }
public void TestIfCellEventArgsIsSetWithCorrectCellOnInitialization() { CellEventArgs testCellEvents = new CellEventArgs(new BombCell(5)); Assert.AreEqual(testCellEvents.Target.CellType.Equals(CellType.Bomb), true, string.Format("Expected CellEventArgs created with bomb type. Received {0}",testCellEvents.Target.CellType)); }
public void TestIfCellEventArgsCreateWithNullCellWillThrowArgumentNullException() { CellEventArgs testCellEvents = new CellEventArgs(null); }
/// <summary>Called when there is a new ICell object being controlled by the attached GameEngine object. The default behavior is to create a new /// corresponding CellView and redraw it. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="BattleFiled.GameEngine.CellEventArgs" /> instance containing the event data.</param> protected virtual void OnCellRedefinedHandler(object sender, CellEventArgs e) { ICellView view = this.CreateCellView(e.Target, false); this.CellViews[e.Target.X, e.Target.Y] = view; view.Draw(); }
/// <summary> /// Called when a ICell object controlled by the attached GameEngine object changes its state. The default behavior is to redraw the /// corresponding ICellView object maintained by this class. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="BattleFiled.GameEngine.CellEventArgs" /> /// instance containing the event data about the changed CellView.</param> protected virtual void OnCellChangedHandler(object sender, CellEventArgs e) { this.CellViews[e.Target.X, e.Target.Y].Draw(); }