Controller ClassDelta Engine Documentation
Handles the falling and upcoming blocks. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Entity
    Blocks Controller

Namespace: Blocks
Assembly: Blocks (in Blocks.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public class Controller : Entity, Updateable

The Controller type exposes the following members.

Constructors

  NameDescription
Public methodController
Initializes a new instance of the Controller class
Top
Methods

  NameDescription
Public methodAdd T  (Inherited from Entity.)
Public methodAddTag (Inherited from Entity.)
Public methodClearTags (Inherited from Entity.)
Public methodContains T  (Inherited from Entity.)
Public methodContainsBehavior T  (Inherited from Entity.)
Public methodContainsTag (Inherited from Entity.)
Protected methodDeactivate (Inherited from Entity.)
Public methodDispose (Inherited from Entity.)
Public methodGet T 
Gets a specific component, derived classes can return faster cached values (e.g. Entity2D) View code on GitHub
(Inherited from Entity.)
Protected methodGetActiveBehaviors (Inherited from Entity.)
Protected methodGetComponentsForSaving (Inherited from Entity.)
Public methodGetOrDefault T  (Inherited from Entity.)
Public methodGetTags (Inherited from Entity.)
Public methodMoveBlockLeftIfPossible
Public methodMoveBlockRightIfPossible
Public methodRemove T  (Inherited from Entity.)
Public methodRemoveTag (Inherited from Entity.)
Public methodRotateBlockAntiClockwiseIfPossible
Public methodSet (Inherited from Entity.)
Public methodSetComponents (Inherited from Entity.)
Public methodStart T  (Inherited from Entity.)
Public methodStop T  (Inherited from Entity.)
Public methodToString (Inherited from Entity.)
Public methodUpdate
Top
Fields

  NameDescription
Protected fieldcomponents (Inherited from Entity.)
Public fieldcontent
Public fielddisplayMode
Top
Properties

  NameDescription
Public propertyFallingBlock
Public propertyGameRunning
Public propertyIsActive (Inherited from Entity.)
Public propertyIsFallingFast
Public propertyIsPauseable (Inherited from Entity.)
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyUpcomingBlock
Public propertyUpdatePriority (Inherited from Entity.)
Top
Events

  NameDescription
Public eventAddToScore
Public eventLose
Top
Remarks

Tests: Blocks.Tests.ControllerTests
Examples

13 unit tests call Blocks.Controller
[Test, CloseAfterFirstFrame]
public void RunCreatesFallingAndUpcomingBlocks()
{
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.IsNotNull(controller.FallingBlock);
    Assert.IsNotNull(controller.UpcomingBlock);
}
[Test, CloseAfterFirstFrame]
public void DropSlowAffixesBlocksSlowly()
{
    controller.IsFallingFast = false;
    controller.FallingBlock = new Block(displayMode, content, Vector2D.One);
    controller.UpcomingBlock = new Block(displayMode, content, Vector2D.One);
    AdvanceTimeAndUpdateEntities(0.1f);
    Assert.AreEqual(0, CountBricks(grid));
    AdvanceTimeAndUpdateEntities(1.5f);
    Assert.AreEqual(0, CountBricks(grid));
    AdvanceTimeAndUpdateEntities(9.0f);
    Assert.AreEqual(4, CountBricks(grid), 1);
}
[Test, CloseAfterFirstFrame]
public void DropFastAffixesBlocksQuickly()
{
    controller.IsFallingFast = true;
    controller.FallingBlock = new Block(displayMode, content, Vector2D.One);
    controller.UpcomingBlock = new Block(displayMode, content, Vector2D.One);
    Assert.AreEqual(0, CountBricks(grid));
    AdvanceTimeAndUpdateEntities(2.5f);
    Assert.GreaterOrEqual(CountBricks(grid), 4);
}
See Also