示例#1
0
        public static void mp_grid_set_instance(GameObject go, bool empty = false)
        {
            // rasterize entire shit based on bounding box
            if (Math.Abs(go.ImageAngle) < .5f)
            {
                Microsoft.Xna.Framework.Rectangle r = go.CollisionContainer;
                int relativeX = (int)go.X - pathfindingGrid.X;
                int relativeY = (int)go.Y - pathfindingGrid.Y;

                mp_grid_set_rectangle(relativeX / pathfindingGrid.CellSizeX, relativeY / pathfindingGrid.CellSizeY, (int)ceil(r.Width / (float)pathfindingGrid.CellSizeX), (int)ceil(r.Height / (float)pathfindingGrid.CellSizeY), empty);
            }
            else
            {
                RotatedRectangle rr = go.rr;
                Vector2          p  = new Vector2();

                for (int i = 0; i < pathfindingGrid.CellsY; i++)
                {
                    for (int j = 0; j < pathfindingGrid.CellsX; j++)
                    {
                        p.X = j * pathfindingGrid.CellSizeX + pathfindingGrid.CellSizeX / 2;
                        p.Y = i * pathfindingGrid.CellSizeY + pathfindingGrid.CellSizeX / 2;

                        if (rr.Contains(p))
                        {
                            mp_grid_set_cell(j, i);
                        }
                    }
                }
            }
        }
示例#2
0
        public static bool point_in_rectangle_rotated(Point2 point, RectangleF rectangle, double angle, Vector2 origin)
        {
            RotatedRectangle rr = rectangle_rotate(rectangle, origin, angle);

            //currentObject.rr = rr;
            return(rr.Contains(point));
        }