Example #1
0
    public void ReturnToPool(RoadTile tile)
    {
        tile.ApplyReturnProcess();

        if (tile.TileType != RoadTile.Type.Straight)
        {
            RotatorLink rotatorLink = tile.GetComponent <RotatorLink>();
            Rotator     rotator     = rotatorLink.DetachRotator();
            rotator.ApplyReturnProcess();
            rotatorPool.ReturnToPool(rotator);
        }

        roadTilePool.ReturnToPool(tile.TileType, tile);
        activeTileMap.Remove(tile.MapPosition);
    }
Example #2
0
    public void InstallTile(RoadTile.Type type, Vector3 position, Vector3 direction)
    {
        RoadTile installedTile = roadTilePool.GetFromPool(type);

        installedTile.transform.position = position;
        installedTile.transform.rotation = Quaternion.LookRotation(direction);

        Vector2 mapPosition = standingTilePosition + lastOutDirection;

        activeTileMap.Add(mapPosition, installedTile);

        lastWorldPoint = position;

        if (type != RoadTile.Type.Straight)
        {
            Rotator rotator;

            RotatorLink rotatorLink = installedTile.GetComponent <RotatorLink>();

            if (roadTilePool[roadTilePool.InstantiatedCount - 2].TileType != type)
            {
                rotator = rotatorPool.GetFromPool();

                float clockwiseValue;
                if (installedTile.TileType == RoadTile.Type.Left)
                {
                    clockwiseValue = -1;
                }
                else
                {
                    clockwiseValue = 1;
                }
                rotator.ApplyInstallProcess(clockwiseValue);
                rotatorLink.InstallRotator(rotator);
            }
            else
            {
                rotatorLink.Rotator = roadTilePool[roadTilePool.InstantiatedCount - 2].GetComponent <RotatorLink>().Rotator;
            }
        }

        installedTile.ApplyInstallProcess(direction, position, mapPosition);
    }