示例#1
0
 // Update is called once per frame
 void Update()
 {
     BCFC.LAYER layer = null;
     if (Input.GetKey(KeyCode.Z)) // if this key is pressed, it will load a new background
     {
         layer = controller.background;
     }
     if (Input.GetKey(KeyCode.X))
     {
         layer = controller.cinematic; //key related to cinematics
     }
     if (Input.GetKey(KeyCode.C))
     {
         layer = controller.foreground; //key related to foreground
     }
     if (Input.GetKey(KeyCode.V))
     {
         if (Input.GetKeyDown(KeyCode.A))
         {
             layer.TransitionToTexture(text);
         }
         // else if (Input.GetKeyDown(KeyCode.S))
         // layer.SetTexture(mov);
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.A))
         {
             layer.SetTexture(text);
         }
         //  else if (Input.GetKeyDown(KeyCode.S))
         //  layer.SetTexture(mov);
     }
 }
示例#2
0
    void Command_TransLayer(BCFC.LAYER layer, string data)
    {
        string[] parameters = data.Split(',');

        string    texName      = parameters[0];
        string    transTexName = parameters[1];
        Texture2D tex          = texName == "null" ? null : Resources.Load("Images/UI/Backdrops/" + texName) as Texture2D;
        Texture2D transTex     = Resources.Load("Images/TransitionEffects/" + transTexName) as Texture2D;

        float spd    = 2f;
        bool  smooth = false;

        for (int i = 2; i < parameters.Length; i++)
        {
            string p    = parameters[i];
            float  fVal = 0;
            bool   bVal = false;
            if (float.TryParse(p, out fVal))
            {
                spd = fVal; continue;
            }
            if (bool.TryParse(p, out bVal))
            {
                smooth = bVal; continue;
            }
        }

        TransitionMaster.TransitionLayer(layer, tex, transTex, spd, smooth);
    }
示例#3
0
    void Command_SetLayerImage(string data, BCFC.LAYER layer)
    {
        string    texName = data.Contains(",") ? data.Split(',')[0] : data;
        Texture2D tex     = texName == "null" ? null : Resources.Load("Images/UI/Backdrops/" + texName) as Texture2D;
        float     spd     = 2f;    //optional speed parameter
        bool      smooth  = false; //optional smooth transition parameter


        if (data.Contains(","))
        {
            string[] parameters = data.Split(',');



            foreach (string p in parameters)
            {
                float fVal = 0;
                bool  bVal = false;
                if (float.TryParse(p, out fVal))
                {
                    spd = fVal; continue;
                }
                if (bool.TryParse(p, out bVal))
                {
                    smooth = bVal; continue;
                }
            }
        }
        layer.TransitionToTexture(tex, spd, smooth);
    }
示例#4
0
    void command_setLayerImage(string data, BCFC.LAYER layer)
    {
        string    texName = data.Contains(",") ? data.Split(',')[0] : data;
        Texture2D tex     = texName == "null" ? null : Resources.Load("Images/Background/" + texName) as Texture2D;
        float     spd     = 2.0f;
        bool      smooth  = false;

        if (data.Contains(","))
        {
            string[] parameter = data.Split(',');
            foreach (string p in parameter)
            {
                float fVal = 2.0f;
                bool  bVal = false;
                if (float.TryParse(p, out fVal))
                {
                    spd = fVal; continue;
                }
                if (bool.TryParse(p, out bVal))
                {
                    smooth = bVal; continue;
                }
            }
        }
        layer.setTexture(tex);
    }
    static IEnumerator TransitioningLayerToNull(BCFC.LAYER layer, Texture2D transitionEffect, float speed = 1, bool smooth = false)
    {
        List <RawImage> currentImageOnLayer = new List <RawImage>();

        foreach (RawImage r in layer.allImage)
        {
            r.material = new Material(instance.transitionMaterialInPrefab);
            r.material.SetTexture("_AlphaTex", transitionEffect);
            r.material.SetFloat("_Cutoff", 0);
            currentImageOnLayer.Add(r);
        }
        float curVal = 0;

        while (curVal < 1)
        {
            curVal = smooth ? Mathf.Lerp(curVal, 1, speed * Time.deltaTime) : Mathf.MoveTowards(curVal, 1, speed * Time.deltaTime);
            for (int i = 0; i < layer.allImage.Count; i++)
            {
                layer.allImage[i].material.SetFloat("_Cutoff", curVal);
            }
            yield return(new WaitForEndOfFrame());
        }
        foreach (RawImage r in currentImageOnLayer)
        {
            layer.allImage.Remove(r);
            if (r != null)
            {
                Destroy(r.gameObject, 0.01f);
            }
        }
        layer.specialTransitionCoroutine = null;
    }
示例#6
0
 // Update is called once per frame
 void Update()
 {
     BCFC.LAYER layer = controller.background;
     if (Input.GetKey(KeyCode.Q))
     {
         layer = controller.background;
     }
     if (Input.GetKey(KeyCode.W))
     {
         layer = controller.cinematic;
     }
     if (Input.GetKey(KeyCode.E))
     {
         layer = controller.foreground;
     }
     if (Input.GetKey(KeyCode.T))
     {
         if (Input.GetKeyDown(KeyCode.A))
         {
             layer.TransitionToTexture(tex, speed, smooth);
         }
     }
     else
     {
         if (Input.GetKeyDown(KeyCode.A))
         {
             layer.setTexture(tex);
         }
     }
 }
示例#7
0
    void command_transitionLayer(string data, BCFC.LAYER layer)
    {
        string[]  parameter            = data.Split(',');
        string    targetTexName        = parameter[0];
        string    transitionEffectName = parameter[1];
        float     speed            = parameter.Length >= 3 ? float.Parse(parameter[2]) : 3f;
        bool      smooth           = parameter.Length == 4 ? bool.Parse(parameter[3]) : true;
        Texture2D targetTex        = targetTexName == null ? null : Resources.Load("Images/Background/" + targetTexName) as Texture2D;
        Texture2D transitionEffect = transitionEffectName == null ? null : Resources.Load("Images/TransitionEffect" + transitionEffectName) as Texture2D;

        TransitionMaster.TransitionLayer(layer, targetTex, transitionEffect, speed, smooth);
    }
示例#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;
    }
    public static void TransitionLayer(BCFC.LAYER layer, Texture2D targetImage, Texture2D transitionEffect, float speed = 1, bool smooth = false)
    {
        if (layer.specialTransitionCoroutine != null)
        {
            instance.StopCoroutine(layer.specialTransitionCoroutine);
        }

        if (targetImage != null)
        {
            layer.specialTransitionCoroutine = instance.StartCoroutine(TransitioningLayer(layer, targetImage, transitionEffect, speed, smooth));
        }
        else
        {
            layer.specialTransitionCoroutine = instance.StartCoroutine(TransitioningLayerToNull(layer, transitionEffect, speed, smooth));
        }
    }
示例#10
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;
    }