Example #1
0
    public void PostGenerateOne(Canvas twoDMap, int seed, int aiSeed)
    {
        Random.seed = seed;
        IntVector2 newSize = new IntVector2(size.x / 2, size.z / 2);
        IntVector2 offset  = new IntVector2(-newSize.x - 1, (size.z - newSize.z) / 2);

        postOneCells = new LevelCell[newSize.x, newSize.z];
        List <LevelCell> activeCells     = new List <LevelCell>();
        IntVector2       coordinates     = new IntVector2(offset.x + newSize.x - 1, ((newSize.z - 1) / 2) + offset.z);
        IntVector2       roomCoordinates = new IntVector2(coordinates.x + 2, coordinates.z);

        DoFirstPostGenerationStep(postOneCells, activeCells, coordinates, roomCoordinates, twoDMap, offset, newSize);
        while (activeCells.Count > 0)
        {
            DoNextGenerationStep(postOneCells, activeCells, twoDMap, offset, newSize);
        }
        Destroy(postOneCells[coordinates.x - offset.x, coordinates.z - offset.z].GetEdge(LevelDirection.East).image.gameObject);
        Destroy(this.cells[roomCoordinates.x, roomCoordinates.z].GetEdge(LevelDirection.West).image.gameObject);
        Destroy(postOneCells[coordinates.x - offset.x, coordinates.z - offset.z].GetEdge(LevelDirection.East).gameObject);
        Destroy(this.cells[roomCoordinates.x, roomCoordinates.z].GetEdge(LevelDirection.West).gameObject);
        LevelCell cell = CreateHallwayCell(new IntVector2(roomCoordinates.x - 1, roomCoordinates.z), new IntVector2(1, 1), twoDMap);

        cell.InitializeCell(this.cells[roomCoordinates.x, roomCoordinates.z].room);
        CreateTwoDCell(cell, twoDMap);
        CreateWall(cell, null, LevelDirection.North, twoDMap);
        CreateWall(cell, null, LevelDirection.South, twoDMap);
        CreatePassageInSameRoom(cell, postOneCells[coordinates.x - offset.x, coordinates.z - offset.z], LevelDirection.West, twoDMap);
        CreatePassageInSameRoom(cell, this.cells[roomCoordinates.x, roomCoordinates.z], LevelDirection.East, twoDMap);
        CleanLevel(postOneCells, offset);
        Random.seed = aiSeed;
        StartCoroutine(CreatePostConnections());
    }
Example #2
0
 public GlobalData()
 {
     for (int i = 0; i < Const.MaxLevel; i++)
     {
         AllLevels[i] = new LevelCell[Const.MapSize, Const.MapSize];
     }
 }
Example #3
0
    public void Initialize()
    {
        // create layers
        layers = new Layers();
        foreach (string layerName in layersName)
        {
            layers.Register(layerName);
        }

        // build quad tree
        worldBounds     = new SBSBounds();
        worldBounds.min = worldBoundsMin;
        worldBounds.max = worldBoundsMax;

        rootCell = this.BuildQuadTree(worldBounds, 5);

        // initialize level objects
        LevelObject[] objects = gameObject.GetComponentsInChildren <LevelObject>(true);
        foreach (LevelObject obj in objects)
        {
            obj.Initialize();
        }

        //if (RacingManager.Instance != null)
        //    RacingManager.Instance.track.Build();

        foreach (LevelObject obj in objects)
        {
            obj.gameObject.SendMessage("OnPostInit", SendMessageOptions.DontRequireReceiver);
        }
    }
Example #4
0
    protected LevelCell BuildQuadTree(SBSBounds bounds, int depth, bool yUp = true)
    {
        LevelCell root = new LevelCell(bounds);

        this.RecursiveBuildQuadTree(null, root, 0, depth - 1, yUp);
        return(root);
    }
Example #5
0
    public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context)
    {
        LevelCell levelCell = (LevelCell)obj;

        info.AddValue("average", levelCell._average);
        info.AddValue("grayscale", levelCell._grayscale);
        info.AddValue("rgbComponents", levelCell._rgbComponents);
    }
Example #6
0
 public override void Initialize(LevelCell cell, LevelCell otherCell, LevelDirection direction)
 {
     base.Initialize(cell, otherCell, direction);
     wall.GetComponent <Renderer>().material = material;
     this.cell      = cell;
     this.otherCell = otherCell;
     this.direction = direction;
 }
 private void Start()
 {
     for (int levelNum = 0; levelNum < _levelTitles.Length; levelNum++)
     {
         GameObject newCell   = Instantiate(_cellPrefab, _content);
         LevelCell  levelCell = newCell.GetComponent <LevelCell>();
         levelCell.PopulateCell(levelNum + 1, _levelTitles[levelNum], _levelPreviews[levelNum], SaveData.IsLevelLocked(levelNum), SaveData.IsLevelComplete(levelNum));
     }
 }
Example #8
0
    private void DoFirstPostGenerationStep(LevelCell[,] cells, List <LevelCell> activeCells, IntVector2 coordinates, IntVector2 roomCoordinates, Canvas twoDMap, IntVector2 offset, IntVector2 size)
    {
        tempNodeList = new List <Node>();
        LevelCell cell = CreateCell(cells, coordinates, twoDMap, offset);

        cell.InitializeCell(this.cells[roomCoordinates.x, roomCoordinates.z].room);
        CreateTwoDCell(cell, twoDMap);
        activeCells.Add(cell);
    }
Example #9
0
 void SetupLevelTable()
 {
     foreach (LevelInfo levelInfo in  LevelManager.Instance.levelInfoByStageId[stageInfo.identifier])
     {
         GameObject stageObject = Instantiate(levelCellPrefab, levelTable);
         LevelCell  levelCell   = stageObject.GetComponent <LevelCell>();
         levelCell.InitWithLevelInfo(levelInfo, isUnlocked);
     }
 }
Example #10
0
    public System.Object SetObjectData(System.Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    {
        LevelCell levelCell = (LevelCell)obj;

        levelCell._average       = (Color)info.GetValue("average", typeof(Color));
        levelCell._grayscale     = (float)info.GetValue("grayscale", typeof(float));
        levelCell._rgbComponents = (RGBContent)info.GetValue("rgbComponents", typeof(RGBContent));
        obj = levelCell;
        return(obj);
    }
Example #11
0
    private void CreateTwoDCell(LevelCell cell, Canvas twoDMap)
    {
        Image newImage = Instantiate(twoDCellPrefab) as Image;

        newImage.transform.SetParent(twoDMap.transform, false);
        newImage.transform.localPosition = new Vector3((cell.coordinates.x - midX) * 1.0f, (cell.coordinates.z - midY) * 1.0f, 0);
        newImage.color = cell.room.mats.floorMaterial.color;
        newImage.transform.SetAsFirstSibling();
        cell.twoDImage = newImage;
    }
 public virtual void Initialize(LevelCell cell, LevelCell otherCell, LevelDirection direction)
 {
     this.cell      = cell;
     this.otherCell = otherCell;
     this.direction = direction;
     cell.SetEdge(direction, this);
     transform.parent        = cell.transform;
     transform.localPosition = Vector3.zero;
     transform.localRotation = direction.ToRotation();
 }
Example #13
0
    private void DoFirstGenerationStep(LevelCell [,] cells, List <LevelCell> activeCells, IntVector2 coordinates, Canvas twoDMap, IntVector2 offset, IntVector2 size)
    {
        tempNodeList = new List <Node>();
        coordinates  = new IntVector2(coordinates.x + offset.x, coordinates.z + offset.z);
        LevelCell cell = CreateCell(cells, coordinates, twoDMap, offset);

        cell.InitializeCell(CreateRoom(-1));
        CreateTwoDCell(cell, twoDMap);
        activeCells.Add(cell);
    }
Example #14
0
    private void CreateWall(LevelCell cell, LevelCell otherCell, LevelDirection direction, Canvas twoDMap)
    {
        LevelWall wall = Instantiate(wallPrefab) as LevelWall;

        wall.Initialize(cell, otherCell, direction);
        if (otherCell != null)
        {
            wall = Instantiate(wallPrefab) as LevelWall;
            wall.Initialize(otherCell, cell, direction.GetOpposite());
        }
        CreateTwoDWall(cell, twoDMap, direction);
    }
Example #15
0
    private void DoNextGenerationStep(LevelCell [,] cells, List <LevelCell> activeCells, Canvas twoDMap, IntVector2 offset, IntVector2 size)
    {
        int       currentIndex = activeCells.Count - 1;
        LevelCell currentCell  = activeCells[currentIndex];

        if (currentCell.IsFullyInitialized)
        {
            activeCells.RemoveAt(currentIndex);
            return;
        }
        LevelDirection direction   = currentCell.RandomUninitializedDirection;
        IntVector2     coordinates = currentCell.coordinates + direction.ToIntVector2();

        if (ContainsCoordinates(coordinates, size, offset))
        {
            LevelCell neighbor = cells[coordinates.x - offset.x, coordinates.z - offset.z];
            if (neighbor == null)
            {
                neighbor = CreateCell(cells, coordinates, twoDMap, offset);
                CreatePassage(currentCell, neighbor, direction, twoDMap, false);
                activeCells.Add(neighbor);
            }
            else if (currentCell.room == neighbor.room)
            {
                CreatePassageInSameRoom(currentCell, neighbor, direction, twoDMap);
            }
            else
            {
                if (currentCell.room.matIndex == neighbor.room.matIndex)
                {
                    CreatePassageInSameRoom(currentCell, neighbor, direction, twoDMap);
                }
                else
                {
                    if (Random.value < breakableWallProability)
                    {
                        CreateBreakableWall(currentCell, neighbor, direction, twoDMap);
                    }
                    else
                    {
                        CreateWall(currentCell, neighbor, direction, twoDMap);
                    }
                }
            }
        }
        else
        {
            CreateWall(currentCell, null, direction, twoDMap);
        }
    }
Example #16
0
    private void CreateBreakableWall(LevelCell cell, LevelCell otherCell, LevelDirection direction, Canvas twoDMap)
    {
        LevelBreakableWall wall = Instantiate(breakableWallPrefab) as LevelBreakableWall;

        wall.material = breakableMats[cell.room.matIndex];
        wall.Initialize(cell, otherCell, direction);
        breakableWalls.Add(wall);
        LevelBreakableWall otherWall = Instantiate(breakableWallPrefab) as LevelBreakableWall;

        otherWall.material = breakableMats[otherCell.room.matIndex];
        otherWall.Initialize(otherCell, cell, direction.GetOpposite());
        breakableWalls.Add(otherWall);
        CreateTwoDWall(cell, twoDMap, direction);
    }
Example #17
0
    private LevelCell CreateHallwayCell(IntVector2 coordinates, IntVector2 arrayCoordinates, Canvas twoDMap)
    {
        LevelCell newCell = Instantiate(cellPrefab) as LevelCell;

        cells[arrayCoordinates.x, arrayCoordinates.z] = newCell;
        newCell.coordinates             = coordinates;
        newCell.name                    = "Maze Cell " + newCell.coordinates.x + ", " + newCell.coordinates.z;
        newCell.transform.parent        = transform;
        newCell.transform.localPosition =
            new Vector3(newCell.coordinates.x - size.x * 0.5f + 0.5f, 0f, newCell.coordinates.z - size.z * 0.5f + 0.5f);
        CreateNodes(newCell.coordinates);

        return(newCell);
    }
Example #18
0
    public void Generate()
    {
        grid = new LevelCell[WIDTH, HEIGHT];
        for (int x = 0; x < WIDTH; x++)
        {
            for (int y = 0; y < HEIGHT; y++)
            {
                grid[x, y] = new LevelCell(UnityEngine.Random.Range(0, 4));
            }
        }

        UpdateGrid();

        transform.position = new Vector3(-WIDTH / 2f, -HEIGHT);
    }
Example #19
0
    /// <summary>
    /// Returns true if the cell in the level is visible by the given camera.
    /// </summary>
    private bool IsCellVisible(Cell cell, GameCamera camera)
    {
        // Get the LevelCell corresponding to the given cell coordinates.
        LevelCell levelCell = level.GetLevelCell(cell);

        // If the camera's frustum does not overlap the level cell
        if (camera.Right < levelCell.Left || camera.Left >= levelCell.Right ||
            camera.Top < levelCell.Bottom || camera.Bottom > levelCell.Top)
        {
            // Return false, since the camera cannot see the cell
            return(false);
        }

        // Return true if this statement is reached, since the camera can see the cell in the level
        return(true);
    }
Example #20
0
    private void CreatePassageInSameRoom(LevelCell cell, LevelCell otherCell, LevelDirection direction, Canvas twoDMap)
    {
        LevelPassage passage = Instantiate(passagePrefab) as LevelPassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(passagePrefab) as LevelPassage;
        passage.Initialize(otherCell, cell, direction.GetOpposite());
        if (cell.room != otherCell.room)
        {
            LevelRoom joinRoom = otherCell.room;
            cell.room.Join(joinRoom);
            rooms.Remove(joinRoom);
            Destroy(joinRoom);
        }
        CreateTwoDPassage(cell, twoDMap, direction);
    }
Example #21
0
    /// <summary>
    /// Creates and returns a LevelCell at the given (row,column) coordinates. A random prefab from 'cellPrefabs' is chosen
    /// and duplicated to serve as the physical cell inside the level.
    /// </summary>
    /// <param name="traversable">If true, the cell will be traversable by characters. If false, the cell is blocked off
    /// by obstacles and cannot be walked through by character </param>
    /// <param name="boundaryCell">If set to <c>true</c>, the cell is outside the bounds of the grid. It serves to block
    /// of the boundaries of the grid. Default = false</param>
    private LevelCell CreateLevelCell(int row, int column, GameObject[] cellPrefabs, bool traversable, bool boundaryCell)
    {
        // Choose a random prefab to occupy this given coordinates.
        GameObject cellPrefab = cellPrefabs[Random.Range(0, cellPrefabs.Length)];

        // Instantiate a copy of the chosen prefab.
        GameObject cellObject = Instantiate(cellPrefab);

        // Create a new LevelCell instance. This acts as a container for the cell in the level grid
        LevelCell levelCell = new LevelCell(row, column, cellWidth, cellHeight, cellObject, traversable);

        // Place the cell at the correct position in the level.
        levelCell.Transform.position = GetCellPosition(row, column);

        // Set the parent of each LevelCell to the same GameObject, the 'levelHolder'. Keeps the Hierarchy clean.
        levelCell.Transform.SetParent(levelHolder);

        // If the created cell is traversable
        if (traversable)
        {
            // Get the distance (in cell units) from the cell to the start of the level. This is the shortest path from the
            // cell to the starting cell of the level.
            int distanceToStart = GetDistanceToStart(row, column);
            // Update the cell's distance to the start of the level.
            levelCell.DistanceToStart = distanceToStart;

            // Populate the dictionary with a list at the index 'distanceToStart' to avoid a NullReferenceException
            if (!traversableCells.ContainsKey(distanceToStart))
            {
                traversableCells.Add(distanceToStart, new List <Cell>());
            }

            // Add the cell to the list of traversable cells in the level. The cell is stored in a dictionary mapping the
            // cell's distance from the start of level, to a list of cells that are at that distance.
            traversableCells[distanceToStart].Add(new Cell(row, column));
        }

        // If the created cell is inside the maze, and is not made to close off any boundaries, add it to the level grid.
        if (!boundaryCell)
        {
            // Store the created LevelCell inside the level grid for storage purposes
            grid[row, column] = levelCell;
        }

        // Return the created cell to place in the level grid
        return(levelCell);
    }
Example #22
0
    /// <summary>
    /// Generate the branches in the level maze. These are divergences in the maze that lead to nowhere
    /// </summary>
    private void GenerateBranches()
    {
        // Calculates the number of cells that separate each branch in the golden path. The branches are evenly distributed accross the golden path
        int branchSeparationDistance = (int)(goldenPath.Count / this.branchCount);

        // Iterate from 0 to the number of branches in the level and create each branch individually.
        for (int branchNumber = 0; branchNumber < this.branchCount; branchNumber++)
        {
            // Calculates the index of the cell at which the branch starts. This is the branchSeparationDistance*(branchNumber+1)
            // (Note: branchNumber incremented by one to avoid starting a branch at the first cell in the golden path.)
            // (Another Note: Final index decremented by one to avoid generating an index out of bounds of goldenPath:List<>)
            int startCellIndex = branchSeparationDistance * (branchNumber + 1) - 1;

            // Retrieve the golden path cell at which the branch will start.
            Cell startCell = goldenPath[startCellIndex];

            // Choose a cell in which to start the branch. Note that the function called is smart enough to return an onoccupied cell.
            Cell branchCell = ChooseNextTraversableCell(startCell, branchNavigator);

            // Invert the probabilities in the grid navigator so that the branches go in the opposite direction of the golden path.
            //gridNavigator.Invert ();

            // Cycles until 'maxBranchSize' cells are placed in the branch. or until a dead end is reached.
            for (int i = 0; i < maxBranchSize; i++)
            {
                // If the chosen cell to form the branching path is already occupied or is out of bounds of the grid, break
                // this for loop. The branch has reached a dead end.
                if (IsOccupied(branchCell) || IsOutOfBounds(branchCell))
                {
                    break;
                }

                // Create a traversable cell at the chosen (row,column) coordinates. This is a cell for the current branch being defined
                LevelCell branchLevelCell = CreateLevelCell(branchCell.row, branchCell.column, traversableCellPrefabs, true);

                // If the cell in the branch which was just created forms a dead end, break the loop, since the branch can't go any further
                if (IsDeadEnd(branchCell))
                {
                    break;
                }

                // Choose the next cell to be added to the branching path
                branchCell = ChooseNextTraversableCell(branchCell, branchNavigator);
            }
        }
    }
Example #23
0
    void Update()
    {
        if (GetComponent <Renderer>() != null)
        {
            _bounds = GetComponent <Renderer>().bounds;
        }
        else if (GetComponent <Collider>() != null)
        {
            _bounds = GetComponent <Collider>().bounds;
        }
        else
        {
            _bounds = new SBSBounds(_transform.position, SBSVector3.zero);
        }

        if (null == cell)
        {
            cell = LevelRoot.Instance.RootCell;
            if (null == cell)
            {
                return;
            }
            cell.AttachObject(this);
        }

        LevelCell newCell = cell.FindObjectContainmentCell(this);

        if (newCell != cell)
        {
            if (cell != null)
            {
                cell.DetachObject(this);
            }

            cell = newCell;
            cell.AttachObject(this);
        }

        _prevLocalToWorld = _localToWorld;
        _prevWorldToLocal = _worldToLocal;

        _localToWorld = _transform.localToWorldMatrix;
        _worldToLocal = _transform.worldToLocalMatrix;
    }
Example #24
0
    public void SetCell(int x, int y, int z, int level, Quaternion rotation)
    {
        if (levelCellList == null)
        {
            levelCellList = new List <LevelCell>();
        }
        LevelCell cell = levelCellList.Find(element => (element.x == x) && (element.y == y) && (element.z == z));

        if (cell == default)
        {
            cell          = new LevelCell();
            cell.x        = x;
            cell.y        = y;
            cell.z        = z;
            cell.rotation = rotation;
            levelCellList.Add(cell);
        }
        cell.prefabIndex = level;
    }
Example #25
0
    public IEnumerator CleanLevelCinematically()
    {
        LevelCell[,] areaCells = cells;
        IntVector2       offset    = new IntVector2(0, 0);
        List <LevelRoom> deadRooms = new List <LevelRoom>();

        foreach (LevelRoom room in rooms)
        {
            if (room.cells.Count <= 4)
            {
                deadRooms.Add(room);
                bool           roomCleaned = false;
                int            cellIndex   = 0;
                LevelCell      cell        = room.cells[0];
                LevelDirection direction   = 0;
                while (!roomCleaned && cellIndex < room.cells.Count)
                {
                    cell = room.cells[cellIndex];
                    while ((int)direction < 4 && !roomCleaned)
                    {
                        if (cell.GetEdge(direction) is LevelPassage)
                        {
                            IntVector2 coordinates = cell.coordinates + direction.ToIntVector2();
                            LevelCell  otherCell   = areaCells[coordinates.x - offset.x, coordinates.z - offset.z];
                            if (otherCell.room != cell.room)
                            {
                                StartCoroutine(AssimilateCinematically(otherCell.room, cell.room));
                                roomCleaned = true;
                            }
                        }
                        direction++;
                    }
                    cellIndex++;
                }
            }
            yield return(new WaitForSeconds(0.0f));
        }
        foreach (LevelRoom room in deadRooms)
        {
            rooms.Remove(room);
            Destroy(room);
        }
    }
    IEnumerator UpdateLoop()
    {
        yield return(new WaitForEndOfFrame());

        while (true)
        {
            // If the player has reached his destination
            if (((Vector2)player.transform.position - targetPosition).sqrMagnitude < 0.5f * 0.5f)
            {
                cellsTraversed++;

                /*if((cellsTraversed % 3) == 0)
                 * {
                 *      yield return new WaitForSeconds(idleTime);
                 *      continue;
                 * }*/

                int playerToStart = levelToTraverse.GetLevelCell(levelToTraverse.GetCellFromPosition(player.Transform.position)).DistanceToStart;

                // Choose the next to traverse to
                LevelCell nextCell = levelToTraverse.GetCellAtDistance(playerToStart + 1);

                if (nextCell == null)
                {
                    nextCell = levelToTraverse.GetCellAtDistance(playerToStart - 1);
                }

                // Update the target position
                targetPosition = nextCell.Transform.position;

                Action walk = player.CharacterControl.ActionSet.basicActions.GetBasicAction(BasicActionType.Walk);

                Debug.Log("WALK " + targetPosition);

                walk.targetPosition = targetPosition;

                player.CharacterControl.PerformAction(walk);
            }

            yield return(null);
        }
    }
Example #27
0
    /// <summary>
    /// Returns the distance from the given cell to the start of the level. Note: Only works if this cell has at least one neighbouring
    /// cell that is traversable. This distance denotes the shortest path (in cell units) from the start of the level to the given cell.
    /// Returns zero if the given cell has no traversable neighbouring cells.
    /// </summary>
    public int GetDistanceToStart(int row, int column)
    {
        // Store the traversable LevelCell that is
        // A) a neighbour of the given cell, and
        // B) closest to the starting cell in the level
        LevelCell closestNeighbourToStart = GetNeighbourClosestToStart(row, column);

        // If the given cell does not have any traversable neighbouring cells
        if (closestNeighbourToStart == null)
        {
            // Return zero, since there does not exist a path from this cell to the start of the level
            return(0);
        }

        // This cell is one unit away (in cell units) from his closest neighbour
        int distanceToStart = closestNeighbourToStart.DistanceToStart + 1;

        // Return the distance (in cell units) from the given cell to the starting cell of the level.
        return(distanceToStart);
    }
Example #28
0
    List <LevelCell> LoadAllLevelCells( )
    {
        List <LevelCell> lcl = new List <LevelCell>();

        lcl.AddRange(Resources.LoadAll <LevelCell>("LevelCells/"));

        // uses 'for' due to 'foreach' enumerators breaking from modifying the list in real time
        // checks each loaded cell to make sure nothing's just garbage or otherwise
        // not meant to be used
        for (int i = 0; i < lcl.Count; i++)
        {
            LevelCell lc = lcl [i];
            if (!lc.IsUsable)
            {
                lcl.Remove(lc);
            }
        }

        return(lcl);
    }
Example #29
0
    private void CreatePassage(LevelCell cell, LevelCell otherCell, LevelDirection direction, Canvas twoDMap, bool existingCell)
    {
        LevelPassage passage = Instantiate(passagePrefab) as LevelPassage;

        passage.Initialize(cell, otherCell, direction);
        passage = Instantiate(passagePrefab) as LevelPassage;
        if (!existingCell)
        {
            if (Random.value < newRoomProbability)
            {
                otherCell.InitializeCell(CreateRoom(cell.room.matIndex));
            }
            else
            {
                otherCell.InitializeCell(cell.room);
            }
            CreateTwoDCell(otherCell, twoDMap);
        }
        passage.Initialize(otherCell, cell, direction.GetOpposite());
        CreateTwoDPassage(cell, twoDMap, direction);
    }
Example #30
0
    private void CreateTwoDWall(LevelCell cell, Canvas twoDMap, LevelDirection direction)
    {
        IntVector2 positionMultiplier = direction.ToIntVector2();
        Vector3    cellPosition       = new Vector3((cell.coordinates.x - midX) * 1.0f, (cell.coordinates.z - midY) * 1.0f, 0);
        Vector2    offset             = new Vector2(positionMultiplier.x * 0.5f, positionMultiplier.z * 0.5f);
        Image      newImage           = null;

        if (positionMultiplier.x != 0)
        {
            newImage = Instantiate(twoDVertPrefab) as Image;
        }
        else
        {
            newImage = Instantiate(twoDHorzPrefab) as Image;
        }
        newImage.transform.SetParent(twoDMap.transform, false);
        newImage.transform.localPosition = new Vector3(cellPosition.x + offset.x, cellPosition.y + offset.y, 0);
        newImage.color = Color.black;
        newImage.transform.SetAsLastSibling();
        cell.GetEdge(direction).image = newImage;
    }