/// <summary> /// Figures change direction on clash /// </summary> /// <param name="figure1">First Figure</param> /// <param name="figure2">Second Figure</param> public void FigureClash(Figure figure1, Figure figure2) { figure1.Dx = -figure1.Dx; figure1.Dy = -figure1.Dy; if (figure1.GetType() != figure2.GetType()) { figure1.FiguresClashed(figure2, new Point(Rectangle.Intersect(figure1.Model, figure2.Model).X, Rectangle.Intersect(figure1.Model, figure2.Model).Y)); } }
/// <summary> /// Clash Figure event call /// </summary> /// <param name="enemy">Second Figure</param> /// <param name="p">Clash Point</param> public void FiguresClashed(Figure enemy, Point p) { FiguresClashEventArgs e = new FiguresClashEventArgs(this, enemy, p); this.OnNewClash(e); }
/// <summary> /// Intersect with another Figure /// </summary> /// <param name="figure">Second Figure</param> /// <returns>Is this Figure intersect with parameter</returns> public bool IntersectWith(Figure figure) { bool flag = this.Model.IntersectsWith(figure.Model); return flag; }
/// <summary> /// Initializes a new instance of the <see cref="FiguresClashEventArgs"/> class. /// </summary> /// <param name="figure1">First figure</param> /// <param name="figure2">Second figure</param> /// <param name="point">Clashing point</param> public FiguresClashEventArgs(Figure figure1, Figure figure2, Point point) { this.figure1 = figure1; this.figure2 = figure2; this.clashPoint = point; }