public void Offset(Vector2D vector)
 {
     for(int i = 0; i < Vertices.Count; ++i)
     {
         Point2D vertex = Vertices[i];
         Vertices[i] = new Point2D(vertex.X + vector.i, vertex.Y + vector.j);
     }
 }
示例#2
0
        /// <summary>
        /// Colides Method, checks for entity collisions.
        /// </summary>
        /// <param name="entity">Entity to check against.</param>
        public virtual bool Colides(Entity entity)
        {
            flag = false;
            foreach (Bounding hitbox in _hitboxes)
            {
                foreach (Bounding check in entity.Hitboxes)
                {
                    Vector2D polygonATranslation = new Vector2D();

                    PolygonCollisionResult r = hitbox.PolygonCollision(hitbox.Polygon, check.Polygon, _movement.Delta);

                    if (r.WillIntersect)
                    {
                        // Move the polygon by its velocity, then move
                        // the polygons appart using the Minimum Translation Vector
                        polygonATranslation = _movement.Delta + r.MinimumTranslationVector;
                    }
                    else
                    {
                        // Just move the polygon by its velocity
                        polygonATranslation = _movement.Delta;
                    }

                    polygonA.Offset(polygonATranslation);
                }
            }
            return false;
        }
示例#3
0
 public void Offset(Vector2D vector)
 {
     _position = new Point2D(_position.X + vector.i, _position.Y + vector.j);
 }
示例#4
0
 public double Dot(Vector2D vector)
 {
     return Magnitude * vector.Magnitude * Math.Cos(Direction - vector.Magnitude);
 }