示例#1
0
 public override void Update(TimeSpan time, Vector3 position, Matrix4 transform)
 {
     if (sys == null)
     {
         return;
     }
     pos = position;
     if (equip.Animated)
     {
         timer -= time.TotalSeconds;
         if (timer < 0)
         {
             if (lt_on)
             {
                 timer     = equip.BlinkDuration;
                 colorBulb = equip.Color;
                 colorGlow = equip.GlowColor;
             }
             else
             {
                 timer     = equip.AvgDelay + rnd.NextFloat(-(equip.AvgDelay / 2f), +(equip.AvgDelay / 2f));
                 colorBulb = equip.MinColor;
                 colorGlow = equip.MinColor;
             }
             lt_on = !lt_on;
         }
     }
 }
示例#2
0
        Color4 GetPulseColor()
        {
            //TODO: Made this function playing around in GeoGebra. Probably not great
            double pulseState = Math.Abs(Math.Cos(9 * Manager.Game.TotalTime));
            var    a          = new Color3f(Manager.TextColor.R, Manager.TextColor.G, Manager.TextColor.B);
            var    b          = new Color3f(Color4.Yellow.R, Color4.Yellow.G, Color4.Yellow.B);
            var    result     = Utf.Ale.AlchemyEasing.EaseColorRGB(
                Utf.Ale.EasingTypes.Linear,
                (float)pulseState,
                0,
                1,
                a,
                b
                );

            return(new Color4(result.R, result.G, result.B, 1));
        }
        public static HSLColor FromRGB(Color3f c)
        {
            float r = c.R;
            float g = c.G;
            float b = c.B;

            float min   = Math.Min(Math.Min(r, g), b);
            float max   = Math.Max(Math.Max(r, g), b);
            float delta = max - min;

            float H = 0;
            float S = 0;
            float L = (float)((max + min) / 2.0f);

            if (delta != 0)
            {
                if (L < 0.5f)
                {
                    S = (float)(delta / (max + min));
                }
                else
                {
                    S = (float)(delta / (2.0f - max - min));
                }


                if (r == max)
                {
                    H = (g - b) / delta;
                }
                else if (g == max)
                {
                    H = 2f + (b - r) / delta;
                }
                else if (b == max)
                {
                    H = 4f + (r - g) / delta;
                }
            }

            return(new HSLColor(H, S, L));
        }
示例#4
0
 void DrawSpine(Texture2D texture, Vector3 position, Vector2 size, Color3f inner, Color3f outer, float alpha, float angle, float z)
 {
     sysr.Game.Billboards.DrawCustomShader(
         GetSpineShader(sysr.Game.Billboards),
         _setupSpineDelegate,
         new RenderUserData()
     {
         Texture = texture, Color = new Color4(inner, 1), Color2 = new Color4(outer, 1), Float = alpha
     },
         position,
         size,
         Color4.White,
         new Vector2(0, 0),
         new Vector2(0, 1),
         new Vector2(1, 0),
         new Vector2(1, 1),
         angle,
         SortLayers.SUN,
         z
         );
 }
            public bool Run(Cutscene cs, double delta)
            {
                t += delta;
                var amount = MathHelper.Clamp((float)(t / Event.Duration), 0, 1);

                if (t > Event.Duration)
                {
                    return(false);
                }
                if (FogColor != null)
                {
                    var f    = FogColor.Value;
                    var c2   = new Color3f(f.X / 255f, f.Y / 255f, f.Z / 255f);
                    var c1   = new Color3f(OrigFogColor.R, OrigFogColor.G, OrigFogColor.B);
                    var cend = Utf.Ale.AlchemyEasing.EaseColorRGB(Utf.Ale.EasingTypes.Linear, amount, 0, 1, c1, c2);
                    cs.Renderer.SystemLighting.FogColor = new Color4(cend, 1);
                }
                if (FogStart != null)
                {
                    var f = FogStart.Value;
                    cs.Renderer.SystemLighting.FogRange.X =
                        MathHelper.Lerp(OrigFogStart, f, amount);
                }
                if (FogEnd != null)
                {
                    var f = FogEnd.Value;
                    cs.Renderer.SystemLighting.FogRange.Y =
                        MathHelper.Lerp(OrigFogEnd, f, amount);
                }
                if (FogDensity != null)
                {
                    var f = FogDensity.Value;
                    cs.Renderer.SystemLighting.FogDensity =
                        MathHelper.Lerp(OrigFogDensity, f, amount);
                }

                return(true);
            }
示例#6
0
        public static Color3f EaseColorRGB(EasingTypes type, float time, float t1, float t2, Color3f c1, Color3f c2)
        {
            float r = Ease(type, time, t1, t2, c1.R, c2.R);
            float g = Ease(type, time, t1, t2, c1.G, c2.G);
            float b = Ease(type, time, t1, t2, c1.B, c2.B);

            return(new Color3f(r, g, b));
        }
示例#7
0
        public void Process(ThnEvent ev, Cutscene cs)
        {
            if (!cs.Objects.ContainsKey((string)ev.Targets[0]))
            {
                FLLog.Error("Thn", $"Entity {ev.Targets[0]} does not exist");
                return;
            }
            var obj = cs.Objects[(string)ev.Targets[0]];

            if (obj.Light == null)
            {
                FLLog.Error("Thn", $"Entity {ev.Targets[0]} is not a light");
                return;
            }

            object   tmp;
            LuaTable lightprops;

            if (ev.Properties.TryGetValue("lightprops", out tmp))
            {
                lightprops = (LuaTable)tmp;
            }
            else
            {
                FLLog.Warning("Thn", "Light prop animation with no properties");
                return;
            }

            Vector3 vtmp;
            Color3f?targetDiffuse = null;
            Color3f?targetAmbient = null;

            if (lightprops.TryGetValue("on", out tmp))
            {
                obj.Light.Active = ThnEnum.Check <bool>(tmp);
            }
            if (lightprops.TryGetVector3("diffuse", out vtmp))
            {
                targetDiffuse = new Color3f(vtmp);
                if (ev.Duration <= 0)
                {
                    obj.Light.Light.Color = new Color3f(vtmp);
                }
            }
            if (lightprops.TryGetVector3("ambient", out vtmp))
            {
                targetAmbient = new Color3f(vtmp);
                if (ev.Duration <= 0)
                {
                    obj.Light.Light.Ambient = new Color3f(vtmp);
                }
            }
            if (ev.Duration > 0)
            {
                cs.Coroutines.Add(new AnimLightProp()
                {
                    Source        = obj.Light.Light,
                    Target        = obj.Light,
                    TargetDiffuse = targetDiffuse,
                    TargetAmbient = targetAmbient,
                    Duration      = ev.Duration,
                    ParamCurve    = ev.ParamCurve
                });
            }
        }