public void CreateRectangleShadowHull(Vector2 position, Rectangle rectangle) { ShadowHull shadowHull = ShadowHull.CreateRectangle(new Vector2(rectangle.Width, rectangle.Height)); shadowHull.Position = position; Engine.Lighting.Krypton.Hulls.Add(shadowHull); }
public void CreateShadowHulls() { var hull2 = ShadowHull.CreateRectangle(new Vector2(7, 7)); hull2.Position.X = 30; hull2.Position.Y = -20; hull2.Scale.X = (float)(1); hull2.Scale.Y = (float)(1); krypton.Hulls.Add(hull2); }
/// <summary> /// Set ShadowHull of Tile /// </summary> /// <param name="Size">Size</param> /// <param name="Pos">Position</param> public void SetRectHull(Vector2 Size, Vector2 Pos) { ShadowHull H = ShadowHull.CreateRectangle(Size); H.Position = Pos; LightingEngine LE = ((LightingEngine)Renderer.GetRenderEffect("LightingEngine")); if (Hull != null) { LE.RemoveHull(Hull); } LE.AddHull(H); this._Hull = H; }
public Platform(Rectangle platformBounds, TileCollision collision, Boolean isShadowCaster, KryptonEngine krypton) { this.krypton = krypton; Collision = collision; IsShadowCaster = isShadowCaster; Bounds = platformBounds; if (isShadowCaster) { ShadowHull shadowHull = ShadowHull.CreateRectangle(new Vector2(platformBounds.Width, platformBounds.Height)); shadowHull.Position.X = platformBounds.X + platformBounds.Width / 2; shadowHull.Position.Y = platformBounds.Y + platformBounds.Height / 2; krypton.Hulls.Add(shadowHull); } }
public ShadowHull CreateHull(float radius, float angle, Vector2 position, Vector2 scale, bool circlular = false) { ShadowHull hull; if (!circlular) { hull = ShadowHull.CreateRectangle(Vector2.One); } else { hull = ShadowHull.CreateCircle(radius, 20); } hull.Position = position; hull.Scale = scale; hull.Angle = angle; hull.MaxRadius = radius; Krypton.Hulls.Add(hull); return(hull); }
private void CreateHulls(int x, int y) { float w = 50; float h = 50; // Make lines of lines of hulls! for (int j = 0; j < y; j++) { // Make lines of hulls! for (int i = 0; i < x; i++) { var posX = (((i + 0.5f) * w) / x) - w / 2 + (j % 2 == 0 ? w / x / 2 : 0); var posY = (((j + 0.5f) * h) / y) - h / 2; // +(i % 2 == 0 ? h / y / 4 : 0); var hull = ShadowHull.CreateRectangle(Vector2.One * 1f); hull.Position.X = posX; hull.Position.Y = posY; hull.Scale.X = (float)(this.mRandom.NextDouble() * 0.75f + 0.25f); hull.Scale.Y = (float)(this.mRandom.NextDouble() * 0.75f + 0.25f); krypton.Hulls.Add(hull); } } }
void rebuild( ) { _krypton.Lights.Clear( ); _krypton.Hulls.Clear( ); LayerEditor activeLayer = IoC.Model.ActiveLayer; if (activeLayer == null) { return; } activeLayer.OfType <LightEditor>( ).ForEach( light => { var props = (LightProperties)light.ItemProperties; Texture2D texture; if (props.TypeOfLight == TypeOfLight.Point) { texture = LightTextureBuilder.CreatePointLight(_game.GraphicsDevice, props.TextureSize); } else { texture = LightTextureBuilder.CreateConicLight(_game.GraphicsDevice, props.TextureSize, props.FieldOfView); } if (texture == null) { throw new InvalidOperationException(@"Cannot create light of type {0}.".FormatWith(props.TypeOfLight)); } _krypton.Lights.Add(new Light2D { Angle = props.Rotation, Color = props.Color, Intensity = props.Intensity, Fov = props.FieldOfView, Position = props.Position, IsOn = props.IsOn, Range = props.Range, ShadowType = convertShadowType(props.ShadowType), Texture = texture }); }); activeLayer.OfType <RectangularHullEditor>( ).ForEach( light => { var props = (RectangularHullProperties)light.ItemProperties; ShadowHull shadowHull = ShadowHull.CreateRectangle(new Vector2(props.Width, props.Height)); shadowHull.Angle = props.Rotation; shadowHull.Opacity = props.Opacity; shadowHull.Position = props.Position + new Vector2(props.Width / 2, props.Height / 2); shadowHull.Scale = props.Scale; shadowHull.Visible = props.Visible; _krypton.Hulls.Add(shadowHull); }); activeLayer.OfType <CircularHullEditor>( ).ForEach( light => { var props = (CircularHullProperties)light.ItemProperties; ShadowHull shadowHull = ShadowHull.CreateCircle(props.Radius, props.Sides); shadowHull.Opacity = props.Opacity; shadowHull.Position = props.Position; shadowHull.Scale = props.Scale; shadowHull.Visible = props.Visible; _krypton.Hulls.Add(shadowHull); }); activeLayer.OfType <ConvexHullEditor>( ).ForEach( light => { var props = (ConvexHullProperties)light.ItemProperties; Vector2[] worldPoints = props.WorldPoints.ToArray( ); // === DON'T SET THE POSITION!! === ShadowHull shadowHull = ShadowHull.CreateConvex(ref worldPoints); shadowHull.Opacity = props.Opacity; shadowHull.Visible = props.Visible; _krypton.Hulls.Add(shadowHull); }); activeLayer.OfType <PreShapedConvexHullEditor>( ).ForEach( light => { var props = (ConvexHullProperties)light.ItemProperties; Vector2[] worldPoints = props.WorldPoints.ToArray( ); // === DON'T SET THE POSITION!! === ShadowHull shadowHull = ShadowHull.CreateConvex(ref worldPoints); shadowHull.Opacity = props.Opacity; shadowHull.Visible = props.Visible; _krypton.Hulls.Add(shadowHull); }); }
public static ShadowHull BuildHull(float width, float height) { return(ShadowHull.CreateRectangle(new Vector2(width, height))); }