Exemplo n.º 1
0
    protected override void DoPrepare()
    {
        duration       = 0;
        columns        = Mathf.FloorToInt(Screen.width / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.x, Screen.width));
        rows           = Mathf.FloorToInt(Screen.height / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.y, Screen.height));
        actualTileSize = new Vector2(1f / columns, 1f / rows);

        tiles = new List <Tile>(columns * rows);
        for (int x = 0; x < columns; x++)
        {
            float startTime = 0;
            for (int y = 0; y < rows; y++)
            {
                startTime += UnityEngine.Random.Range(minDelayBetweenTiles, maxDelayBetweenTiles);
                float offset = state == SMTransitionState.In  ? 1 : 0;
                if (mode == Mode.AnimateBackground)
                {
                    offset = 1 - offset;
                }


                tiles.Add(new Tile(x, y, new Vector2(x * actualTileSize.x, y * actualTileSize.y + offset), startTime));
                duration = Mathf.Max(duration, startTime);
            }
        }

        duration += tileFallTime;
    }
Exemplo n.º 2
0
    private void DrawTiles()
    {
        var material = mode == Mode.AnimateLevelContents ? shaderMaterial : backgroundMaterial;

        for (var i = 0; i < material.passCount; ++i)
        {
            material.SetPass(i);
            GL.Begin(GL.QUADS);

            foreach (Tile tile in tiles)
            {
                float   tileProgress = SMTransitionUtils.SmoothProgress(tile.startTime, tileFallTime, effectTime);
                Vector2 position     = tile.position - Vector2.up * tileProgress;             // move the tile down

                if (position.y < 1 && position.y >= (-actualTileSize.y))
                {
                    GL.TexCoord3(tile.column * actualTileSize.x, tile.row * actualTileSize.y, 0);
                    GL.Vertex3(position.x, position.y, 0);
                    GL.TexCoord3(tile.column * actualTileSize.x, (tile.row + 1) * actualTileSize.y, 0);
                    GL.Vertex3(position.x, position.y + actualTileSize.y, 0);
                    GL.TexCoord3((tile.column + 1) * actualTileSize.x, (tile.row + 1) * actualTileSize.y, 0);
                    GL.Vertex3(position.x + actualTileSize.x, position.y + actualTileSize.y, 0);
                    GL.TexCoord3((tile.column + 1) * actualTileSize.x, tile.row * actualTileSize.y, 0);
                    GL.Vertex3(position.x + actualTileSize.x, position.y, 0);
                }
            }
            GL.End();
        }
    }
Exemplo n.º 3
0
        protected override void Prepare()
        {
            int preferredHeightInPixel = SMTransitionUtils.ToAbsoluteSize(preferredBlindsHeight, Screen.height);

            numberOfBlinds     = Mathf.FloorToInt(Screen.height / preferredHeightInPixel);
            actualBlindsHeight = (float)Screen.height / (float)numberOfBlinds;
            blindsStartOffset  = (duration - blindsFlipTime) / (float)numberOfBlinds;
        }
Exemplo n.º 4
0
 public void OnGUI()
 {
     GUI.depth = 0;
     for (int i = 0; i < numberOfBlinds; i++)
     {
         float progress      = SMTransitionUtils.SmoothProgress(i * blindsStartOffset, blindsFlipTime, effectTime);
         float visibleHeight = actualBlindsHeight * progress;
         GUI.DrawTexture(new Rect(0, i * actualBlindsHeight + (actualBlindsHeight - visibleHeight) / 2f, Screen.width, visibleHeight), blindsTexture);
     }
 }
Exemplo n.º 5
0
    protected override void Prepare()
    {
        if (tintMaterial == null)
        {
            tintMaterial = new Material(Shader.Find("Scene Manager/Cinema Effect"));
        }

        duration = fadeOutStartOffset + fadeOutDuration;
        float borderSizeInPixel = SMTransitionUtils.ToAbsoluteSize(borderSize, Screen.height);

        actualBorderSize = borderSizeInPixel / Screen.height;
    }
Exemplo n.º 6
0
    protected override bool Process(float elapsedTime)
    {
        float effectTime = elapsedTime;

        // invert direction if necessary
        if (state == SMTransitionState.In)
        {
            effectTime = duration - effectTime;
        }

        progress = SMTransitionUtils.SmoothProgress(0, duration, effectTime);

        return(elapsedTime < duration);
    }
Exemplo n.º 7
0
 protected override bool Process(float elapsedTime)
 {
     effectTime = elapsedTime - simplifiedShaderLagCompensation;
     // calculation phase.
     for (int x = 0; x < columns; x++)
     {
         for (int y = 0; y < rows; y++)
         {
             float tileProgress = SMTransitionUtils.SmoothProgress((x + y) * tileStartOffset, tilesFlipTime, effectTime);
             CalculateTile(x, y, tileProgress * 180);
         }
     }
     return(effectTime < duration);
 }
Exemplo n.º 8
0
    protected override bool Process(float elapsedTime)
    {
        float effectTime = elapsedTime - simplifiedShaderLagCompensation;
        float calcBase   = effectTime;

        // invert direction
        if (state == SMTransitionState.In)
        {
            calcBase = duration - effectTime;
        }

        progress = SMTransitionUtils.SmoothProgress(0, duration, calcBase);

        return(effectTime < duration);
    }
Exemplo n.º 9
0
    private void DrawBlade(float time)
    {
        float cutProgress = SMTransitionUtils.Progress(0, cutDuration, time);

        if (cutProgress > 0 && cutProgress < 1)
        {
            DrawBlade(firstCutStart, firstCutEnd, cutProgress, false);
        }

        cutProgress = SMTransitionUtils.Progress(cutDuration + delayBetweenCuts, cutDuration, time);
        if (cutProgress > 0 && cutProgress < 1)
        {
            DrawBlade(secondCutEnd, secondCutStart, 1 - cutProgress, true);
        }
    }
Exemplo n.º 10
0
    protected override bool Process(float elapsedTime)
    {
        float effectTime = elapsedTime;

        // invert direction
        if (state == SMTransitionState.In)
        {
            effectTime = duration - effectTime;
        }

        borderProgress = SMTransitionUtils.SmoothProgress(borderStartOffset, borderSlideDuration, effectTime);
        tintProgress   = SMTransitionUtils.SmoothProgress(tintStartOffset, tintDuration, effectTime);
        fadeProgress   = SMTransitionUtils.SmoothProgress(fadeOutStartOffset, fadeOutDuration, effectTime);

        return(elapsedTime < duration);
    }
Exemplo n.º 11
0
    private void DrawPieces(float time)
    {
        var material = state == SMTransitionState.Out ? shaderMaterial : backgroundMaterial;

        for (var i = 0; i < material.passCount; ++i)
        {
            material.SetPass(i);
            GL.Begin(GL.QUADS);

            Vector3 progress = new Vector3(0, -Screen.height * SMTransitionUtils.SmoothProgress(cutDuration, pieceFallTime, time), 0);
            GL.TexCoord3(0, 0, 0);
            GL.Vertex3(0, progress.y, 0);
            GL.TexCoord3(0, .2f, 0);
            GL.Vertex(firstCutStart + progress);
            GL.TexCoord3(1, .4f, 0);
            GL.Vertex(firstCutEnd + progress);
            GL.TexCoord3(1, 0, 0);
            GL.Vertex3(Screen.width, progress.y, 0);

            progress = new Vector3(0, -Screen.height * SMTransitionUtils.SmoothProgress(2 * cutDuration + delayBetweenCuts, pieceFallTime, time), 0);
            GL.TexCoord3(0, .2f, 0);
            GL.Vertex(firstCutStart + progress);
            GL.TexCoord3(0, .9f, 0);
            GL.Vertex(secondCutEnd + progress);
            GL.TexCoord3(1, .6f, 0);
            GL.Vertex(secondCutStart + progress);
            GL.TexCoord3(1, .4f, 0);
            GL.Vertex(firstCutEnd + progress);

            progress = new Vector3(0, -Screen.height * SMTransitionUtils.SmoothProgress(2 * cutDuration + 2 * delayBetweenCuts, pieceFallTime, time), 0);
            GL.TexCoord3(0, .9f, 0);
            GL.Vertex(secondCutEnd + progress);
            GL.TexCoord3(0, 1, 0);
            GL.Vertex3(0, Screen.height + progress.y, 0);
            GL.TexCoord3(1, 1, 0);
            GL.Vertex3(Screen.width, Screen.height + progress.y, 0);
            GL.TexCoord3(1, .6f, 0);
            GL.Vertex(secondCutStart + progress);

            GL.End();
        }
    }
Exemplo n.º 12
0
    protected override void Prepare()
    {
        if (material == null)
        {
            material = new Material(Shader.Find("Scene Manager/Cartoon Effect"));
            material.SetTexture("_Background", holdMaterial.mainTexture);
        }

        Vector2 pixelCenter = new Vector2(SMTransitionUtils.ToAbsoluteSize(center.x, Screen.width),
                                          SMTransitionUtils.ToAbsoluteSize(center.y, Screen.height));

        Vector2 bottomLeftPath  = pixelCenter - new Vector2(0, 0);
        Vector2 topLeftPath     = pixelCenter - new Vector2(0, Screen.height);
        Vector2 topRightPath    = pixelCenter - new Vector2(Screen.width, Screen.height);
        Vector2 bottomRightPath = pixelCenter - new Vector2(Screen.width, 0);

        length = Mathf.Max(bottomLeftPath.magnitude, topLeftPath.magnitude, topRightPath.magnitude, bottomRightPath.magnitude);
        material.SetFloat("_CenterX", pixelCenter.x);
        material.SetFloat("_CenterY", pixelCenter.y);

        material.SetColor("_BorderColor", borderColor);
    }
Exemplo n.º 13
0
    protected override void DoPrepare()
    {
        shaderMaterial.SetTexture("_Backface", holdMaterial.mainTexture);

        if (backgroundTexture)
        {
            backgroundMaterial.mainTexture = backgroundTexture;
        }

        topLeft     = gameObject.GetComponent <Camera>().ScreenToWorldPoint(new Vector3(0, Screen.height, distance));
        bottomRight = gameObject.GetComponent <Camera>().ScreenToWorldPoint(new Vector3(Screen.width, 0, distance));

        width  = bottomRight.x - topLeft.x;
        height = topLeft.y - bottomRight.y;

        columns = Mathf.FloorToInt(Screen.width / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.x, Screen.width));
        rows    = Mathf.FloorToInt(Screen.height / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.y, Screen.height));

        // recalculate size to avoid clipped tiles
        actualTileSize = new Vector2(width / columns, height / rows);

        tileStartOffset = (duration - tilesFlipTime) / (columns + rows);

        tileVertices        = new Vector3[rows * columns * 4]; // 4 vertices per tile
        transformedVertices = new Vector3[rows * columns * 4]; // 4 transformed vertices per tile.
        uvSet1 = new Vector2[rows * columns * 4];              // 4 uv coords per tile (1 per vertex)
        uvSet2 = new Vector2[rows * columns * 4];              // 4 uv coords per tile (1 per vertex)

        for (int x = 0; x < columns; x++)
        {
            for (int y = 0; y < rows; y++)
            {
                CalculateStaticTileData(x, y);
            }
        }
    }