コード例 #1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.R:
                grid = new Grid(this);
                graphics.Clear(SystemColors.Control);
                grid.DrawLines(graphics);
                grid.DrawItem(graphics);
                playerNode = null;
                finishNode = null;
                break;

            case Keys.Space:
                if (playerNode != null && finishNode != null)
                {
                    playerNode.State = Grid.GridItemStates.Player;
                    finishNode.State = Grid.GridItemStates.Finish;
                    Pathfinding.FindPath(grid, playerNode, finishNode);
                    grid.DrawItem(graphics);
                }
                break;

            case Keys.D1:
                Brush = Grid.DrawStates.Wall;
                break;

            case Keys.D2:
                Brush = Grid.DrawStates.Finish;
                break;

            case Keys.D3:
                Brush = Grid.DrawStates.Player;
                break;
            }
        }
コード例 #2
0
 void Start()
 {
     grid.path = pathfinding.FindPath(grid, start.position, target.position);
 }