Esempio n. 1
0
 public override void CreateShadow(ShadowConfiguration shadowConfig)
 {
     if (bodyAnimator != null)
     {
         bodyAnimator.CreateShadow(shadowConfig);
     }
 }
Esempio n. 2
0
 public void ReconfigurePeriodicShadow(ShadowConfiguration newShadowConfiguration)
 {
     if (shadowPeriodic != null)
     {
         shadowPeriodic.Copy(newShadowConfiguration);
     }
 }
 private static bool BelongToGroup(LightComponent light, ShadowMap shadow, ShadowConfiguration config, int groupCount, Texture groupTexture)
 {
     return(light.ShadowMapCascadeCount == config.CascadeCount &&
            light.ShadowMapFilterType == config.FilterType &&
            groupCount < config.ShadowCount &&
            (groupTexture == null || groupTexture == shadow.Texture.ShadowMapDepthTexture));
 }
Esempio n. 4
0
    protected override void Awake()
    {
        GameObject          shadowConfigModel  = null;
        GameObject          shadowConfigObject = null;
        ShadowConfiguration shadowConfig       = null;
        int shadowConfigsLength = 0;

        bodyAnimator          = null;
        shadowPeriodicObject  = null;
        shadowFullHealObject  = null;
        shadowsLevelUpObjects = null;
        shadowPeriodic        = null;
        shadowFullHeal        = null;
        shadowsLevelUp        = null;
        base.Awake();
        if (shadowConfigPeriodic != null)
        {
            shadowPeriodicObject = Instantiate(shadowConfigPeriodic) as GameObject;
            if (shadowPeriodicObject != null)
            {
                shadowPeriodic = shadowPeriodicObject.GetComponent <ShadowConfiguration>();
            }
        }
        if (shadowConfigFullHeal != null)
        {
            shadowFullHealObject = Instantiate(shadowConfigFullHeal) as GameObject;
            if (shadowFullHealObject != null)
            {
                shadowFullHeal = shadowFullHealObject.GetComponent <ShadowConfiguration>();
            }
        }
        if (shadowConfigsLevelUp != null)
        {
            shadowConfigsLength = shadowConfigsLevelUp.Length;
            if (shadowConfigsLength > 0)
            {
                shadowsLevelUpObjects = new GameObject[shadowConfigsLength];
                shadowsLevelUp        = new ShadowConfiguration[shadowConfigsLength];
                for (int i = 0; i < shadowConfigsLength; i++)
                {
                    shadowConfigModel  = shadowConfigsLevelUp[i];
                    shadowConfigObject = null;
                    shadowConfig       = null;
                    if (shadowConfigModel != null)
                    {
                        shadowConfigObject = Instantiate(shadowConfigModel) as GameObject;
                        if (shadowConfigObject != null)
                        {
                            shadowConfig = shadowConfigObject.GetComponent <ShadowConfiguration>();
                        }
                    }
                    shadowsLevelUpObjects[i] = shadowConfigObject;
                    shadowsLevelUp[i]        = shadowConfig;
                }
            }
        }
    }
Esempio n. 5
0
 public void Copy(ShadowConfiguration otherConfig)
 {
     if (otherConfig != null)
     {
         creationInterval  = otherConfig.creationInterval;
         fixedPosition     = otherConfig.fixedPosition;
         fixedSprite       = otherConfig.fixedSprite;
         renderingMaterial = otherConfig.renderingMaterial;
         alphaOrigin       = otherConfig.alphaOrigin;
         alphaTargets      = null;
         if (otherConfig.alphaTargets != null)
         {
             alphaTargets = (float[])otherConfig.alphaTargets.Clone();
         }
         fadeDurations = null;
         if (otherConfig.fadeDurations != null)
         {
             fadeDurations = (float[])otherConfig.fadeDurations.Clone();
         }
         scaleOrigin  = otherConfig.scaleOrigin;
         scaleTargets = null;
         if (otherConfig.scaleTargets != null)
         {
             scaleTargets = (Vector3[])otherConfig.scaleTargets.Clone();
         }
         scalingDurations = null;
         if (otherConfig.scalingDurations != null)
         {
             scalingDurations = (float[])otherConfig.scalingDurations.Clone();
         }
         outlineColors = null;
         if (otherConfig.outlineColors != null)
         {
             outlineColors = (Color[])otherConfig.outlineColors.Clone();
         }
         outlineColorInterval = otherConfig.outlineColorInterval;
         outlineWidth         = otherConfig.outlineWidth;
         outlineAlphaOrigin   = otherConfig.outlineAlphaOrigin;
         outlineAlphaTargets  = null;
         if (otherConfig.outlineAlphaTargets != null)
         {
             outlineAlphaTargets = (float[])otherConfig.outlineAlphaTargets.Clone();
         }
         outlineFadeDurations = null;
         if (otherConfig.outlineFadeDurations != null)
         {
             outlineFadeDurations = (float[])otherConfig.outlineFadeDurations.Clone();
         }
         contentColorAddition = otherConfig.contentColorAddition;
         totalDuration        = otherConfig.totalDuration;
     }
 }
        private static List <ShadowConfiguration> CreateShadowConfiguration(List <EntityLightShadow> lights, LightType lightType)
        {
            var resultList          = new List <ShadowConfiguration>();
            var groupedShadowLights = lights.GroupBy(x => new ShadowMapGroup()
            {
                Texture = x.ShadowMap.Texture, CascadeCount = x.ShadowMap.CascadeCount, FilterType = x.ShadowMap.Filter
            });

            foreach (var lightGroup in groupedShadowLights)
            {
                var shadowGroup = new ShadowConfiguration()
                {
                    CascadeCount = lightGroup.Key.CascadeCount,
                    FilterType   = lightGroup.Key.FilterType,
                    LightType    = lightType,
                    ShadowCount  = lightGroup.Count()
                };
                resultList.Add(shadowGroup);
            }
            return(resultList);
        }
Esempio n. 7
0
    protected void ClearShadowConfigurations()
    {
        GameObject shadowObject = null;

        shadowPeriodic = null;
        shadowFullHeal = null;
        if (shadowsLevelUp != null)
        {
            for (int i = 0; i < shadowsLevelUp.Length; i++)
            {
                shadowsLevelUp[i] = null;
            }
            shadowsLevelUp = null;
        }
        if (shadowPeriodicObject != null)
        {
            Destroy(shadowPeriodicObject);
            shadowPeriodicObject = null;
        }
        if (shadowFullHealObject != null)
        {
            Destroy(shadowFullHealObject);
            shadowFullHealObject = null;
        }
        if (shadowsLevelUpObjects != null)
        {
            for (int i = 0; i < shadowsLevelUpObjects.Length; i++)
            {
                shadowObject = shadowsLevelUpObjects[i];
                if (shadowObject != null)
                {
                    Destroy(shadowObject);
                    shadowsLevelUpObjects[i] = null;
                }
            }
            shadowsLevelUpObjects = null;
        }
    }
Esempio n. 8
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);
                }
            }
        }
    }