Beispiel #1
0
    public void CreateBoardingPlank()
    {
        if (createdPlank)
        {
            return;
        }

        createdPlank = true;

        Transform plank = Instantiate(plankPrefab, new Vector2(2, .25f), Quaternion.identity).transform;

        MovementTile[,] plankTiles = new MovementTile[2, 1];

        for (int x = 0; x < plankTiles.GetLength(0); x++)
        {
            for (int y = 0; y < plankTiles.GetLength(1); y++)
            {
                plankTiles [x, y]   = plank.GetChild(x * 1 + y).GetComponent <MovementTile> ();
                plankTiles [x, y].x = x;
                plankTiles [x, y].y = y;
            }
        }

        AStar.AddAreaToLayout(plankTiles);

        LevelLayout.Portal portalPlayerPlank = new LevelLayout.Portal(playerBoarding, plankTiles [0, 0]);
        AStar.AddPortalToLayout(portalPlayerPlank);

        LevelLayout.Portal portalPlankShip = new LevelLayout.Portal(plankTiles [1, 0], otherBoarding);
        AStar.AddPortalToLayout(portalPlankShip);
    }
Beispiel #2
0
    void Awake()
    {
        layers       = new int[areas.Length];
        edgeTiles    = new List <MovementTile> ();
        floodedTiles = new List <BailPosition> ();

        List <MovementTile[, ]> areaTiles = new List <MovementTile[, ]> ();

        for (int i = 0; i < areas.Length; i++)
        {
            Transform  area = areas[i].area;
            Vector2Int dims = areas [i].dimensions;
            MovementTile[,] tiles = new MovementTile [dims.x, dims.y];

            for (int x = 0; x < dims.x; x++)
            {
                for (int y = 0; y < dims.y; y++)
                {
                    tiles [x, y]   = area.GetChild(x * 8 + y).GetComponent <MovementTile> ();
                    tiles [x, y].x = x;
                    tiles [x, y].y = y;

                    if (tiles [x, y].isEdgeTile)
                    {
                        edgeTiles.Add(tiles [x, y]);
                    }

                    if (tiles [x, y].walkable)
                    {
                        maxFloodTiles++;
                        //TODO: testing this (also in plank prefab)
                        tiles[x, y].GetComponent <SpriteRenderer> ().enabled = false;
                    }
                }
            }

            layers [i] = tiles [0, 0].layer;
            areaTiles.Add(tiles);

            AStar.AddAreaToLayout(tiles);
        }

        List <LevelLayout.Portal> portalTiles = new List <LevelLayout.Portal> ();

        for (int i = 0; i < portals.Length; i++)
        {
            portalTiles.Add(portals [i]);
            AStar.AddPortalToLayout(portals [i]);
        }
    }