protected virtual void Start()
 {
     tilemapGraph = new TilemapGraph(tilemap, allowedTiles.Get());
     //tilemapGraph = new TilemapGraphAStar(tilemap, allowedTiles.Get());
     timeBetweenSteps = 1 / speed;
     StartCoroutine(MoveTowardsTheTarget());
 }
Exemplo n.º 2
0
    protected virtual void Start()
    {
        pathFinder = new BFS <Vector3Int>();//Initialize to BFS algorithm

        tilemapGraph     = new TilemapGraph(tilemap, allowedTiles.Get());
        timeBetweenSteps = 1 / speed;
        StartCoroutine(MoveTowardsTheTarget());
    }
Exemplo n.º 3
0
    protected virtual void Start()
    {
        targetInWorld = transform.position;
        targetInGrid  = tilemap.WorldToCell(targetInWorld);

        //Erel's code:
        //tilemapGraph = new TilemapGraph(tilemap, allowedTiles.Get());

        // Changed to IWeightedGraph implementation:
        tilemapGraph = new TileWeightedGraph(tilemap, allowedTiles.Get());


        StartCoroutine(MoveTowardsTheTarget());
    }
    void Update()
    {
        Vector3  newPosition       = NewPosition();
        TileBase tileOnNewPosition = TileOnPosition(newPosition);

        if (allowedTiles.Contain(tileOnNewPosition))
        {
            transform.position = newPosition;
        }
        else    //if the player hit a mountain, and also press both 'x' and arrow its break the tile into a grass and put the player on his position
        {
            if (twoButt && tileOnNewPosition.name.Equals("mountains"))
            {
                Vector3Int a = tilemap.WorldToCell(newPosition);
                tilemap.SetTile(a, allowedTiles.Get()[0]);
                twoButt = false;
                Thread.Sleep((int)(timeToDestoy * 1000));
                transform.position = newPosition;
            }
            Debug.Log("You cannot walk on " + tileOnNewPosition + "!");
        }
    }
 protected virtual void Start()
 {
     tilemapDijkstra  = new TileMapDijkstra(tilemap, allowedTiles.Get(), weight);
     timeBetweenSteps = 1 / speed;
     StartCoroutine(MoveTowardsTheTarget());
 }