Ejemplo n.º 1
0
    protected virtual void UpdateSprite(int newSpriteIndex, float newSpriteElapsed)
    {
        VFXAppearanceController shadow = null;

        spriteIndex   = newSpriteIndex;
        spriteElapsed = newSpriteElapsed;
        sprite        = null;
        spriteNormal  = null;
        if (sprites != null)
        {
            if ((spriteIndex > -1) && (sprites.Length > spriteIndex))
            {
                sprite = sprites[spriteIndex];
                if (spriteNormals != null)
                {
                    /*halmeida - if spriteNormals exists, it necessarily has the same length as sprites.*/
                    spriteNormal = spriteNormals[spriteIndex];
                }
            }
        }
        if (sprite == null)
        {
            spriteWidth      = 0f;
            focusOneValidity = false;
            focusTwoValidity = false;
        }
        else
        {
            spriteWidth    = sprite.bounds.size.x;
            focusOffsetOne = focusOffsetsOne[spriteIndex];
            focusOffsetTwo = focusOffsetsTwo[spriteIndex];
            if (spriteFlip)
            {
                focusOffsetOne = MirrorOffsetWithinSprite(focusOffsetOne);
                focusOffsetTwo = MirrorOffsetWithinSprite(focusOffsetTwo);
            }
            focusOneValidity = focusOneValidities[spriteIndex];
            focusTwoValidity = focusTwoValidities[spriteIndex];
            if (shadows != null)
            {
                for (int i = 0; i < shadows.Length; i++)
                {
                    shadow = shadows[i];
                    if (shadow != null)
                    {
                        /*halmeida - when updating the sprite of a shadow, I never lock the sprite. If a shadow
                         * has its sprite fixed at some point, that point is its creation.*/
                        shadow.SetSprite(sprite, spriteFlip, false);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    protected void RemoveShadow(int shadowIndex, bool fromPausedShadows)
    {
        VFXAppearanceController shadow = null;
        GameObject shadowObject        = null;

        VFXAppearanceController[] properShadows = null;
        GameObject[] properShadowObjects        = null;

        if (fromPausedShadows)
        {
            properShadowObjects = pausedShadowObjects;
            properShadows       = pausedShadows;
        }
        else
        {
            properShadowObjects = shadowObjects;
            properShadows       = shadows;
        }
        if (properShadows != null)
        {
            if ((shadowIndex > -1) && (shadowIndex < properShadows.Length))
            {
                shadow = properShadows[shadowIndex];
                if (shadow != null)
                {
                    shadow.Clear();
                    properShadows[shadowIndex] = null;
                }
                shadowObject = properShadowObjects[shadowIndex];
                if (shadowObject != null)
                {
                    Destroy(shadowObject);
                    properShadowObjects[shadowIndex] = null;
                }
                if (fromPausedShadows)
                {
                    UsefulFunctions.DecreaseArray <VFXAppearanceController>(ref pausedShadows, shadowIndex);
                    UsefulFunctions.DecreaseArray <GameObject>(ref pausedShadowObjects, shadowIndex);
                }
                else
                {
                    UsefulFunctions.DecreaseArray <VFXAppearanceController>(ref shadows, shadowIndex);
                    UsefulFunctions.DecreaseArray <GameObject>(ref shadowObjects, shadowIndex);
                }
            }
        }
    }
Ejemplo n.º 3
0
    public virtual void ClearShadows()
    {
        VFXAppearanceController shadow = null;
        GameObject shadowObject        = null;

        if (pausedShadows != null)
        {
            for (int i = 0; i < pausedShadows.Length; i++)
            {
                shadow = pausedShadows[i];
                if (shadow != null)
                {
                    shadow.Clear();
                    pausedShadows[i] = null;
                }
                shadowObject = pausedShadowObjects[i];
                if (shadowObject != null)
                {
                    Destroy(shadowObject);
                    pausedShadowObjects[i] = null;
                }
            }
            pausedShadows       = null;
            pausedShadowObjects = null;
        }
        if (shadows != null)
        {
            for (int i = 0; i < shadows.Length; i++)
            {
                shadow = shadows[i];
                if (shadow != null)
                {
                    shadow.Clear();
                    shadows[i] = null;
                }
                shadowObject = shadowObjects[i];
                if (shadowObject != null)
                {
                    Destroy(shadowObject);
                    shadowObjects[i] = null;
                }
            }
            shadows       = null;
            shadowObjects = null;
        }
    }
Ejemplo n.º 4
0
    protected virtual void ProgressShadows(float timeStep)
    {
        VFXAppearanceController shadow = null;

        VFXAppearanceController[] properShadows = null;

        properShadows = (paused ? pausedShadows : shadows);
        if (properShadows != null)
        {
            for (int i = 0; i < properShadows.Length; i++)
            {
                shadow = properShadows[i];
                if (shadow != null)
                {
                    shadow.Progress(timeStep);
                    if (shadow.IsOver())
                    {
                        RemoveShadow(i, paused);

                        /*halmeida - when we remove a shadow, the smaller array may be realocated somewhere else in memory.
                         * In this case, the porperShadows pointer will be pointing to the wrong place and has to be once again
                         * made to point to the proper memory place where the smaller array is.*/
                        properShadows = (paused ? pausedShadows : shadows);
                        if (properShadows == null)
                        {
                            break;
                        }
                        else
                        {
                            i--;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
    public virtual void CreateShadow(ShadowConfiguration shadowConfig)
    {
        GameObject shadowObject        = null;
        VFXAppearanceController shadow = null;
        int    shadowIndex             = 0;
        string properShadowName        = null;

        if (shadowConfig != null)
        {
            if (!paused)
            {
                shadowIndex      = (shadowObjects != null) ? shadowObjects.Length : 0;
                properShadowName = "ShadowObject";
            }
            else
            {
                shadowIndex      = (pausedShadowObjects != null) ? pausedShadowObjects.Length : 0;
                properShadowName = "PausedShadowObject";
            }
            shadowObject = new GameObject(properShadowName + shadowIndex);
            if (shadowObject != null)
            {
                shadow = shadowObject.AddComponent <VFXSpriteController>();
                if (shadow != null)
                {
                    if (!paused)
                    {
                        UsefulFunctions.IncreaseArray <GameObject>(ref shadowObjects, shadowObject);
                        UsefulFunctions.IncreaseArray <VFXAppearanceController>(ref shadows, shadow);
                    }
                    else
                    {
                        UsefulFunctions.IncreaseArray <GameObject>(ref pausedShadowObjects, shadowObject);
                        UsefulFunctions.IncreaseArray <VFXAppearanceController>(ref pausedShadows, shadow);
                    }
                    if (shadowConfig.fixedPosition)
                    {
                        shadowObject.transform.position = transform.position;
                        shadowObject.transform.rotation = transform.rotation;
                    }
                    else
                    {
                        shadowObject.transform.SetParent(transform, false);
                        shadowObject.transform.localPosition = Vector3.zero;
                        shadowObject.transform.localRotation = Quaternion.identity;
                    }
                    CorrectShadowDepths(transform.position.z);
                    shadow.ChangeRenderingMaterial(shadowConfig.renderingMaterial);
                    shadow.SetSprite(sprite, spriteFlip, shadowConfig.fixedSprite);
                    shadow.ConfigureScaleEvolution(shadowConfig.scaleOrigin, shadowConfig.scaleTargets, shadowConfig.scalingDurations);
                    shadow.ConfigureAlphaEvolution(shadowConfig.alphaOrigin, shadowConfig.alphaTargets, shadowConfig.fadeDurations);
                    shadow.ConfigureOutlineEvolution(shadowConfig.outlineColors, shadowConfig.outlineWidth, shadowConfig.outlineColorInterval,
                                                     shadowConfig.outlineAlphaOrigin, shadowConfig.outlineAlphaTargets, shadowConfig.outlineFadeDurations);
                    shadow.ConfigureColorAddition(shadowConfig.contentColorAddition);
                    shadow.StartEvolutions(shadowConfig.totalDuration);
                }
                else
                {
                    Destroy(shadowObject);
                }
            }
        }
    }