private static IEnumerable <IEntity2D> CreateChamfer(IEntity2D geometry, IEntity2D nextGeometry, double chamferValue, out bool chamferSuccess) { var line1 = geometry as Line2D; var arc1 = geometry as Arc2D; var line2 = nextGeometry as Line2D; var arc2 = nextGeometry as Arc2D; if (line1 != null && line2 != null) { return(CreateChamfer(line1, line2, chamferValue, out chamferSuccess)); } if (line1 != null && arc2 != null) { return(CreateChamfer(line1, arc2, chamferValue, out chamferSuccess)); } if (arc1 != null && line2 != null) { return(CreateChamfer(arc1, line2, chamferValue, out chamferSuccess)); } if (arc1 != null && arc2 != null) { return(CreateChamfer(arc1, arc2, chamferValue, out chamferSuccess)); } throw new NotImplementedException(); }
public override void Collide(GameTime gameTime, Rectangle entityBounds, IEntity2D entity) { if (entity.GetType().Equals(typeof(Pong))) { ((Pong)entity).SetLastHitBy(this); } else if (entity.GetType().Equals(typeof(Wall))) { this._velocity.Y = 0; } }
private void UpdateGeometry() { _geometry = null; if (IsDefined && _prevTeoricalPnt != null && _endPnt != null) { _geometry = new Line2D { Start = new Point2D(_prevTeoricalPnt), End = new Point2D(_endPnt), PlotStyle = IsSelected ? EnumPlotStyle.SelectedElement : EnumPlotStyle.Element }; // Set Plot Style if (PlotStyle == EnumPlotStyle.Invisible) { _geometry.PlotStyle = EnumPlotStyle.Invisible; } } }
public override void Collide(GameTime gameTime, Rectangle entityBounds, IEntity2D entity) { var XProjected = this.BoundingBox; XProjected.X += (int)(this._velocity.X); var YProjected = this.BoundingBox; YProjected.Y += (int)(this._velocity.Y); //This is a proper fix if (XProjected.Intersects(entityBounds)) { this._velocity.X = this._velocity.X * -1; } else if (YProjected.Intersects(entityBounds)) { this._velocity.Y = this._velocity.Y * -1; } else { XProjected = this.BoundingBox; XProjected.X += (int)(this._velocity.X * gameTime.ElapsedGameTime.TotalSeconds); YProjected = this.BoundingBox; YProjected.Y += (int)(this._velocity.Y * gameTime.ElapsedGameTime.TotalSeconds); //This will handle edge cases if (XProjected.Intersects(entityBounds) || XProjected.Right == entityBounds.Left || XProjected.Left == entityBounds.Right) { this._velocity.X = (this._velocity.X * (-1)); } else { this._velocity.Y = (this._velocity.Y * (-1)); } } }
/// <summary> /// Will eventually be a speedup of the current N^2 solution /// </summary> /// <param name="obj"></param> /// <returns></returns> private List <IEntity2D> getNearbyObjects(IEntity2D obj) { return(entities); }
public override void Collide(GameTime gameTime, Rectangle entityBounds, IEntity2D entity) { }
/// <summary> /// Abstract method that executes when two components collide /// </summary> /// <param name="entityBounds"></param> /// <param name="entity"></param> public abstract void Collide(GameTime gameTime, Rectangle entityBounds, IEntity2D entity);