Esempio n. 1
0
        override public float Run()
        {
            if (spriteFader == null)
            {
                return(0f);
            }

            if (!isRunning)
            {
                isRunning = true;

                spriteFader.Fade(fadeType, fadeSpeed);

                if (willWait)
                {
                    return(fadeSpeed);
                }
            }
            else
            {
                isRunning = false;
            }

            return(0f);
        }
Esempio n. 2
0
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }
            else if (GetComponent <SpriteRenderer>() && saveColour)
            {
                Color _color = new Color(data.colourR, data.colourG, data.colourB, data.colourA);
                GetComponent <SpriteRenderer>().color = _color;
            }

            if (GetComponent <FollowTintMap>())
            {
                GetComponent <FollowTintMap>().LoadData(data);
            }

            if (limitVisibility)
            {
                limitVisibility.isLockedOff = !data.isOn;
            }
            else if (GetComponent <Renderer>())
            {
                GetComponent <Renderer>().enabled = data.isOn;
            }

            if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    _renderer.enabled = data.isOn;
                }
            }

            loadedData = true;
        }
Esempio n. 3
0
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                return;
            }

            if (GetComponent <SpriteFader>())
            {
                SpriteFader spriteFader = GetComponent <SpriteFader>();
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }

            if (GetComponent <Renderer>())
            {
                GetComponent <Renderer>().enabled = data.isOn;
            }

            if (affectChildren)
            {
                foreach (Renderer _renderer in GetComponentsInChildren <Renderer>())
                {
                    _renderer.enabled = data.isOn;
                }
            }
        }
        /**
         * <summary>Deserialises a string of data, and restores the GameObject to its previous state.</summary>
         * <param name = "stringData">The data, serialised as a string</param>
         */
        public override void LoadData(string stringData)
        {
            VisibilityData data = Serializer.LoadScriptData <VisibilityData> (stringData);

            if (data == null)
            {
                loadedData = false;
                return;
            }
            SavePrevented = data.savePrevented; if (savePrevented)
            {
                return;
            }

            SpriteFader spriteFader = GetComponent <SpriteFader>();

            if (spriteFader)
            {
                if (data.isFading)
                {
                    if (data.isFadingIn)
                    {
                        spriteFader.Fade(FadeType.fadeIn, data.fadeTime, data.fadeAlpha);
                    }
                    else
                    {
                        spriteFader.Fade(FadeType.fadeOut, data.fadeTime, data.fadeAlpha);
                    }
                }
                else
                {
                    spriteFader.EndFade();
                    spriteFader.SetAlpha(data.fadeAlpha);
                }
            }
            else
            {
                if (saveColour)
                {
                    SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
                    if (spriteRenderer)
                    {
                        Color _color = new Color(data.colourR, data.colourG, data.colourB, data.colourA);
                        spriteRenderer.color = _color;
                    }
                }
            }

            FollowTintMap followTintMap = GetComponent <FollowTintMap>();

            if (followTintMap)
            {
                followTintMap.LoadData(data);
            }

            if (limitVisibility)
            {
                limitVisibility.isLockedOff = !data.isOn;
            }
            else
            {
                Renderer renderer = GetComponent <Renderer>();
                if (renderer)
                {
                    renderer.enabled = data.isOn;
                }
                else
                {
                    Canvas canvas = GetComponent <Canvas>();
                    if (canvas)
                    {
                        canvas.enabled = data.isOn;
                    }
                }
            }

            if (affectChildren)
            {
                Renderer[] renderers = GetComponentsInChildren <Renderer>();
                foreach (Renderer _renderer in renderers)
                {
                    _renderer.enabled = data.isOn;
                }
            }

            loadedData = true;
        }