Beispiel #1
0
    public void selectAlgorithm()
    {
        _currentAlgorithm = (Algorithm)algorithmDrpDn.value;

        switch (_currentAlgorithm)
        {
        case Algorithm.BreadthFirst:
            _pathFinderAlgorithm = new BreadthFirst();
            instructionsTxt.text = "LMB: creates wall if not created, otherwise deletes it\nWASD: camera navigation";
            break;

        case Algorithm.DepthFirst:
            _pathFinderAlgorithm = new DepthFirst();
            instructionsTxt.text = "LMB: creates wall if not created, otherwise deletes it\nWASD: camera navigation";
            break;

        case Algorithm.Dijkstra:
            _pathFinderAlgorithm = new Dijkstra();
            instructionsTxt.text = "LMB: creates wall if not created, otherwise deletes it\nWASD: camera navigation\nRMB: add Water(3),Mud(6), Mine, castle,deletes tile";
            break;

        case Algorithm.AStar:
            _pathFinderAlgorithm = new AStar();
            instructionsTxt.text = "LMB: creates wall if not created, otherwise deletes it\nWASD: camera navigation\nRMB: add Water(3),Mud(6), Mine, castle,deletes tile";
            break;

        default:
            break;
        }
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        PathFinding        = GetComponent <PathFindingAlgorithm>();
        rig                = GetComponent <Rigidbody>();
        PathFinding.seeker = transform;
        PathFinding.target = target;
        var grid = GetComponentInParent <Grid>();

        PathFinding.grid = grid;
    }
Beispiel #3
0
    void Start()
    {
        _width          = 30;
        _height         = 30;
        widthInFd.text  = "30";
        heightInFd.text = "30";

        _tiles = new GameObject[_width, _height];
        _nodes = new Node[_width, _height];

        _pathFinderAlgorithm = new BreadthFirst();
        _currentAlgorithm    = Algorithm.BreadthFirst;

        buildGrid();
    }