Exemplo n.º 1
0
    public IEnumerator TransitioningExpression(Sprite sprite, float speed, bool smooth)
    {
        for (int i = 0; i < renderers.allExpressionRenderers.Count; i++)
        {
            Image image = renderers.allExpressionRenderers [i];
            if (image.sprite == sprite)
            {
                renderers.expressionRenderer = image;
                break;
            }
        }

        if (renderers.expressionRenderer.sprite != sprite)
        {
            Image image = GameObject.Instantiate(renderers.expressionRenderer.gameObject, renderers.expressionRenderer.transform.parent).GetComponent <Image> ();
            renderers.allExpressionRenderers.Add(image);
            renderers.expressionRenderer = image;
            image.color  = GlobalF.SetAlpha(image.color, 0f);
            image.sprite = sprite;
        }

        while (GlobalF.TransitionImages(ref renderers.expressionRenderer, ref renderers.allExpressionRenderers, speed, smooth, true))
        {
            yield return(new WaitForEndOfFrame());
        }

        StopTransitioningExpression();
    }
Exemplo n.º 2
0
    IEnumerator Revealing()
    {
        banner.enabled    = true;
        titleText.enabled = true;

        switch (displayMethod)
        {
        case DISPLAY_METHOD.instant:
            banner.color    = GlobalF.SetAlpha(banner.color, 1);
            titleText.color = GlobalF.SetAlpha(titleText.color, 1);
            break;

        case DISPLAY_METHOD.slowFade:
            yield return(SlowFade());

            break;

        case DISPLAY_METHOD.typeWritter:
            yield return(typeWritter());

            break;

        case DISPLAY_METHOD.floatingSlowFade:
            yield return(floatingFade());

            break;
        }
        revealing = null;
    }
Exemplo n.º 3
0
    IEnumerator Revealing()
    {
        banner.enabled    = true;
        titleText.enabled = true;
        //yield for the current display method.
        switch (displayMethod)
        {
        case DISPLAY_METHOD.instant:
            banner.color    = GlobalF.SetAlpha(banner.color, 1);
            titleText.color = GlobalF.SetAlpha(titleText.color, 1);
            break;

        case DISPLAY_METHOD.slowFade:
            yield return(SlowFade());

            break;

        case DISPLAY_METHOD.floatingSlowFade:
            yield return(FloatingSlowFade());

            break;

        case DISPLAY_METHOD.typeWriter:
            yield return(TypeWriter());

            break;
        }

        //title is displayed now.
        revealing = null;
    }
Exemplo n.º 4
0
    IEnumerator Revealing()
    {
        banner.enabled    = true;
        titleText.enabled = true;
        switch (displayMethod)
        {
        case DISPLAY_METHOD.instant:
            banner.color    = GlobalF.SetAlpha(banner.color, 1);
            titleText.color = GlobalF.SetAlpha(titleText.color, 1);
            break;

        case DISPLAY_METHOD.slowFade:
            banner.color    = GlobalF.SetAlpha(banner.color, 0);
            titleText.color = GlobalF.SetAlpha(titleText.color, 0);
            while (banner.color.a < 1)
            {
                banner.color    = GlobalF.SetAlpha(banner.color, Mathf.MoveTowards(banner.color.a, 1, fadeSpeed * Time.unscaledDeltaTime));
                titleText.color = GlobalF.SetAlpha(titleText.color, banner.color.a);
                yield return(new WaitForEndOfFrame());
            }
            break;

        case DISPLAY_METHOD.typeWriter:
            banner.color    = GlobalF.SetAlpha(banner.color, 1);
            titleText.color = GlobalF.SetAlpha(titleText.color, 1);
            TextArchitect architect = new TextArchitect(titleText, title);
            while (architect.isConstructing)
            {
                yield return(new WaitForEndOfFrame());
            }
            break;
        }
        //title is displayed
        revealing = null;
    }
        IEnumerator Transitioning(Texture texture, float speed, bool smooth)
        {
            if (texture != null)
            {
                for (int i = 0; i < allRawImages.Count; i++)
                {
                    RawImage image = allRawImages[i];
                    if (image.texture == texture)
                    {
                        activeRawImage = image;
                        break;
                    }
                }

                if (activeRawImage == null || activeRawImage.texture != texture)
                {
                    CreateNewactiveRawImage();
                    activeRawImage.texture = texture;
                    activeRawImage.color   = GlobalF.SetAlpha(activeRawImage.color, 0f);
                }
            }
            else
            {
                activeRawImage = null;
            }

            while (GlobalF.TransitionRawImages(ref activeRawImage, ref allRawImages, speed, smooth))
            {
                yield return(new WaitForEndOfFrame());
            }

            StopTransitioning();
        }
Exemplo n.º 6
0
 IEnumerator SlowFade()
 {
     banner.color    = GlobalF.SetAlpha(banner.color, 1);
     titleText.color = GlobalF.SetAlpha(titleText.color, 1);
     while (banner.color.a < 1)
     {
         banner.color    = GlobalF.SetAlpha(banner.color, Mathf.MoveTowards(banner.color.a, 1, fadeSpeed * Time.unscaledDeltaTime));
         titleText.color = GlobalF.SetAlpha(titleText.color, Mathf.MoveTowards(titleText.color.a, 1, fadeSpeed * Time.unscaledDeltaTime));
         yield return(new WaitForEndOfFrame());
     }
 }
Exemplo n.º 7
0
    IEnumerator typeWritter()
    {
        banner.color    = GlobalF.SetAlpha(banner.color, 1);
        titleText.color = GlobalF.SetAlpha(titleText.color, 1);
        TextArchitect architect = new TextArchitect(titleText, title);

        while (architect.isConstructing)
        {
            yield return(new WaitForEndOfFrame());
        }
    }
Exemplo n.º 8
0
    static IEnumerator TransitioningLayer(BCFC.LAYER layer, Texture2D targetTex, Texture2D transitionEffect, float speed, bool smooth)
    {
        GameObject ob = Instantiate(layer.newImageObjectReference, layer.newImageObjectReference.transform.parent) as GameObject;

        ob.SetActive(true);

        RawImage im = ob.GetComponent <RawImage>();

        im.texture = targetTex;

        layer.activeImage = im;
        layer.allImages.Add(im);

        im.material = new Material(instance.transitionMaterialPrefab);
        im.material.SetTexture("_AlphaTex", transitionEffect);
        im.material.SetFloat("_Cutoff", 1);
        float curVal = 1;

        while (curVal > 0)
        {
            curVal = smooth ? Mathf.Lerp(curVal, 0, speed * Time.deltaTime) : Mathf.MoveTowards(curVal, 0, speed * Time.deltaTime);
            im.material.SetFloat("_Cutoff", curVal);
            yield return(new WaitForEndOfFrame());
        }

        //remove the material so we can use regular alpha for transitions.
        //check for null if we rapidly progress through fading and transition overlaps.
        if (im != null)
        {
            im.material = null;
            //transition does not use alpha so make sure alpha is up.
            im.color = GlobalF.SetAlpha(im.color, 1);
        }

        //now remove all other images on layer.
        for (int i = layer.allImages.Count - 1; i >= 0; i--)
        {
            if (layer.allImages[i] == layer.activeImage && layer.activeImage != null)
            {
                continue;
            }

            if (layer.allImages[i] != null)
            {
                Destroy(layer.allImages[i].gameObject, 0.01f);
            }

            layer.allImages.RemoveAt(i);
        }

        //clear special transition field
        layer.specialTransitionCoroutine = null;
    }
Exemplo n.º 9
0
    static IEnumerator TransitioningLayer(BCFC.LAYER layer, Texture2D targetTex, Texture2D transitionEffect, float speed, bool smooth)
    {
        GameObject ob = Instantiate(layer.newImageObjectReference, layer.newImageObjectReference.transform.parent) as GameObject;

        ob.SetActive(true);

        RawImage im = ob.GetComponent <RawImage>();

        im.texture = targetTex;

        layer.activeImage = im;
        layer.allImages.Add(im);

        im.material = new Material(instance.transitionMaterialPrefab);
        im.material.SetTexture("_AlphaTex", transitionEffect);
        im.material.SetFloat("_CutOff", 1);
        float curVal = 1;

        while (curVal > 0)
        {
            curVal = smooth ? Mathf.Lerp(curVal, 0, speed * Time.deltaTime) : Mathf.MoveTowards(curVal, 0, speed * Time.deltaTime);
            im.material.SetFloat("_Cutoff", curVal);
            yield return(new WaitForEndOfFrame());
        }

        //remove material
        if (im != null)
        {
            im.material = null;
            im.color    = GlobalF.SetAlpha(im.color, 1);
        }

        for (int i = layer.allImages.Count - 1; i <= 0; i--)
        {
            if (layer.allImages[i] == layer.activeImage && layer.activeImage != null)
            {
                continue;
            }

            if (layer.allImages[i] != null)
            {
                Destroy(layer.allImages[i].gameObject, 0.01f);
            }
        }

        layer.specialTransitionCoroutine = null;
    }
Exemplo n.º 10
0
    IEnumerator floatingFade()
    {
        banner.color    = GlobalF.SetAlpha(banner.color, 0);
        titleText.color = GlobalF.SetAlpha(titleText.color, 0);

        float   amount  = 25f * ((float)Screen.height / 720f);
        Vector3 downPos = new Vector3(0, amount, 0);

        banner.transform.position = cachedBannerOriginalPosition - downPos;

        while (banner.color.a < 1 || banner.transform.position != cachedBannerOriginalPosition)
        {
            banner.color    = GlobalF.SetAlpha(banner.color, Mathf.MoveTowards(banner.color.a, 1, fadeSpeed * Time.unscaledDeltaTime));
            titleText.color = GlobalF.SetAlpha(titleText.color, banner.color.a);

            banner.transform.position = Vector3.MoveTowards(banner.transform.position, cachedBannerOriginalPosition, 11 * fadeSpeed * Time.unscaledDeltaTime);
            yield return(new WaitForEndOfFrame());
        }
    }
Exemplo n.º 11
0
        public void setTexture(Texture texture, bool ifMovieThenLoop = true)
        {
            if (activeImage != null && activeImage.texture != null)
            {
                VideoPlayer mov = new VideoPlayer();
                mov.targetTexture = (RenderTexture)texture;

                if (mov.texture != null)
                {
                    mov.Stop();
                }
            }

            if (texture != null)
            {
                if (activeImage == null)
                {
                    createNewActiveImage();
                }
                activeImage.texture = texture;
                activeImage.color   = GlobalF.SetAlpha(activeImage.color, 1f);

                VideoPlayer mov = new VideoPlayer();
                mov.targetTexture = (RenderTexture)texture;

                if (mov.texture != null)
                {
                    mov.isLooping = ifMovieThenLoop;
                    mov.Play();
                }
            }
            else
            {
                if (activeImage != null)
                {
                    allImages.Remove(activeImage);
                    GameObject.DestroyImmediate(activeImage.gameObject);
                    activeImage = null;
                }
            }
        }
Exemplo n.º 12
0
        IEnumerator Transitioning(Texture texture, float speed = 2f, bool smooth = false, bool ifMovieThenLoop = true)
        {
            if (texture != null)
            {
                for (int i = 0; i < allImages.Count; i++)
                {
                    RawImage image = allImages[i];
                    if (image.texture == texture)
                    {
                        activeImage = image;
                        break;
                    }
                }
                if (activeImage == null || activeImage.texture != texture)
                {
                    createNewActiveImage();
                    activeImage.texture = texture;
                    activeImage.color   = GlobalF.SetAlpha(activeImage.color, 0f);

                    //VideoPlayer mov = new VideoPlayer();
                    //mov.targetTexture = (RenderTexture)texture;

                    //if (mov != null)
                    //{

                    //	mov.isLooping = ifMovieThenLoop;
                    //	mov.Play();
                    //}
                }
            }
            else
            {
                activeImage = null;
            }
            while (GlobalF.TransitionRawImages(ref activeImage, ref allImages, speed, smooth))
            {
                yield return(new WaitForEndOfFrame());
            }

            StopTransitioning();
        }
 public void SetTexture(Texture texture)
 {
     if (texture != null)
     {
         if (activeRawImage == null)
         {
             CreateNewactiveRawImage();
         }
         activeRawImage.texture = texture;
         activeRawImage.color   = GlobalF.SetAlpha(activeRawImage.color, 1f);
     }
     else
     {
         if (activeRawImage != null)
         {
             allRawImages.Remove(activeRawImage);
             GameObject.DestroyImmediate(activeRawImage.gameObject);
             activeRawImage = null;
         }
     }
 }
Exemplo n.º 14
0
        IEnumerator Transitioning(Texture texture, float speed, bool smooth, bool ifMovieThenLoop)
        {
            if (texture != null)
            {
                for (int i = 0; i < allImages.Count; i++)
                {
                    RawImage image = allImages[i];
                    if (image.texture == texture)
                    {
                        activeImage = image;
                        break;
                    }
                }

                if (activeImage == null || activeImage.texture != texture)
                {
                    CreateNewActiveImage();
                    activeImage.texture = texture;
                    activeImage.color   = GlobalF.SetAlpha(activeImage.color, 0f);

                    //MovieTexture mov = texture as MovieTexture;
                    //if (mov != null)
                    //{
                    //    mov.loop = ifMovieThenLoop;
                    //    mov.Play();
                    //}
                }
            }
            else
            {
                activeImage = null;
            }

            while (GlobalF.TransitionRawImages(ref activeImage, ref allImages, speed, smooth))
            {
                yield return(new WaitForEndOfFrame());
            }

            StopTransitioning();
        }
Exemplo n.º 15
0
Arquivo: BCFC.cs Projeto: Hengle/Novel
        public void SetTexture(Texture texture, bool ifMovieThenLoop = true)
        {
            if (texture != null)
            {
                if (activeImage == null)
                {
                    CreateNewActiveImage();
                }

                activeImage.texture = texture;
                activeImage.color   = GlobalF.SetAlpha(activeImage.color, 1f);
            }
            else
            {
                if (activeImage != null)
                {
                    allImages.Remove(activeImage);
                    GameObject.DestroyImmediate(activeImage.gameObject);
                    activeImage = null;
                }
            }
        }
Exemplo n.º 16
0
        public void SetTexture(Texture texture, bool ifMovieThenLoop = true)
        {
            if (activeImage != null && activeImage.texture != null)
            {
                //MovieTexture mov = texture as MovieTexture;
                //if (mov != null)
                //    mov.Stop();
            }

            if (texture != null)
            {
                if (activeImage == null)
                {
                    CreateNewActiveImage();
                }

                activeImage.texture = texture;
                activeImage.color   = GlobalF.SetAlpha(activeImage.color, 1f);

                //MovieTexture mov = texture as MovieTexture;
                //if (mov != null)
                //{
                //    mov.loop = ifMovieThenLoop;
                //    mov.Play();
                //}
            }
            else
            {
                if (activeImage != null)
                {
                    allImages.Remove(activeImage);
                    GameObject.DestroyImmediate(activeImage.gameObject);
                    activeImage = null;
                }
            }
        }