예제 #1
0
 /// <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);
     }
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
 /// <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);
     }
 }
예제 #4
0
        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));
        }
예제 #5
0
 public void TestIfCellEventArgsCreateWithNullCellWillThrowArgumentNullException()
 {
     CellEventArgs testCellEvents = new CellEventArgs(null);
 }
예제 #6
0
 /// <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();
 }
예제 #7
0
 /// <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();
 }