public object Load(JToken json) { var FadeList = SaveLoad.LoadList <ColorFader.ColorFade>(json["FadeList"].Value <JArray>()) as List <ColorFader.ColorFade>; //Need to create AssestConverters for these!! var obj = new ColorFader(); obj.FadeList = FadeList; SaveLoad.PostLoadIfPossible(obj); return(obj); }
/// <summary> /// Does Color Fading on the particle /// </summary> /// <param name="p"></param> /// <param name="colorFader"></param> /// <param name="fdt"></param> void doColorFade(ref Particle p, ColorFader colorFader, float fdt) { colorFader.updateColorFadeAndRate(ref p); /*p.Color.R -= (p.Color.R - colorFader.nextColor.R) * colorFader.ColorRate * fdt; * p.Color.G -= (p.Color.G- colorFader.nextColor.G) * colorFader.ColorRate * fdt; * p.Color.B -= (p.Color.B - colorFader.nextColor.B) * colorFader.ColorRate * fdt; * p.Color.A -= (p.Color.A - colorFader.nextColor.A) * colorFader.ColorRate * fdt;*/ //colorRate = colorFader.ColorRate*fdt; p.Color.R += (colorFader.nextColor.R - p.Color.R) * colorFader.ColorRate * fdt; p.Color.G += (colorFader.nextColor.G - p.Color.G) * colorFader.ColorRate * fdt; p.Color.B += (colorFader.nextColor.B - p.Color.B) * colorFader.ColorRate * fdt; p.Color.A += (colorFader.nextColor.A - p.Color.A) * colorFader.ColorRate * fdt; }
/// <summary> /// Sets up a Particle Emitter. /// Can set for particles to fade into the background with time, to fade from multiple colors, and scale with time /// </summary> /// <param name="_emitter"></param> /// <param name="_doFadeWithTime"></param> /// <param name="_colorFader"></param> /// <param name="_scaleWithTime"></param> public void setupEmitter(ParticleEmitter _emitter, ColorFader _colorFader = null, bool _scaleWithTime = false) { this.emitter = _emitter; /* Texture texture = Resources.TheResources.GetTexture("dot"); * this.RenderState = new ParticleRenderState(texture, particle_group.Particles); */ //AddComponent(this.RenderState); //XXX: Once physics is complete, get the position information from Owner's Body //Particle Controlling options //controller.fadeWithTime = _doFadeWithTime; particleGroup.colorFader = _colorFader; controller.changeColorWithTime = (_colorFader != null); if (controller.changeColorWithTime && _colorFader.FadeList[0].Color != emitter.Color && _colorFader.FadeList[0].FadeTime != 0) { particleGroup.colorFader.insertColorFader(0, 0, emitter.Color); } controller.scaleWithTime = _scaleWithTime; }