Time for action – the PathNode class

  1. Add a new class called PathNode to the Robot Rampage project.
  2. Add the following using directive to the top of the class file:
    using Microsoft.Xna.Framework;
  3. Add declarations to the PathNode class:
    #region Declarations
    public PathNode ParentNode;
    public PathNode EndNode;
    private Vector2 gridLocation;
    public float TotalCost;
    public float DirectCost;
    #endregion
  4. Add properties to the PathNode class:
    #region Properties public Vector2 GridLocation { get { return gridLocation; } set { gridLocation = new Vector2( (float)MathHelper.Clamp(value.X,0f,(float)TileMap.MapWidth), (float)MathHelper.Clamp(value.Y,0f,(float)TileMap.MapHeight)); } } public int GridX { get { return (int)gridLocation.X; } } public int GridY { get { return ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.