예제 #1
0
    public void BuildTiles(OverworldData overworldData)
    {
        Dictionary <InGameOverworldTile, List <SerialisableGridLocation> > TileTransformationGridLocationByTile = new Dictionary <InGameOverworldTile, List <SerialisableGridLocation> >();

        for (int i = 0; i < overworldData.Tiles.Count; i++)
        {
            SerialisableTile serialisableTile = overworldData.Tiles[i];
            GameObject       tileGO           = GameObject.Instantiate(OverworldGameplayManager.Instance.InGameTilePrefab, _overworldContainer.transform);

            InGameOverworldTile tile = tileGO.GetComponent <InGameOverworldTile>();

            tile.SetGridLocation(serialisableTile.GridLocation.X, serialisableTile.GridLocation.Y);
            tile.SetId(serialisableTile.Id);

            tileGO.name = "Tile" + tile.GridLocation.X + ", " + tile.GridLocation.Y;
            tileGO.transform.position = GridLocation.GridToVector(tile.GridLocation);

            Tiles.Add(tile);

            AddBackgroundSprites(serialisableTile, tile);
            AddTileAttributes(serialisableTile, tile);
            AddCornerFillers(serialisableTile, tile);

            TilesByLocation.Add(tile.GridLocation, tile);

            GridLocation furthestBounds = LevelBounds;
            if (tile.GridLocation.X > furthestBounds.X)
            {
                _levelBounds.X = tile.GridLocation.X;
            }
            if (tile.GridLocation.Y > furthestBounds.Y)
            {
                _levelBounds.Y = tile.GridLocation.Y;
            }

            TileTransformationGridLocationByTile.Add(tile, serialisableTile.TilesToTransform);
        }

        for (int k = 0; k < Tiles.Count; k++)
        {
            InGameOverworldTile tile = Tiles[k] as InGameOverworldTile;
            tile.AddNeighbours(this);
        }
    }
예제 #2
0
    public void BuildTiles(OverworldData overworldData)
    {
        for (int i = 0; i < overworldData.Tiles.Count; i++)
        {
            SerialisableTile serialisableTile = overworldData.Tiles[i];
            GameObject       tileGO           = GameObject.Instantiate(OverworldGameplayManager.Instance.EditorTilePrefab, _overworldContainer.transform);

            EditorOverworldTile tile = tileGO.GetComponent <EditorOverworldTile>();
            tile.SetGridLocation(serialisableTile.GridLocation.X, serialisableTile.GridLocation.Y);
            tile.SetId(serialisableTile.Id);

            tileGO.name = "Tile" + tile.GridLocation.X + ", " + tile.GridLocation.Y;
            tileGO.transform.position = GridLocation.GridToVector(tile.GridLocation);

            Tiles.Add(tile);

            AddTileAttributes(serialisableTile, tile);
            AddBackgroundSprites(serialisableTile, tile);
            AddCornerFillers(serialisableTile, tile);

            ITileMainMaterial mainMaterial = AddMainMaterial(serialisableTile);
            tile.SetMainMaterial(mainMaterial);

            TilesByLocation.Add(tile.GridLocation, tile);

            GridLocation furthestBounds = LevelBounds;
            if (tile.GridLocation.X > furthestBounds.X)
            {
                _levelBounds.X = tile.GridLocation.X;
            }
            if (tile.GridLocation.Y > furthestBounds.Y)
            {
                _levelBounds.Y = tile.GridLocation.Y;
            }
        }

        for (int k = 0; k < Tiles.Count; k++)
        {
            EditorOverworldTile tile = Tiles[k] as EditorOverworldTile;
            tile.AddNeighbours(this);
        }
    }
예제 #3
0
    public override void BuildTiles(MazeLevelData mazeLevelData)
    {
        Dictionary <InGameMazeTile, List <SerialisableGridLocation> > TileTransformationGridLocationByTile = new Dictionary <InGameMazeTile, List <SerialisableGridLocation> >();

        for (int i = 0; i < mazeLevelData.Tiles.Count; i++)
        {
            SerialisableTile serialisableTile = mazeLevelData.Tiles[i];
            GameObject       tileGO           = GameObject.Instantiate(MazeLevelGameplayManager.Instance.InGameTilePrefab, _mazeContainer.transform);

            InGameMazeTile tile = tileGO.GetComponent <InGameMazeTile>();

            tile.SetGridLocation(serialisableTile.GridLocation.X, serialisableTile.GridLocation.Y);
            tile.SetId(serialisableTile.Id);

            tileGO.name = "Tile" + tile.GridLocation.X + ", " + tile.GridLocation.Y;
            tileGO.transform.position = GridLocation.GridToVector(tile.GridLocation);

            Tiles.Add(tile);

            AddBackgroundSprites(serialisableTile, tile);
            AddTileAttributes(serialisableTile, tile);
            AddCornerFillers(serialisableTile, tile);
            AddTileAreas(serialisableTile, tile);

            TilesByLocation.Add(tile.GridLocation, tile);

            GridLocation furthestBounds = LevelBounds;
            if (tile.GridLocation.X > furthestBounds.X)
            {
                _levelBounds.X = tile.GridLocation.X;
            }
            if (tile.GridLocation.Y > furthestBounds.Y)
            {
                _levelBounds.Y = tile.GridLocation.Y;
            }

            TileTransformationGridLocationByTile.Add(tile, serialisableTile.TilesToTransform);
        }

        foreach (KeyValuePair <InGameMazeTile, List <SerialisableGridLocation> > item in TileTransformationGridLocationByTile)
        {
            List <InGameMazeTile> tilesToTransform = new List <InGameMazeTile>();

            for (int i = 0; i < item.Value.Count; i++)
            {
                for (int j = 0; j < Tiles.Count; j++)
                {
                    InGameMazeTile tile = Tiles[j] as InGameMazeTile;
                    if (item.Value[i].X == tile.GridLocation.X && item.Value[i].Y == tile.GridLocation.Y)
                    {
                        tilesToTransform.Add(tile);
                        break;
                    }
                }
            }

            item.Key.AddTilesToTransform(tilesToTransform);
        }

        for (int k = 0; k < Tiles.Count; k++)
        {
            InGameMazeTile tile = Tiles[k] as InGameMazeTile;
            tile.AddNeighbours(this);
        }

        ConnectBridgeEdgesToTheirBridgePieces();
    }
예제 #4
0
    public override void BuildTiles(MazeLevelData mazeLevelData)
    {
        Dictionary <SerialisableGridLocation, List <EditorMazeTile> > TileTransformationTriggererByGridLocation = new Dictionary <SerialisableGridLocation, List <EditorMazeTile> >();

        for (int i = 0; i < mazeLevelData.Tiles.Count; i++)
        {
            SerialisableTile serialisableTile = mazeLevelData.Tiles[i];
            GameObject       tileGO           = GameObject.Instantiate(MazeLevelGameplayManager.Instance.EditorTilePrefab, _mazeContainer.transform);

            EditorMazeTile tile = tileGO.GetComponent <EditorMazeTile>();
            tile.SetGridLocation(serialisableTile.GridLocation.X, serialisableTile.GridLocation.Y);
            tile.SetId(serialisableTile.Id);


            tileGO.name = "Tile" + tile.GridLocation.X + ", " + tile.GridLocation.Y;
            tileGO.transform.position = GridLocation.GridToVector(tile.GridLocation);

            Tiles.Add(tile);

            AddTileAttributes(serialisableTile, tile);
            AddBackgroundSprites(serialisableTile, tile);
            AddCornerFillers(serialisableTile, tile);
            AddTileAreas(serialisableTile, tile);

            TilesByLocation.Add(tile.GridLocation, tile);

            ITileMainMaterial mainMaterial = AddMainMaterial(serialisableTile);
            tile.SetMainMaterial(mainMaterial);

            GridLocation furthestBounds = LevelBounds;
            if (tile.GridLocation.X > furthestBounds.X)
            {
                _levelBounds.X = tile.GridLocation.X;
            }
            if (tile.GridLocation.Y > furthestBounds.Y)
            {
                _levelBounds.Y = tile.GridLocation.Y;
            }

            if (serialisableTile.TilesToTransform != null)
            {
                for (int j = 0; j < serialisableTile.TilesToTransform.Count; j++)
                {
                    if (TileTransformationTriggererByGridLocation.ContainsKey(serialisableTile.TilesToTransform[j]))
                    {
                        List <EditorMazeTile> transformationTriggerers = TileTransformationTriggererByGridLocation[serialisableTile.TilesToTransform[j]];
                        transformationTriggerers.Add(tile);
                    }
                    else
                    {
                        List <EditorMazeTile> transformationTriggerers = new List <EditorMazeTile>();
                        transformationTriggerers.Add(tile);
                        TileTransformationTriggererByGridLocation.Add(serialisableTile.TilesToTransform[j], transformationTriggerers);
                    }
                }
            }
        }

        foreach (KeyValuePair <SerialisableGridLocation, List <EditorMazeTile> > item in TileTransformationTriggererByGridLocation)
        {
            for (int i = 0; i < Tiles.Count; i++)
            {
                EditorMazeTile tile = Tiles[i] as EditorMazeTile;
                if (item.Key.X == tile.GridLocation.X && item.Key.Y == tile.GridLocation.Y)
                {
                    tile.BeautificationTriggerers = item.Value;
                }
            }
        }

        for (int k = 0; k < Tiles.Count; k++)
        {
            EditorMazeTile tile = Tiles[k] as EditorMazeTile;
            tile.AddNeighbours(this);
        }

        ConnectBridgeEdgesToTheirBridgePieces();
    }