public Graph(CatAndMouseGame game, GridCell[,] grid) { this.game = game; this.grid = grid; rows = grid.GetLength(0); columns = grid.GetLength(1); adjacencyList = new Node[rows * columns]; for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { grid[i, j] = new GridCell(game, new Vector2(i * 32, j * 32)); List<Node> adjacentNodes = new List<Node>(); // Check NSEW if (j - 1 >= 0) adjacentNodes.Add(new Node(i, j - 1)); if (j + 1 < columns) adjacentNodes.Add(new Node(i, j + 1)); if (i - 1 >= 0) adjacentNodes.Add(new Node(i - 1, j)); if (i + 1 < rows) adjacentNodes.Add(new Node(i + 1, j)); List<Node> cornerNodes = new List<Node>(); // Check all if (i - 1 >= 0 && j - 1 >= 0) cornerNodes.Add(new Node(i - 1, j - 1)); if (i - 1 >= 0 && j + 1 < columns) cornerNodes.Add(new Node(i - 1, j + 1)); if (i + 1 < rows && j - 1 >= 0) cornerNodes.Add(new Node(i + 1, j - 1)); if (i + 1 < rows && j + 1 < columns) cornerNodes.Add(new Node(i + 1, j + 1)); adjacencyList[columns * i + j] = new Node(i, j); allNodes.Add(adjacencyList[columns * i + j]); adjacencyList[columns * i + j].AdjacentNodes = adjacentNodes; adjacencyList[columns * i + j].CornerNodes = cornerNodes; } } }
public AgentSprite(CatAndMouseGame game, Texture2D texture, Vector2 position, UserSprite target, GridCell[,] gridCell, Graph graph) : base(game, texture, position) { this.target = target; this.gridCell = gridCell; this.graph = graph; }
public Sprite(CatAndMouseGame game, Texture2D texture, Vector2 position) : base(game) { this.Game = game; this.Texture = texture; this.Position = position; }
static void Main() { using (var game = new CatAndMouseGame()) game.Run(); }
// TODO: Think about creating a Spawn() method for creating and placing new sprites public Sprite(CatAndMouseGame game) : base(game) { this.Game = game; }
public UserSprite(CatAndMouseGame game, Texture2D texture, Vector2 position) : base(game, texture, position) { Cooldown = new CooldownBar(game, COOLDOWN_MAX, COOLDOWN_BAR_WIDTH, this); }