Esempio n. 1
0
        public static List <Vector2Object> LineVsMap(MapTreeHolder map, LineObject segment)
        {
            List <Vector2Object> temp = new List <Vector2Object>();

            temp.AddRange(linevsRecs(LineBoundaryVsMap(map, segment), segment));

            return(temp);
        }
Esempio n. 2
0
        protected bool RemoveOnMapCollision(MapTreeHolder map, IProjectile projectile, out Vector2Object hit)
        {
            hit = null;

            if (CompareF.LineVsMap(map, _track).Count > 0)
            {
                hit = CompareF.NearestVector(_track.Line.Start, CompareF.LineVsMap(map, _track));
                Game1.mapLive.MapProjectiles.Remove(projectile);
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        //Test
        public static List <Vector2Object> LineVsMapRecReturn(MapTreeHolder map, LineObject segment)
        {
            List <Vector2Object> vectors = new List <Vector2Object>();

            for (int Y = (int)(Math.Max(0, (segment.Line.LineBoundingBox().Position.Y / 1024f) - 1)); Y < (int)Math.Ceiling(Math.Min((segment.Line.LineBoundingBox().CornerRightTop.Y / 1024f) + 1, map.Trees.GetLength(1))); Y++)
            {
                for (int X = (int)(Math.Max(0, (segment.Line.LineBoundingBox().Position.X / 1024f) - 1)); X < (int)Math.Ceiling(Math.Min((segment.Line.LineBoundingBox().CornerRightTop.X / 1024f) + 1, map.Trees.GetLength(0))); X++)
                {
                    if (LineIntersectionRectangle(map.Trees[X, Y].Boundary, segment).Count > 0 || RectangleVsVector2(map.Trees[X, Y].Boundary, segment.Line.End))
                    {
                        vectors.AddRange(map.Trees[X, Y].FindIntersectLine(segment.Line));
                    }
                }
            }

            return(vectors);
        }
Esempio n. 4
0
        public static List <RectangleF> LineBoundaryVsMap(MapTreeHolder map, LineObject segment)
        {
            List <RectangleF> rectangles = new List <RectangleF>();

            for (int Y = (int)(Math.Max(0, (segment.Line.LineBoundingBox().Position.Y / 1024f) - 1)); Y < (int)Math.Ceiling(Math.Min((segment.Line.LineBoundingBox().CornerRightTop.Y / 1024f) + 1, map.Trees.GetLength(1))); Y++)
            {
                for (int X = (int)(Math.Max(0, (segment.Line.LineBoundingBox().Position.X / 1024f) - 1)); X < (int)Math.Ceiling(Math.Min((segment.Line.LineBoundingBox().CornerRightTop.X / 1024f) + 1, map.Trees.GetLength(0))); X++)
                {
                    if (RectangleFVsRectangleF(map.Trees[X, Y].Boundary, segment.Line.LineBoundingBox()) == true)
                    {
                        rectangles.AddRange(map.Trees[X, Y].FindIntersectRec(segment.Line.LineBoundingBox()));
                    }
                }
            }

            return(rectangles);
        }
Esempio n. 5
0
        public void GenerateMapFunctionTrees()
        {
            MapTree   = new MapTreeHolder((int)MapBoundary.Size.X, (int)MapBoundary.Size.Y);
            WaterTree = new MapTreeHolder((int)MapBoundary.Size.X, (int)MapBoundary.Size.Y);

            for (int y = 0; y < FunctionTileMap.GetLength(1); y++)
            {
                for (int x = 0; x < FunctionTileMap.GetLength(0); x++)
                {
                    if (FunctionTileMap[x, y] == "block")
                    {
                        MapTree.AddRectangle32(new Vector2(x, y) * Globals.TileSize);
                    }
                    if (FunctionTileMap[x, y] == "water")
                    {
                        WaterTree.AddRectangle32(new Vector2(x, y) * Globals.TileSize);
                    }
                }
            }
        }
Esempio n. 6
0
        public static List <RectangleF> VectorVsWater(MapTreeHolder water, Vector2 vector)
        {
            List <RectangleF> rectangles = new List <RectangleF>();

            if (water != null)
            {
                for (int Y = 0; Y < water.Trees.GetLength(1); Y++)
                {
                    for (int X = 0; X < water.Trees.GetLength(0); X++)
                    {
                        if (RectangleVsVector2NotEq(water.Trees[X, Y].Boundary, vector) == true)
                        {
                            rectangles.AddRange(water.Trees[X, Y].FindRecWithVector(vector));
                        }
                    }
                }
            }

            return(rectangles);
        }
Esempio n. 7
0
        public static List <RectangleF> RectangleVsMap(MapTreeHolder map, RectangleF rectangle)
        {
            List <RectangleF> rectangles = new List <RectangleF>();

            if (map != null)
            {
                for (int Y = 0; Y < map.Trees.GetLength(1); Y++)
                {
                    for (int X = 0; X < map.Trees.GetLength(0); X++)
                    {
                        if (RectangleFVsRectangleF(map.Trees[X, Y].Boundary, rectangle) == true)
                        {
                            rectangles.AddRange(map.Trees[X, Y].FindIntersectRec(rectangle));
                        }
                    }
                }
            }

            return(rectangles);
        }
Esempio n. 8
0
 private void Explode(MapTreeHolder map, List <Inpc> npcs)
 {
     Explosion.Explode(Boundary.Origin, _damage);
     Game1.mapLive.MapProjectiles.Remove(this);
 }