Esempio n. 1
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);
        }
    }
Esempio n. 2
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;
    }
Esempio n. 3
0
    private void CleanLevel(LevelCell[,] areaCells, IntVector2 offset)
    {
        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)
                            {
                                Assimilate(otherCell.room, cell.room);
                                roomCleaned = true;
                            }
                        }
                        direction++;
                    }
                    cellIndex++;
                }
            }
        }
        foreach (LevelRoom room in deadRooms)
        {
            rooms.Remove(room);
            Destroy(room);
        }
    }