Exemple #1
0
        public override bool ContainsCirc(CircStruct circ)
        {
            RectStruct boxX = new RectStruct(Position.X - circ.Size.X / 2, Position.Y, Size.X + circ.Size.X, Size.Y);
            RectStruct boxY = new RectStruct(Position.X, Position.Y - circ.Size.Y / 2, Size.X, Size.Y + circ.Size.X);
            Vector2    circOriginPosition = new Vector2(circ.Position.X + circ.Size.X / 2, circ.Position.Y + circ.Size.Y / 2);

            if (boxX.ContainsPoint(circOriginPosition) || boxY.ContainsPoint(circOriginPosition))
            {
                return(true);
            }

            List <Vector2> vertexes = new List <Vector2>();

            vertexes.Add(new Vector2(Position.X, Position.Y));
            vertexes.Add(new Vector2(Position.X + Size.X, Position.Y));
            vertexes.Add(new Vector2(Position.X, Position.Y + Size.Y));
            vertexes.Add(new Vector2(Position.X + Size.X, Position.Y + Size.Y));

            foreach (Vector2 vertex in vertexes)
            {
                if (GameMath.GetDistance(vertex, circOriginPosition) <= circ.Size.X / 2)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
        public override bool ContainsRect(RectStruct rect)
        {
            RectStruct boxX = new RectStruct(rect.Position.X - Size.X / 2, rect.Position.Y, rect.Size.X + Size.X / 2, rect.Size.Y);
            RectStruct boxY = new RectStruct(rect.Position.X, rect.Position.Y - Size.X / 2, rect.Size.X, rect.Size.Y + Size.X / 2);

            if (boxX.ContainsPoint(GetOrigin()) || boxY.ContainsPoint(GetOrigin()))
            {
                return(true);
            }

            List <Vector2> vertexes = new List <Vector2>();

            vertexes.Add(new Vector2(rect.Position.X, rect.Position.Y));
            vertexes.Add(new Vector2(rect.Position.X + rect.Size.X, rect.Position.Y));
            vertexes.Add(new Vector2(rect.Position.X, rect.Position.Y + rect.Size.Y));
            vertexes.Add(new Vector2(rect.Position.X + rect.Size.X, rect.Position.Y + rect.Size.Y));

            foreach (Vector2 vertex in vertexes)
            {
                if (GameMath.GetDistance(vertex, GetOrigin()) <= Size.X / 2)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
        public override bool ContainsRect(RectStruct rect)
        {
            if (rect.Position.X + rect.Size.X >= Position.X && rect.Position.X <= Position.X + Size.X && rect.Position.Y + rect.Size.Y >= Position.Y && rect.Position.Y <= Position.Y + Size.Y)
            {
                return(true);
            }

            return(false);
        }
Exemple #4
0
 public abstract bool ContainsRect(RectStruct rect);