public void Init(Blending blending, int paletteIndex) { this.blending = blending; this.paletteIndex = paletteIndex; texture = null; material = null; }
public override void CleanUp() { if (OffensiveInfo.HitPauseTime > 1) { InHitPause = true; --OffensiveInfo.HitPauseTime; } else { InHitPause = false; OffensiveInfo.HitPauseTime = 0; } if (InHitPause == false) { base.CleanUp(); Transparency = new Blending(); CameraFollowX = true; CameraFollowY = true; ScreenBound = true; PositionFreeze = false; Assertions.Reset(); Dimensions.ClearOverride(); DrawOffset = Vector2.Zero; PushFlag = false; DrawScale = Vector2.One; m_updatedanimation = false; DoFriction(); } }
// Use this for initialization void Start() { offX = Random.Range(0f, 999f); offY = Random.Range(0f, 999f); Terrain terrain = GetComponent <Terrain>();//getting the terrain //terrain.terrainData = generateTerrain(terrain.terrainData); Blending blender = new Blending(); //init blender Texture2D grass = Resources.Load("greenLawn") as Texture2D; //1 Texture2D wood = Resources.Load("Holz-34") as Texture2D; //2 Texture2D mud = Resources.Load("mud02") as Texture2D; //3 Texture2D stone = Resources.Load("rock8") as Texture2D; //4 Color[,] colorArray = blender.generateBlend(grass, wood, mud, stone, terrain.terrainData, width, height); //use this colorArray to calculate a texture and apply it to the terrain Texture2D image = new Texture2D(width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { image.SetPixel(x, y, colorArray[x, y]); } } //save pic var Bytes = image.EncodeToPNG(); File.WriteAllBytes(Application.dataPath + "/Resources/TerrainColorMap.png", Bytes); }
public void OnDestroy() { //generate and safe terrain and colormaps for the next run Terrain terrain = this.GetComponent <Terrain>(); data = terrain.terrainData; data.heightmapResolution = width; data.size = new Vector3(width, height, depth); terrain.terrainData = GenerateTerrain(terrain.terrainData); Blending blender = new Blending(); //init blender Texture2D grass = Resources.Load("gras15") as Texture2D; //1 Texture2D wood = Resources.Load("Holz-34") as Texture2D; //2 Texture2D mud = Resources.Load("mud02") as Texture2D; //3 Texture2D stone = Resources.Load("rock8") as Texture2D; //4 Color[,] colorArray = blender.generateBlend(grass, wood, mud, stone, terrain.terrainData, width, height); //use this colorArray to calculate a texture and apply it to the terrain Texture2D image = new Texture2D(width, height); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { image.SetPixel(x, y, colorArray[x, y]); } } //save pic var Bytes = image.EncodeToPNG(); File.WriteAllBytes(Application.dataPath + "/Resources/TerrainColorMap.png", Bytes); }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="id">The index of this element in the Animation.</param> /// <param name="clsns">The collection of collision boxes in this elements.</param> /// <param name="ticks">The time, in gameticks, that this element is drawn.</param> /// <param name="spriteid">The Sprite that is drawn for this element. SpriteId.Invalid for nothing to be drawn.</param> /// <param name="offset">The offset, in pixels, used to draw this element.</param> /// <param name="flip">The drawing orientation of this element.</param> /// <param name="blending">Alpha blending to be used while drawing this element.</param> public AnimationElement(Int32 id, List <Clsn> clsns, Int32 ticks, Int32 starttick, SpriteId spriteid, Point offset, SpriteEffects flip, Blending blending) { if (id < 0) { throw new ArgumentOutOfRangeException("id"); } if (clsns == null) { throw new ArgumentNullException("clsns"); } if (ticks < -1) { throw new ArgumentOutOfRangeException("ticks"); } if (starttick < 0) { throw new ArgumentOutOfRangeException("starttick"); } if (blending == null) { throw new ArgumentNullException("blending"); } m_id = id; m_clsns = clsns; m_gameticks = ticks; m_spriteid = spriteid; m_offset = (Vector2)offset; m_flip = flip; m_blending = blending; m_starttick = starttick; }
void SetBlending(Blending blending) { RenderState r = Device.RenderState; switch (blending.BlendType) { case BlendType.Add: GetShaderParameter("xBlendWeight").SetValue((Single)blending.SourceFactor / 255.0f); r.AlphaBlendEnable = true; r.BlendFunction = BlendFunction.Add; r.SourceBlend = Blend.SourceAlpha; r.DestinationBlend = Blend.BlendFactor; r.BlendFactor = new Color(blending.DestinationFactor, blending.DestinationFactor, blending.DestinationFactor, 255); break; case BlendType.Subtract: GetShaderParameter("xBlendWeight").SetValue((Single)blending.SourceFactor / 255.0f); r.AlphaBlendEnable = true; r.BlendFunction = BlendFunction.ReverseSubtract; r.SourceBlend = Blend.SourceAlpha; r.DestinationBlend = Blend.BlendFactor; r.BlendFactor = new Color(blending.DestinationFactor, blending.DestinationFactor, blending.DestinationFactor, 255); break; default: case BlendType.None: GetShaderParameter("xBlendWeight").SetValue(1.0f); r.AlphaBlendEnable = false; break; } }
public void Init(Blending blending, ShaderId shader, int[] gradientMapIndices) { this.blending = blending; this.shader = shader; this.gradientMapIndices = gradientMapIndices; material = null; }
public DistortionMaterial(Blending blending) { Blending = blending; shaderParams = new ShaderParams(); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; amountKey = shaderParams.GetParamKey <Vector4>("uAmount"); }
public void Init(Blending blending, ShaderId shader) { this.blending = blending; this.shader = shader; texture = null; material = null; }
int GetHotStudioBlending(Blending blending, ShaderId shader) { if (blending == Blending.Inherited && shader == ShaderId.Inherited) { return(0); } if (shader == ShaderId.Diffuse) { switch (blending) { case Blending.Add: return(2); case Blending.Burn: return(3); case Blending.Modulate: return(5); case Blending.Opaque: return(8); } } if (shader == ShaderId.Silhuette) { switch (blending) { case Blending.Alpha: return(7); default: throw new InvalidOperationException("Can't use Silhuette shader with blending other than Alpha"); } } return(1); }
protected void drawInGameObjects(float maxdepth, int firstX, int firstY, int offsetX, int offsetY) { foreach (InGameObject obj in InGameObjects()) { if (!obj.Visible) { continue; } Rectangle sourceRectangle = obj.SourceRectangle; Rectangle destinationRectangle = obj.MakeDestinationRectangle(firstX, firstY, offsetX, offsetY); Rectangle objBox = obj.InWorldSquareBoundingBox; float depth = calculateDepthOffset(maxdepth, objBox.Right - firstX - 1, objBox.Top - firstY); depth -= heightRowDepthMod; //since it's above the ground, level with the first level of walls spriteBatch.Draw( obj.Texture, destinationRectangle, sourceRectangle, Blending.MultiplyBlend(obj.Tint, CellTint(obj.SquareCoordinate)), 0f, //no rotation Vector2.Zero, //don't use origin SpriteEffects.None, depth); } }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual bool Equals(Material other) { if (other == null) { return(false); } return(AlphaTest.Equals(other.AlphaTest) && Blending.Equals(other.Blending) && ClipIntersections.Equals(other.ClipIntersections) && ClipShadows.Equals(other.ClipShadows) && ColorWrite.Equals(other.ColorWrite) && DepthTest.Equals(other.DepthTest) && DepthWrite.Equals(other.DepthWrite) && Dithering.Equals(other.Dithering) && FlatShading.Equals(other.FlatShading) && Fog.Equals(other.Fog) && Lights.Equals(other.Lights) && Opacity.Equals(other.Opacity) && Overdraw.Equals(other.Overdraw) && PremultipliedAlpha.Equals(other.PremultipliedAlpha) && Side.Equals(other.Side) && Transparent.Equals(other.Transparent) && VertexColors.Equals(other.VertexColors) && Visible.Equals(other.Visible) && UserData == other.UserData && ClippingPlanes == other.ClippingPlanes && string.Equals(Precision, other.Precision)); }
private void SetBlending(Blending blending) { switch (blending.BlendType) { case BlendType.Add: GetShaderParameter("xBlendWeight").SetValue(blending.SourceFactor / 255.0f); Device.BlendState = BlendState.Additive; break; case BlendType.Subtract: GetShaderParameter("xBlendWeight").SetValue(blending.SourceFactor / 255.0f); Device.BlendState = new BlendState { ColorSourceBlend = Blend.One, ColorDestinationBlend = Blend.One, ColorBlendFunction = BlendFunction.ReverseSubtract, AlphaSourceBlend = Blend.One, AlphaDestinationBlend = Blend.One, AlphaBlendFunction = BlendFunction.ReverseSubtract }; break; default: GetShaderParameter("xBlendWeight").SetValue(1.0f); Device.BlendState = BlendState.NonPremultiplied; break; } }
public void Apply(int pass) { shaderParams.Set(amountKey, new Vector4(ChromaticAberration * Red, ChromaticAberration * Green, ChromaticAberration * Blue, BarrelPincushion)); PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState); PlatformRenderer.SetShaderProgram(DistortionShaderProgram.GetInstance(Opaque)); PlatformRenderer.SetShaderParams(shaderParamsArray); }
public SharpenMaterial(Blending blending) { Blending = blending; shaderParams = new ShaderParams(); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; stepKey = shaderParams.GetParamKey <Vector2>("step"); sharpnessKey = shaderParams.GetParamKey <Vector3>("uSharpness"); }
public void Apply(int pass) { shaderParams.Set(stepKey, Step); shaderParams.Set(sharpnessKey, new Vector3(Strength, Strength * 0.25f, Limit)); PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState); PlatformRenderer.SetShaderProgram(SharpenShaderProgram.GetInstance(Opaque)); PlatformRenderer.SetShaderParams(shaderParamsArray); }
public void Apply(int pass) { shaderParams.Set(texelStepKey, TexelStep); shaderParams.Set(amountKey, new Vector4(LumaTreshold, 0.25f / MulReduce, 1f / MinReduce, MaxSpan)); PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState); PlatformRenderer.SetShaderProgram(FXAAShaderProgram.GetInstance(Opaque)); PlatformRenderer.SetShaderParams(shaderParamsArray); }
public void Apply(int pass) { shaderParams.Set(stepKey, Dir * Radius * Step); shaderParams.Set(alphaCorrectionKey, 1f / AlphaCorrection); PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState); PlatformRenderer.SetShaderProgram(BlurShaderProgram.GetInstance(BlurShaderId, Opaque)); PlatformRenderer.SetShaderParams(shaderParamsArray); }
private WidgetMaterial(Blending blending, ShaderId shader, int numTextures, bool premulAlpha) { PremulAlpha = premulAlpha || blending == Blending.Burn || blending == Blending.Darken; ShaderProgram = ShaderPrograms.Instance.GetShaderProgram(shader, numTextures, PremulAlpha ? ShaderOptions.PremultiplyAlpha : ShaderOptions.None); Blending = blending; PassCount = Blending == Blending.Glow || Blending == Blending.Darken ? 2 : 1; }
private ColorfulTextMaterial(Blending blending, int styleIndex) { colorIndex = ShaderPrograms.ColorfulTextShaderProgram.StyleIndexToColorIndex(styleIndex); blendState = blending.GetBlendState(); shaderParams = new ShaderParams(); shaderParams.Set(shaderParams.GetParamKey <float>("colorIndex"), colorIndex); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; }
public BlurMaterial(Blending blending) { Blending = blending; shaderParams = new ShaderParams(); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; stepKey = shaderParams.GetParamKey <Vector2>("step"); alphaCorrectionKey = shaderParams.GetParamKey <float>("inversedAlphaCorrection"); }
public FXAAMaterial(Blending blending) { Blending = blending; shaderParams = new ShaderParams(); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; texelStepKey = shaderParams.GetParamKey <Vector2>("uTexelStep"); amountKey = shaderParams.GetParamKey <Vector4>("uAmount"); }
public static void SetBlending(Blending value, bool premultipliedAlpha = false) { if (value == blending && premultipliedAlphaMode == premultipliedAlpha) { return; } premultipliedAlphaMode = premultipliedAlpha; blending = value; switch (blending) { case Blending.Inherited: case Blending.Alpha: if (premultipliedAlphaMode) { GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); } else { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } break; case Blending.LcdTextFirstPass: GL.BlendFunc(BlendingFactorSrc.Zero, BlendingFactorDest.OneMinusSrcColor); break; case Blending.LcdTextSecondPass: GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One); break; case Blending.Add: case Blending.Glow: if (premultipliedAlphaMode) { GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); } else { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One); } break; case Blending.Burn: case Blending.Darken: GL.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.OneMinusSrcAlpha); break; case Blending.Modulate: GL.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.Zero); break; case Blending.Opaque: GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.Zero); break; } CheckErrors(); }
public SDFShadowMaterial(Blending blending) { Blending = blending; shaderParams = new ShaderParams(); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; dilateKey = shaderParams.GetParamKey <float>("dilate"); softnessKey = shaderParams.GetParamKey <float>("softness"); colorKey = shaderParams.GetParamKey <Vector4>("color"); }
public void Apply(int pass) { shaderParams.Set(dilateKey, 0.5f - Dilate * 0.01f); shaderParams.Set(softnessKey, Mathf.Max(Softness * 0.01f, 0.001f)); shaderParams.Set(colorKey, Color.ToVector4()); PlatformRenderer.SetBlendState(Blending.GetBlendState()); PlatformRenderer.SetShaderProgram(SDFShadowShaderProgram.GetInstance()); PlatformRenderer.SetShaderParams(shaderParamsArray); }
public WidgetMaterial(Blending blending, ShaderProgram shaderProgram, ITexture texture1, ITexture texture2, bool premulAlpha) { ShaderProgram = shaderProgram; Blending = blending; PassCount = Blending == Blending.Glow || Blending == Blending.Darken ? 2 : 1; Texture1 = texture1; Texture2 = texture2; PremulAlpha = premulAlpha; }
public ColorCorrectionMaterial(Blending blending) { Blending = blending; shaderParams = new ShaderParams(); shaderParamsArray = new[] { Renderer.GlobalShaderParams, shaderParams }; hslKey = shaderParams.GetParamKey <Vector3>("inHsl"); brightnessKey = shaderParams.GetParamKey <float>("brightness"); contrastKey = shaderParams.GetParamKey <float>("contrast"); }
public static BlendState GetBlendState(this Blending blending, bool alphaPremul = false) { var bs = BlendState.Default; switch (blending) { case Blending.Opaque: bs.SrcBlend = Blend.One; bs.DstBlend = Blend.Zero; break; case Blending.PremultipliedAlpha: bs.SrcBlend = Blend.One; bs.DstBlend = Blend.InverseSrcAlpha; break; case Blending.None: case Blending.Inherited: case Blending.Alpha: bs.SrcBlend = alphaPremul ? Blend.One : Blend.SrcAlpha; bs.DstBlend = Blend.InverseSrcAlpha; break; case Blending.LcdTextFirstPass: bs.SrcBlend = Blend.Zero; bs.DstBlend = Blend.InverseSrcColor; break; case Blending.LcdTextSecondPass: bs.SrcBlend = Blend.SrcAlpha; bs.DstBlend = Blend.One; break; case Blending.Add: case Blending.Glow: bs.SrcBlend = alphaPremul ? Blend.One : Blend.SrcAlpha; bs.DstBlend = Blend.One; break; case Blending.Burn: case Blending.Darken: bs.SrcBlend = Blend.DstColor; bs.DstBlend = Blend.InverseSrcAlpha; break; case Blending.Modulate: bs.SrcBlend = Blend.DstColor; bs.DstBlend = Blend.Zero; break; } if (PlatformRenderer.OffscreenRendering) { bs.AlphaSrcBlend = Blend.InverseDstAlpha; bs.AlphaDstBlend = Blend.One; } return(bs); }
public void Apply(int pass) { shaderParams.Set(hslKey, HSL); shaderParams.Set(brightnessKey, Brightness); shaderParams.Set(contrastKey, Contrast); PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState); PlatformRenderer.SetShaderProgram(ColorCorrectionShaderProgram.GetInstance(RequiredBrightnessContrastProcess, RequiredHSLProcess, Opaque)); PlatformRenderer.SetShaderParams(shaderParamsArray); }
public static WidgetMaterial GetInstance(Blending blending, ShaderId shader, ShaderProgram customShader = null, ITexture texture1 = null, ITexture texture2 = null, bool premulAlpha = false) { premulAlpha |= (blending == Blending.Burn || blending == Blending.Darken); var shaderProgram = shader == ShaderId.Custom ? customShader : ShaderPrograms.Instance.GetShaderProgram(shader, texture1, texture2, premulAlpha ? ShaderOptions.PremultiplyAlpha : ShaderOptions.None); return(GetInstance(blending, shaderProgram, texture1, texture2, premulAlpha)); }
protected Entity(FightEngine engine) : base(engine) { m_draworder = 0; m_location = new Vector2(0, 0); m_velocity = new Vector2(0, 0); m_acceleration = new Vector2(0, 0); m_facing = Facing.Right; m_flip = SpriteEffects.None; m_scale = new Vector2(1, 1); m_blending = new Blending(); m_afterimages = new AfterImage(this); m_drawingangle = 0; }
public virtual void Reset() { m_draworder = 0; m_location = new Vector2(0, 0); m_velocity = new Vector2(0, 0); m_acceleration = new Vector2(0, 0); m_facing = Facing.Right; m_flip = SpriteEffects.None; m_scale = new Vector2(1, 1); m_blending = new Blending(); m_drawingangle = 0; m_angledraw = false; m_afterimages.Reset(); }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="id">The index of this element in the Animation.</param> /// <param name="clsns">The collection of collision boxes in this elements.</param> /// <param name="ticks">The time, in gameticks, that this element is drawn.</param> /// <param name="spriteid">The Sprite that is drawn for this element. SpriteId.Invalid for nothing to be drawn.</param> /// <param name="offset">The offset, in pixels, used to draw this element.</param> /// <param name="flip">The drawing orientation of this element.</param> /// <param name="blending">Alpha blending to be used while drawing this element.</param> public AnimationElement(Int32 id, List<Clsn> clsns, Int32 ticks, Int32 starttick, SpriteId spriteid, Point offset, SpriteEffects flip, Blending blending) { if (id < 0) throw new ArgumentOutOfRangeException("id"); if (clsns == null) throw new ArgumentNullException("clsns"); if (ticks < -1) throw new ArgumentOutOfRangeException("ticks"); if (starttick < 0) throw new ArgumentOutOfRangeException("starttick"); if (blending == null) throw new ArgumentNullException("blending"); m_id = id; m_clsns = clsns; m_gameticks = ticks; m_spriteid = spriteid; m_offset = (Vector2)offset; m_flip = flip; m_blending = blending; m_starttick = starttick; }
public DrawState(VideoSystem videosystem) { if (videosystem == null) throw new ArgumentNullException("videosystem"); m_videosystem = videosystem; m_mode = DrawMode.Normal; m_pixels = null; m_palette = null; m_scissorrect = Rectangle.Empty; m_blending = new Blending(); m_drawdata = new List<DrawData>(); m_scale = Vector2.One; m_axis = Vector2.Zero; m_flip = SpriteEffects.None; m_rotation = 0; m_offset = Vector2.Zero; m_stretch = Vector2.One; m_parameters = new ShaderParameters(); }
private void ApplyBlending(Blending blending) { if (_renderState.Blending.Enabled != blending.Enabled) { Enable(EnableCap.Blend, blending.Enabled); _renderState.Blending.Enabled = blending.Enabled; } if (blending.Enabled) { if ((_renderState.Blending.SourceRGBFactor != blending.SourceRGBFactor) || (_renderState.Blending.DestinationRGBFactor != blending.DestinationRGBFactor) || (_renderState.Blending.SourceAlphaFactor != blending.SourceAlphaFactor) || (_renderState.Blending.DestinationAlphaFactor != blending.DestinationAlphaFactor)) { GL.BlendFuncSeparate( TypeConverterGL3x.To(blending.SourceRGBFactor), TypeConverterGL3x.To(blending.DestinationRGBFactor), TypeConverterGL3x.To(blending.SourceAlphaFactor), TypeConverterGL3x.To(blending.DestinationAlphaFactor)); _renderState.Blending.SourceRGBFactor = blending.SourceRGBFactor; _renderState.Blending.DestinationRGBFactor = blending.DestinationRGBFactor; _renderState.Blending.SourceAlphaFactor = blending.SourceAlphaFactor; _renderState.Blending.DestinationAlphaFactor = blending.DestinationAlphaFactor; } if ((_renderState.Blending.RGBEquation != blending.RGBEquation) || (_renderState.Blending.AlphaEquation != blending.AlphaEquation)) { GL.BlendEquationSeparate( TypeConverterGL3x.To(blending.RGBEquation), TypeConverterGL3x.To(blending.AlphaEquation)); _renderState.Blending.RGBEquation = blending.RGBEquation; _renderState.Blending.AlphaEquation = blending.AlphaEquation; } if (_renderState.Blending.Color != blending.Color) { GL.BlendColor(blending.Color); _renderState.Blending.Color = blending.Color; } } }
public override void Run(Combat.Character character) { Int32 time = EvaluationHelper.AsInt32(character, Time, 1); Int32 numberofframes = EvaluationHelper.AsInt32(character, NumberOfFrames, 20); Int32 basecolor = EvaluationHelper.AsInt32(character, PaletteColor, 255); Boolean invert = EvaluationHelper.AsBoolean(character, PaletteColorInversion, false); Vector3 palpreadd = EvaluationHelper.AsVector3(character, PaletteColorBrightness, new Vector3(30, 30, 30)); Vector3 palcontrast = EvaluationHelper.AsVector3(character, PaletteColorContrast, new Vector3(255, 255, 255)); Vector3 palpostadd = EvaluationHelper.AsVector3(character, PalettePostBrightness, new Vector3(0, 0, 0)); Vector3 paladd = EvaluationHelper.AsVector3(character, PaletteColorAdd, new Vector3(10, 10, 25)); Vector3 palmul = EvaluationHelper.AsVector3(character, PaletteColorMultiply, new Vector3(.65f, .65f, .75f)); Int32 timegap = EvaluationHelper.AsInt32(character, TimeGap, 1); Int32 framegap = EvaluationHelper.AsInt32(character, FrameGap, 4); Point alpha = EvaluationHelper.AsPoint(character, Alpha, new Point(255, 0)); Blending? trans = Transparency; if (trans != null && trans.Value.BlendType == BlendType.Add && trans.Value.SourceFactor == 0 && trans.Value.DestinationFactor == 0) trans = new Blending(BlendType.Add, alpha.X, alpha.Y); Combat.AfterImage afterimages = character.AfterImages; afterimages.Reset(); afterimages.DisplayTime = time; afterimages.NumberOfFrames = numberofframes; afterimages.BaseColor = basecolor / 255.0f; afterimages.InvertColor = invert; afterimages.ColorPreAdd = Vector3.Clamp(palpreadd / 255.0f, Vector3.Zero, Vector3.One); afterimages.ColorContrast = Vector3.Clamp(palcontrast / 255.0f, Vector3.Zero, new Vector3(Single.MaxValue)); afterimages.ColorPostAdd = Vector3.Clamp(palpostadd / 255.0f, Vector3.Zero, Vector3.One); afterimages.ColorPaletteAdd = Vector3.Clamp(paladd / 255.0f, Vector3.Zero, Vector3.One); afterimages.ColorPaletteMultiply = Vector3.Clamp(palmul, Vector3.Zero, new Vector3(Single.MaxValue)); afterimages.TimeGap = timegap; afterimages.FrameGap = framegap; afterimages.Transparency = trans; afterimages.IsActive = true; }
public Explod(StateSystem statesystem, String label, TextSection textsection) : base(statesystem, label, textsection) { m_animationnumber = textsection.GetAttribute<Evaluation.PrefixedExpression>("anim", null); m_id = textsection.GetAttribute<Evaluation.Expression>("id", null); m_position = textsection.GetAttribute<Evaluation.Expression>("pos", null); m_postype = textsection.GetAttribute<PositionType>("postype", PositionType.P1); m_facing = textsection.GetAttribute<Evaluation.Expression>("facing", null); m_verticalfacing = textsection.GetAttribute<Evaluation.Expression>("vfacing", null); m_bindtime = textsection.GetAttribute<Evaluation.Expression>("BindTime", null); Evaluation.Expression exp_vel = textsection.GetAttribute<Evaluation.Expression>("vel", null); Evaluation.Expression exp_velocity = textsection.GetAttribute<Evaluation.Expression>("velocity", null); m_velocity = exp_vel ?? exp_velocity; m_acceleration = textsection.GetAttribute<Evaluation.Expression>("accel", null); m_randomdisplacement = textsection.GetAttribute<Evaluation.Expression>("random", null); m_removetime = textsection.GetAttribute<Evaluation.Expression>("removetime", null); m_supermove = textsection.GetAttribute<Evaluation.Expression>("supermove", null); m_supermovetime = textsection.GetAttribute<Evaluation.Expression>("supermovetime", null); m_pausemovetime = textsection.GetAttribute<Evaluation.Expression>("pausemovetime", null); m_scale = textsection.GetAttribute<Evaluation.Expression>("scale", null); m_spritepriority = textsection.GetAttribute<Evaluation.Expression>("sprpriority", null); m_drawontop = textsection.GetAttribute<Evaluation.Expression>("ontop", null); m_shadow = textsection.GetAttribute<Evaluation.Expression>("shadow", null); m_ownpalette = textsection.GetAttribute<Evaluation.Expression>("ownpal", null); m_removeongethit = textsection.GetAttribute<Evaluation.Expression>("removeongethit", null); m_explodignorehitpause = textsection.GetAttribute<Evaluation.Expression>("ignorehitpause", null); m_blending = textsection.GetAttribute<Blending>("trans", new Blending()); m_alpha = textsection.GetAttribute<Evaluation.Expression>("alpha", null); }
Combat.ExplodData CreateExplodData(Combat.Character character) { if (character == null) throw new ArgumentNullException("character"); Int32? animationnumber = EvaluationHelper.AsInt32(character, AnimationNumber, null); Int32 id = EvaluationHelper.AsInt32(character, Id, -1); Point location = EvaluationHelper.AsPoint(character, Position, new Point(0, 0)); Int32 horizfacing = EvaluationHelper.AsInt32(character, Facing, 1); Int32 vertfacing = EvaluationHelper.AsInt32(character, VerticalFacing, 1); Int32 bindtime = EvaluationHelper.AsInt32(character, BindTime, 0); Vector2 velocity = EvaluationHelper.AsVector2(character, Velocity, new Vector2(0, 0)); Vector2 acceleration = EvaluationHelper.AsVector2(character, Acceleration, new Vector2(0, 0)); Point randomdisplacement = EvaluationHelper.AsPoint(character, RandomDisplacement, new Point(0, 0)); Int32 removetime = EvaluationHelper.AsInt32(character, RemoveTime, -2); Boolean supermove = EvaluationHelper.AsBoolean(character, Supermove, false); Int32 supermovetime = EvaluationHelper.AsInt32(character, SupermoveTime, 0); Int32 pausetime = EvaluationHelper.AsInt32(character, PauseMoveTime, 0); Vector2 scale = EvaluationHelper.AsVector2(character, Scale, new Vector2(1, 1)); Int32 spritepriority = EvaluationHelper.AsInt32(character, SpritePriority, 0); Boolean ontop = EvaluationHelper.AsBoolean(character, DrawOnTop, false); Boolean ownpalette = EvaluationHelper.AsBoolean(character, OwnPalette, false); Boolean removeongethit = EvaluationHelper.AsBoolean(character, RemoveOnGetHit, false); Boolean ignorehitpause = EvaluationHelper.AsBoolean(character, ExplodIgnoreHitPause, true); Point? alpha = EvaluationHelper.AsPoint(character, Alpha, null); if (animationnumber == null) return null; SpriteEffects flip = SpriteEffects.None; if (horizfacing == -1) flip ^= SpriteEffects.FlipHorizontally; if (vertfacing == -1) flip ^= SpriteEffects.FlipVertically; Blending transparency = Transparency; if (transparency.BlendType == BlendType.Add && transparency.SourceFactor == 0 && transparency.DestinationFactor == 0) { if (alpha != null) { transparency = new Blending(BlendType.Add, alpha.Value.X, alpha.Value.Y); } else { transparency = new Blending(); } } Combat.ExplodData data = new Combat.ExplodData(); data.CommonAnimation = EvaluationHelper.IsCommon(AnimationNumber, false); data.AnimationNumber = animationnumber.Value; data.Id = id; data.RemoveTime = removetime; data.Location = (Vector2)location; data.PositionType = PositionType; data.Velocity = velocity; data.Acceleration = acceleration; data.Flip = flip; data.BindTime = bindtime; data.Random = randomdisplacement; data.SuperMove = supermove; data.SuperMoveTime = supermovetime; data.PauseTime = pausetime; data.Scale = scale; data.SpritePriority = spritepriority; data.DrawOnTop = ontop; data.OwnPalFx = ownpalette; data.RemoveOnGetHit = removeongethit; data.IgnoreHitPause = ignorehitpause; data.Transparency = transparency; return data; }
public Projectile(StateSystem statesystem, String label, TextSection textsection) : base(statesystem, label, textsection) { m_priority = textsection.GetAttribute<Evaluation.Expression>("value", null); m_priority = textsection.GetAttribute<Evaluation.Expression>("value", null); m_projectileid = textsection.GetAttribute<Evaluation.Expression>("ProjID", null); m_animation = textsection.GetAttribute<Evaluation.Expression>("projanim", null); m_hitanimation = textsection.GetAttribute<Evaluation.Expression>("projhitanim", null); m_removeanimation = textsection.GetAttribute<Evaluation.Expression>("projremanim", null); m_cancelanimation = textsection.GetAttribute<Evaluation.Expression>("projcancelanim", null); m_scale = textsection.GetAttribute<Evaluation.Expression>("projscale", null); m_removeonhit = textsection.GetAttribute<Evaluation.Expression>("projremove", null); m_removetime = textsection.GetAttribute<Evaluation.Expression>("projremovetime", null); m_velocity = textsection.GetAttribute<Evaluation.Expression>("velocity", null); m_removevelocity = textsection.GetAttribute<Evaluation.Expression>("remvelocity", null); m_acceleration = textsection.GetAttribute<Evaluation.Expression>("accel", null); m_velocitymultiplier = textsection.GetAttribute<Evaluation.Expression>("velmul", null); m_hits = textsection.GetAttribute<Evaluation.Expression>("projhits", null); m_misstime = textsection.GetAttribute<Evaluation.Expression>("projmisstime", null); m_priority = textsection.GetAttribute<Evaluation.Expression>("projpriority", null); m_spritepriority = textsection.GetAttribute<Evaluation.Expression>("projsprpriority", null); m_edgebound = textsection.GetAttribute<Evaluation.Expression>("projedgebound", null); m_stagebound = textsection.GetAttribute<Evaluation.Expression>("projstagebound", null); m_heightbound = textsection.GetAttribute<Evaluation.Expression>("projheightbound", null); m_offset = textsection.GetAttribute<Evaluation.Expression>("offset", null); m_postype = textsection.GetAttribute<PositionType>("postype", PositionType.P1); m_shadow = textsection.GetAttribute<Evaluation.Expression>("projshadow", null); m_supermovetime = textsection.GetAttribute<Evaluation.Expression>("supermovetime", null); m_pausetime = textsection.GetAttribute<Evaluation.Expression>("pausemovetime", null); m_afterimagetime = textsection.GetAttribute<Evaluation.Expression>("afterimage.Time", null); m_afterimageframes = textsection.GetAttribute<Evaluation.Expression>("afterimage.length", null); m_afterimagecolor = textsection.GetAttribute<Evaluation.Expression>("afterimage.palcolor", null); m_afterimageinversion = textsection.GetAttribute<Evaluation.Expression>("afterimage.palinvertall", null); m_afterimageprebrightness = textsection.GetAttribute<Evaluation.Expression>("afterimage.palbright", null); m_afterimagecontrast = textsection.GetAttribute<Evaluation.Expression>("afterimage.palcontrast", null); m_afterimagepostbrightness = textsection.GetAttribute<Evaluation.Expression>("afterimage.palpostbright", null); m_afterimagecoloradd = textsection.GetAttribute<Evaluation.Expression>("afterimage.paladd", null); m_afterimagecolormul = textsection.GetAttribute<Evaluation.Expression>("afterimage.palmul", null); m_afterimagetimegap = textsection.GetAttribute<Evaluation.Expression>("afterimage.TimeGap", null); m_afterimageframegap = textsection.GetAttribute<Evaluation.Expression>("afterimage.FrameGap", null); m_afterimageblending = textsection.GetAttribute<Blending>("afterimage.trans", new Blending()); }
/// <summary> /// Creates a new AnimationElement initialized from a line of text. /// </summary> /// <param name="line"></param> /// <param name="elementid"></param> /// <param name="default_clsn"></param> /// <param name="loading_clsn"></param> /// <returns></returns> AnimationElement CreateElement(String line, Int32 elementid, Int32 starttick, List<Clsn> default_type1, List<Clsn> default_type2, List<Clsn> loading_type1, List<Clsn> loading_type2) { if (line == null) throw new ArgumentNullException("line"); if (elementid < 0) throw new ArgumentOutOfRangeException("elementid"); if (starttick < 0) throw new ArgumentOutOfRangeException("starttick"); if (default_type1 == null) throw new ArgumentNullException("default_type1"); if (default_type2 == null) throw new ArgumentNullException("default_type2"); if (loading_type1 == null) throw new ArgumentNullException("loading_type1"); if (loading_type2 == null) throw new ArgumentNullException("loading_type2"); String[] elements = m_elementregex.Split(line); if (elements == null) return null; Int32 groupnumber; if (Int32.TryParse(elements[0], out groupnumber) == false) return null; Int32 imagenumber; if (Int32.TryParse(elements[1], out imagenumber) == false) return null; Int32 offset_x; if (Int32.TryParse(elements[2], out offset_x) == false) return null; Int32 offset_y; if (Int32.TryParse(elements[3], out offset_y) == false) return null; Int32 gameticks; if (Int32.TryParse(elements[4], out gameticks) == false) return null; SpriteEffects flip = SpriteEffects.None; if (elements.Length >= 6) { if (elements[5].IndexOf('H') != -1 || elements[5].IndexOf('h') != -1) flip |= SpriteEffects.FlipHorizontally; if (elements[5].IndexOf('V') != -1 || elements[5].IndexOf('v') != -1) flip |= SpriteEffects.FlipVertically; } Blending blending = new Blending(); if (elements.Length >= 7) { blending = m_animationsystem.GetSubSystem<StringConverter>().Convert<Blending>(elements[6]); } List<Clsn> clsn = new List<Clsn>(); clsn.AddRange(loading_type1.Count != 0 ? loading_type1 : default_type1); clsn.AddRange(loading_type2.Count != 0 ? loading_type2 : default_type2); AnimationElement element = new AnimationElement(elementid, clsn, gameticks, starttick, new SpriteId(groupnumber, imagenumber), new Point(offset_x, offset_y), flip, blending); return element; }
public Trans(StateSystem statesystem, String label, TextSection textsection) : base(statesystem, label, textsection) { m_blending = textsection.GetAttribute<Blending>("trans", new Blending()); m_alpha = textsection.GetAttribute<Evaluation.Expression>("alpha", null); }
public void Reset() { m_mode = DrawMode.Normal; m_pixels = null; m_palette = null; m_scissorrect = Rectangle.Empty; m_blending = new Blending(); m_drawdata.Clear(); m_scale = Vector2.One; m_axis = Vector2.Zero; m_flip = SpriteEffects.None; m_rotation = 0; m_offset = Vector2.Zero; m_stretch = Vector2.One; m_parameters.Reset(); }