예제 #1
0
    public NodeComponent GetNeighbour(Vector3 _direction)
    {
        TileComponent tile = TileComponent.GetTileAt(transform.position + _direction);

        if (tile == null)
        {
            return(null);
        }

        return(tile.GetComponent <NodeComponent>());
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (PathfindingController.FinishedPathfinding && !StartDragger.IsDragging && !EndDragger.IsDragging)
        {
            if ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) && !EventSystem.current.IsPointerOverGameObject())
            {
                Vector3 rawMousePosition  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                Vector3 formattedPosition = new Vector3(rawMousePosition.x, rawMousePosition.y, 0);

                TileComponent tile = TileComponent.GetTileAt(formattedPosition);

                if (Input.GetMouseButton(0) && tile == null)
                {
                    Map.GenerateTile(Mathf.RoundToInt(formattedPosition.x), Mathf.RoundToInt(formattedPosition.y));
                }

                else if (Input.GetMouseButton(1) && tile != null)
                {
                    tile.DestroyTile();
                }
            }
        }
    }
    NodeComponent GetNodeComponentOfBoundary(GameObject _boundary)
    {
        TileComponent tile = TileComponent.GetTileAt(_boundary.transform.position);

        return(tile.GetComponent <NodeComponent>());
    }