/// <summary>
        /// React to collision with a wall
        /// </summary>
        /// <param name="wall"></param>
        public void ReactToCollision(AbstractWall wall)
        {
            Vector2 closestPoint = wall.GetBody().GetClosestPointOnPerimeter(this.Gun.GetBody().GetPosition());
            Vector2 closestPointToPosition = this.Gun.GetBody().GetPosition() - closestPoint;
            closestPointToPosition.Normalize();

            if (float.IsNaN(closestPointToPosition.X))
                closestPointToPosition.X = 0f;
            if (float.IsNaN(closestPointToPosition.Y))
                closestPointToPosition.Y = 0f;

            this.Gun.GetBody().SetPosition(closestPoint + closestPointToPosition * ((CircleBody)this.Gun.GetBody()).GetRadius());
        }
Example #2
0
 /// <summary>
 /// Add wall
 /// </summary>
 public void AddWall(AbstractWall wall)
 {
     this.Walls.Add(wall);
     NodeGraph.Instance.AddNodes(Node.Construct(wall.GetBody(), (int)AppSettingsFacade.PlayerRadius, 50));
     this.ConstructNodeGraphEdges();
     NodeGraph.Instance.BuildShortestPathData();
 }