Пример #1
0
        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;
                }
            }
        }
Пример #2
0
 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;
 }
Пример #3
0
 public Sprite(CatAndMouseGame game, Texture2D texture, Vector2 position)
     : base(game)
 {
     this.Game = game;
     this.Texture = texture;
     this.Position = position;
 }
Пример #4
0
 static void Main()
 {
     using (var game = new CatAndMouseGame())
         game.Run();
 }
Пример #5
0
 // TODO: Think about creating a Spawn() method for creating and placing new sprites
 public Sprite(CatAndMouseGame game)
     : base(game)
 {
     this.Game = game;
 }
Пример #6
0
 public UserSprite(CatAndMouseGame game, Texture2D texture, Vector2 position)
     : base(game, texture, position)
 {
     Cooldown = new CooldownBar(game, COOLDOWN_MAX, COOLDOWN_BAR_WIDTH, this);
 }