Exemplo n.º 1
0
    public void editorCreateNodes()
    {
        CreateNodesFromTilemaps cnt = FindObjectOfType <CreateNodesFromTilemaps> ();

        cnt.editorCreateNodes();
        nodesCreated = true;
    }
Exemplo n.º 2
0
    void Awake()
    {
        me = this;

        if (FindObjectOfType <CreateNodesFromTilemaps>().unsortedNodes == null)
        {
            nodesCreated = false;
        }

        if (fromTilemap == false)
        {
            worldTiles = new GameObject[width, height];
        }
        else
        {
            if (nodesCreated == false)
            {
                //Debug.LogError("Nodes are not created");
                createNodes();
            }
            else
            {
                //Debug.LogError("Nodes already created, seeing if we can use");
                CreateNodesFromTilemaps ct = FindObjectOfType <CreateNodesFromTilemaps> ();
                worldTiles = ct.reassembleNodeArray();
                ct.nodes   = worldTiles;
                for (int x = 0; x < worldTiles.GetLength(0); x++)
                {
                    for (int y = 0; y < worldTiles.GetLength(1); y++)
                    {
                        if (worldTiles[x, y] != null)
                        {
                            startX = x;
                            startY = y;
                            return;
                        }
                    }
                }

                /*if (worldTiles == null) {
                 *                      //Debug.Log ("There were no world tiles found");
                 *                      //DebugFixNodes ();
                 *              }
                 *
                 *              if (ct.nodes == null && worldTiles != null) {
                 *                      //Debug.Log ("Create nodes from tilemaps had no nodes, passing in");
                 *                      ct.nodes = worldTiles;
                 *              }
                 *
                 *              Pathfinding p = FindObjectOfType<Pathfinding> ();
                 *              if (p.pathNodes == null) {
                 *                      //Debug.Log ("There were no threaded nodes");
                 *              }*/
            }
        }
    }
Exemplo n.º 3
0
    public void GenerateGrid()
    {
        map = CreateNodesFromTilemaps.CreateNodes(grid, floor, obstacleLayers, transform);

        SpawnNodes(map, false);
        AStarPath.SaveMap(map);

        path = AStarPath.FindPath(new Vector2(-7.9f, -.2f), new Vector2(-.1f, -.1f));
        StartCoroutine(DelayedPath());
    }
Exemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     me = this;
     reconstructNodeArray();
 }
Exemplo n.º 5
0
    private void FillWalls() // fyllir í veggi
    {
        BoundsInt bounds = groundMap.cellBounds;

        for (int xMap = bounds.xMin - 10; xMap <= bounds.xMax + 10; xMap++)
        {
            for (int yMap = bounds.yMin - 10; yMap <= bounds.yMax + 10; yMap++)
            {
                Vector3Int pos            = new Vector3Int(xMap, yMap, 0); // tekur inn position sem verður miðað við tiles á tilemap
                Vector3Int posRight       = new Vector3Int(xMap + 1, yMap, 0);
                Vector3Int posLeft        = new Vector3Int(xMap - 1, yMap, 0);
                Vector3Int posBelow       = new Vector3Int(xMap, yMap - 1, 0);
                Vector3Int posBelow2      = new Vector3Int(xMap, yMap - 2, 0);
                Vector3Int posBelowLeft   = new Vector3Int(xMap + 1, yMap - 2, 0);
                Vector3Int posBelowRight  = new Vector3Int(xMap - 1, yMap - 2, 0);
                Vector3Int posBelowLeft2  = new Vector3Int(xMap + 1, yMap - 1, 0);
                Vector3Int posBelowRight2 = new Vector3Int(xMap - 1, yMap - 1, 0);
                Vector3Int posAboveRight  = new Vector3Int(xMap - 1, yMap + 1, 0);
                Vector3Int posAboveLeft   = new Vector3Int(xMap + 1, yMap + 1, 0);
                Vector3Int posAbove       = new Vector3Int(xMap, yMap + 1, 0);

                TileBase tile            = groundMap.GetTile(pos); // miðar positionin við tilemap tiles, til að geta sett rétta veggi á rétta staði
                TileBase tileRight       = groundMap.GetTile(posRight);
                TileBase tileLeft        = groundMap.GetTile(posLeft);
                TileBase tileBelow       = groundMap.GetTile(posBelow);
                TileBase tileBelow2      = groundMap.GetTile(posBelow2);
                TileBase tileBelowLeft   = groundMap.GetTile(posBelowLeft);
                TileBase tileBelowRight  = groundMap.GetTile(posBelowRight);
                TileBase tileBelowLeft2  = groundMap.GetTile(posBelowLeft2);
                TileBase tileBelowRight2 = groundMap.GetTile(posBelowRight2);
                TileBase tileAboveRight  = groundMap.GetTile(posAboveRight);
                TileBase tileAboveLeft   = groundMap.GetTile(posAboveLeft);
                TileBase tileAbove       = groundMap.GetTile(posAbove);



                if (tile == null)
                {
                    pitMap.SetTile(pos, pitTile);// setur pitmap allstaðar sem er ekki gólf
                    if (tileBelowLeft != null)
                    {
                        wallMap.SetTile(pos, slabCornerLeftTile);                       //      restin setur niður ákveðið tile við ákveðið situation,
                    }
                    if (tileBelowRight != null)
                    {
                        wallMap.SetTile(pos, slabCornerRightTile);                         //   ekki 100% tilbúið vantar fleyri tile textures og
                    }
                    if (tileBelowLeft2 != null)
                    {
                        wallMap.SetTile(pos, rightWallTile);                         //         fleyri arguments til að þetta verður nánast fullkomið
                    }
                    if (tileBelowRight2 != null)
                    {
                        wallMap.SetTile(pos, leftWallTile);
                    }
                    if (tileAboveLeft != null)
                    {
                        wallMap.SetTile(pos, pitCornerRight);
                    }
                    if (tileAboveRight != null)
                    {
                        wallMap.SetTile(pos, pitCornerLeft);
                    }
                    if (tileRight != null)
                    {
                        wallMap.SetTile(pos, rightWallTile);
                    }
                    if (tileLeft != null)
                    {
                        wallMap.SetTile(pos, leftWallTile);
                    }
                    if (tileBelow2 != null)
                    {
                        wallMap.SetTile(pos, slabWallTile);
                    }
                    if (tileLeft != null && tileBelow2 != null)
                    {
                        wallMap.SetTile(pos, CornerRightTile);
                    }
                    if (tileRight != null && tileBelow2 != null)
                    {
                        wallMap.SetTile(pos, CornerLeftTile);
                    }
                    if (tileBelow != null)
                    {
                        wallMap.SetTile(pos, topWallTile);
                    }
                    if (tileAbove != null)
                    {
                        wallMap.SetTile(pos, botWallTile);
                    }
                    if (tileAbove != null)
                    {
                        bottomSlabMap.SetTile(posAbove, slabWallTile);
                    }
                    if (tileAbove != null && tileRight != null)
                    {
                        bottomSlabMap.SetTile(posAbove, slabWallTileRight);
                    }
                    if (tileAbove != null && tileLeft != null)
                    {
                        bottomSlabMap.SetTile(posAbove, slabWallTileLeft);
                    }
                    if (tileAbove != null && tileLeft != null)
                    {
                        wallMap.SetTile(pos, leftWallPit);
                    }
                    if (tileAbove != null && tileRight != null)
                    {
                        wallMap.SetTile(pos, rightWallPit);
                    }
                }
            }
        }
        // FindObjectOfType<CreateNodesFromTilemap>().generateNodes();
        CreateNodesFromTilemaps CNFT = gameObject.GetComponent <CreateNodesFromTilemaps>();

        CNFT.createNodeFromTilemaps();
    }
Exemplo n.º 6
0
 // Use this for initialization
 void Awake()
 {
     me = this;
 }
Exemplo n.º 7
0
 CreateNodesFromTilemaps grid;//the CreateNodesFromTilemaps object itself
 void Awake()
 {
     grid = GetComponent <CreateNodesFromTilemaps>();
 }