LevelGraph ClassDelta Engine Documentation
2D path finding graph for levels using columns (x) and rows (y) for indexing. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.GameLogic.PathFinding Graph
    DeltaEngine.GameLogic.PathFinding LevelGraph
      DeltaEngine.GameLogic.PathFinding.Tests LevelGraphTests MockLevelGraph

Namespace: DeltaEngine.GameLogic.PathFinding
Assembly: DeltaEngine.GameLogic.PathFinding (in DeltaEngine.GameLogic.PathFinding.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class LevelGraph : Graph

The LevelGraph type exposes the following members.

Constructors

  NameDescription
Public methodLevelGraph
Initializes a new instance of the LevelGraph class
Top
Methods

  NameDescription
Public methodConnect (Overrides Graph Connect(Int32, Int32, Int32, Boolean).)
Protected methodConnectAllNodesToLinkGrid
Public methodGetClosestNode
Public methodGetNode(Int32) (Inherited from Graph.)
Public methodGetNode(Int32, Int32)
Public methodIsConnected (Inherited from Graph.)
Protected methodIsInvalidNodeId (Inherited from Graph.)
Public methodIsUnreachableNode
Public methodResetGraph
Public methodSetReachableAndUpdate
Public methodSetUnreachableAndUpdate
Public methodSetUnreachableNode
Public methodUpdateWeightInAdjacentNodes
Top
Fields

  NameDescription
Public fieldAreDiagonalPathAllowed
Top
Properties

  NameDescription
Public propertyAdjacentLinks (Inherited from Graph.)
Public propertyNodes (Inherited from Graph.)
Public propertyNumberOfNodes (Inherited from Graph.)
Top
Remarks

Tests: DeltaEngine.GameLogic.PathFinding.Tests.LevelGraphTests
Examples

10 unit tests call DeltaEngine.GameLogic.PathFinding.LevelGraph
[Test]
public void CheckNodePositions()
{
    Assert.AreEqual(new Vector2D(0, 0), grid3X2.GetNode(0).Position);
    Assert.AreEqual(new Vector2D(1, 0), grid3X2.GetNode(1).Position);
    Assert.AreEqual(new Vector2D(2, 0), grid3X2.GetNode(2).Position);
    Assert.AreEqual(new Vector2D(0, 1), grid3X2.GetNode(3).Position);
    Assert.AreEqual(new Vector2D(1, 1), grid3X2.GetNode(4).Position);
    Assert.AreEqual(new Vector2D(2, 1), grid3X2.GetNode(5).Position);
}
[Test]
public void CheckForConnectedNodes()
{
    Assert.IsTrue(grid3X2.IsConnected(0, 1));
    Assert.IsTrue(grid3X2.IsConnected(1, 0));
    Assert.IsTrue(grid3X2.IsConnected(1, 4));
    Assert.IsTrue(grid3X2.IsConnected(2, 1));
    Assert.IsTrue(grid3X2.IsConnected(2, 5));
    Assert.IsTrue(grid3X2.IsConnected(3, 4));
    Assert.IsTrue(grid3X2.IsConnected(4, 5));
}
[Test]
public void CheckForNotConnectedNodes()
{
    Assert.IsFalse(grid3X2.IsConnected(0, 4));
    Assert.IsFalse(grid3X2.IsConnected(4, 0));
    Assert.IsFalse(grid3X2.IsConnected(1, 3));
    Assert.IsFalse(grid3X2.IsConnected(3, 1));
    Assert.IsFalse(grid3X2.IsConnected(1, 5));
    Assert.IsFalse(grid3X2.IsConnected(5, 1));
    Assert.IsFalse(grid3X2.IsConnected(2, 4));
    Assert.IsFalse(grid3X2.IsConnected(4, 2));
    Assert.IsFalse(grid3X2.IsConnected(0, 5));
    Assert.IsFalse(grid3X2.IsConnected(5, 0));
    Assert.IsFalse(grid3X2.IsConnected(2, 3));
    Assert.IsFalse(grid3X2.IsConnected(3, 2));
}
See Also