Example #1
0
        public LightEffectHandler(WorldElement parent, LightEffect effect, Vector2f basePosition, int baseZ)
        {
            Parent = parent;
            Effect = effect;
            BasePosition = basePosition;
            BaseZ = baseZ;

            Parent.OnMove += new MoveEventHandler(Parent_OnMove);

            Update();
        }
Example #2
0
        public bool RemoveLightEffect(LightEffect lightEffect)
        {
            foreach (LightEffectHandler lightEffectHandler in LightEffects)
            {
                if (lightEffect != lightEffectHandler.Effect)
                    continue;

                if (Map != null)
                    Map.RemoveStaticLightEffect(lightEffect);

                return LightEffects.Remove(lightEffectHandler);
            }

            return false;
        }
Example #3
0
 public static LightEffect CopyLightEffect(LightEffect template, LightEffect target)
 {
     target.m_alignment         = template.m_alignment;
     target.m_batchedLight      = template.m_batchedLight;
     target.m_blinkType         = template.m_blinkType;
     target.m_fadeEndDistance   = template.m_fadeEndDistance;
     target.m_fadeSpeed         = template.m_fadeSpeed;
     target.m_fadeStartDistance = template.m_fadeStartDistance;
     target.m_offRange          = template.m_offRange;
     target.m_position          = template.m_position;
     target.m_positionIndex     = template.m_positionIndex;
     target.m_rotationAxis      = template.m_rotationAxis;
     target.m_rotationSpeed     = template.m_rotationSpeed;
     target.m_spotLeaking       = template.m_spotLeaking;
     target.m_variationColors   = template.m_variationColors;
     return(target);
 }
Example #4
0
 public void AddLightEffect(LightEffect lightEffect, int baseZ)
 {
     AddLightEffect(new LightEffectHandler(this, lightEffect, baseZ));
 }
Example #5
0
 public void AddLightEffect(LightEffect lightEffect, Vector2f basePosition)
 {
     AddLightEffect(new LightEffectHandler(this, lightEffect, basePosition));
 }
Example #6
0
 public void AddLightEffect(LightEffect lightEffect)
 {
     AddLightEffect(new LightEffectHandler(this, lightEffect));
 }
Example #7
0
 public LightEffectHandler(WorldElement parent, LightEffect effect, int baseZ)
     : this(parent, effect, DEFAULT_LIGHT_BASE_POSITION, baseZ)
 {
 }
Example #8
0
 public LightEffectHandler(WorldElement parent, LightEffect effect, Vector2f basePosition)
     : this(parent, effect, basePosition, DEFAULT_LIGHT_BASE_Z)
 {
 }
Example #9
0
 public void RemoveDynamicEffect(LightEffect effect)
 {
     DynamicEffects.Remove(effect);
 }
Example #10
0
 /// <summary>
 /// When this state is sent to the bridge, sets the current effect of the light.
 /// </summary>
 /// <returns>This LightStateBuilder instance, for method chaining.</returns>
 public LightStateBuilder Effect(LightEffect effect)
 {
     stateObject.Add(new JProperty("effect", effect.ToString().ToLower()));
     AddOrUpdateProperty("effect", effect.ToString().ToLower());
     return(this);
 }
Example #11
0
        public void AddStaticEffect(LightEffect effect)
        {
            StaticEffects.Add(effect);

            GenerateEffect(effect);
        }
Example #12
0
        public void AddDynamicEffect(LightEffect effect)
        {
            DynamicEffects.Add(effect);

            GenerateEffect(effect);
        }
Example #13
0
        bool WindowContainsLight(RenderTarget window, LightEffect effect)
        {
            const float DRAW_MARGIN = 20F;
            Vector2f viewTopLeft = window.GetView().Center - window.GetView().Size / 2F;
            Vector2f viewBottomRight = viewTopLeft + window.GetView().Size;

            FloatRect viewRect = new FloatRect(
                viewTopLeft.X - DRAW_MARGIN,
                viewTopLeft.Y - DRAW_MARGIN,
                viewBottomRight.X + DRAW_MARGIN,
                viewBottomRight.Y + DRAW_MARGIN);

            return !(
                effect.Right < viewRect.Left ||
                effect.Bottom < viewRect.Top ||
                effect.Left >= viewRect.Right ||
                effect.Top >= viewRect.Bottom);
        }
Example #14
0
 public void RemoveStaticEffect(LightEffect effect)
 {
     StaticEffects.Remove(effect);
 }
Example #15
0
 /// <summary>
 /// When this state is sent to the bridge, sets the current effect of the light.
 /// </summary>
 /// <returns>This LightStateBuilder instance, for method chaining.</returns>
 public LightStateBuilder Effect(LightEffect effect)
 {
     stateObject.Add(new JProperty("effect", effect.ToString().ToLower()));
     AddOrUpdateProperty("effect", effect.ToString().ToLower());
     return this;
 }
        private void LoadLightEffect(Package package, EffectsDefinition.LightEffect effectDef)
        {
            if (effectDef.VariationColors == null || effectDef.VariationColors.Count == 0)
            {
                _assetErrors.Add($"{package.packageName} - {effectDef.Name} - no color variation defined");
                return;
            }

            LightType lightType;

            try
            {
                lightType = (LightType)Enum.Parse(typeof(LightType), effectDef.Type, true);
            }
            catch
            {
                _assetErrors.Add($"{package.packageName} - {effectDef.Name} - unknown light type \"${effectDef.Type}\"");
                return;
            }

            LightEffect.BlinkType blinkType;
            try
            {
                blinkType = (LightEffect.BlinkType)Enum.Parse(typeof(LightEffect.BlinkType), effectDef.BlinkType ?? "None", true);
            }
            catch
            {
                _assetErrors.Add($"{package.packageName} - {effectDef.Name} - unknown blink type \"${effectDef.BlinkType}\"");
                return;
            }

            var effectGo = new GameObject(effectDef.Name);

            effectGo.transform.parent = _prefabCollection.transform;
            effectGo.SetActive(false);

            var light = effectGo.AddComponent <Light>();

            light.intensity = effectDef.Intensity;
            light.range     = effectDef.Range;
            light.spotAngle = effectDef.SpotAngle;
            light.color     = effectDef.VariationColors[0].ToUnityColor();
            light.type      = lightType;

            LightEffect lightEffect = effectGo.gameObject.AddComponent <LightEffect>();

            lightEffect.m_batchedLight = effectDef.BatchedLight;
            if (effectDef.BatchedLight)
            {
                effectGo.layer = RenderManager.instance.lightSystem.m_lightLayer;
            }

            lightEffect.m_fadeStartDistance = effectDef.FadeStartDistance;
            lightEffect.m_fadeEndDistance   = effectDef.FadeEndDistance;
            lightEffect.m_offRange          = new Vector2(effectDef.OffMin, effectDef.OffMax);
            lightEffect.m_spotLeaking       = effectDef.SpotLeaking;
            lightEffect.m_renderDuration    = effectDef.RenderDuration;

            lightEffect.m_blinkType     = blinkType;
            lightEffect.m_rotationSpeed = effectDef.RotationSpeed;
            lightEffect.m_rotationAxis  = new Vector3(effectDef.RotationAxisX, effectDef.RotationAxisY, effectDef.RotationAxisZ);

            if (effectDef.VariationColors.Count > 0)
            {
                lightEffect.m_variationColors = effectDef.VariationColors.Select(c => c.ToUnityColor()).ToArray();
            }

            lightEffect.InitializeEffect();

            _effects.Add(lightEffect);
        }
Example #17
0
 public void GenerateEffect(LightEffect effect)
 {
     effect.Generate(GetWalls(effect.Z));
 }