Exemplo n.º 1
0
        /// Gets whether the given vector is within a rectangle from (0,0) to this
        /// vector (half-inclusive).
        public bool contains(VectorBase pos)
        {
            var left = Math.Min(0, x);

            if (pos.x < left)
            {
                return(false);
            }

            var right = Math.Max(0, x);

            if (pos.x >= right)
            {
                return(false);
            }

            var top = Math.Min(0, y);

            if (pos.y < top)
            {
                return(false);
            }

            var bottom = Math.Max(0, y);

            if (pos.y >= bottom)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 public CircleX(VectorBase center, int radius)
 {
     this.center = center;
     this.radius = radius;
     if (radius < 0)
     {
         throw new ArgumentOutOfRangeException("The radius cannot be negative.");
     }
 }
Exemplo n.º 3
0
        /// Gets whether [pos] is in the outermost edge of the circle.
        public bool isEdge(VectorBase pos)
        {
            var leadingEdge = true;

            if (radius > 0)
            {
                leadingEdge = (pos - center) > CircleUtilities.GetRadiusSquared(radius - 1);
            }

            return(leadingEdge);
        }
Exemplo n.º 4
0
 public Appearence(string glyph, string backGroundColor, string foreGroundColor, bool isExplored, bool isHidden, bool isInShadow, int x, int y, string slug, AppearenceType type)
 {
     _glyph          = glyph;
     BackGroundColor = backGroundColor;
     ForeGroundColor = foreGroundColor;
     IsExplored      = isExplored;
     IsHidden        = isHidden;
     IsInShadow      = isInShadow;
     Position        = new VectorBase(x, y);
     Slug            = slug;
     Type            = type;
 }
Exemplo n.º 5
0
 protected bool Equals(VectorBase other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(x == other.x && y == other.y);
 }
Exemplo n.º 6
0
        private VectorBase LineIntersectsLine(VectorBase l1p1, VectorBase l1p2, VectorBase l2p1, VectorBase l2p2)
        {
            var intersectingLine = new Los(l1p1, l1p2);

            var queryingLine = new Los(l2p1, l2p2);

            foreach (var point in intersectingLine.Points)
            {
                if (queryingLine.Points.Contains(point))
                {
                    return(point);
                }
            }

            return(null);
        }
Exemplo n.º 7
0
        public VectorBase GetIntersect(VectorBase origin)
        {
            var center = GetCenter();

            VectorBase pointOfIntersection = null;

            pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x, topLeft.y), new VectorBase(topLeft.x + width, topLeft.y));
            if (pointOfIntersection != null)
            {
                return(pointOfIntersection);
            }
            pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x + width, topLeft.y), new VectorBase(topLeft.x + width, topLeft.y + height));
            if (pointOfIntersection != null)
            {
                return(pointOfIntersection);
            }
            pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x + width, topLeft.y + height), new VectorBase(topLeft.x, topLeft.y + height));
            if (pointOfIntersection != null)
            {
                return(pointOfIntersection);
            }
            pointOfIntersection = LineIntersectsLine(origin, center, new VectorBase(topLeft.x, topLeft.y + height), new VectorBase(topLeft.x, topLeft.y));
            return(pointOfIntersection);
        }
Exemplo n.º 8
0
 public Circle(VectorBase center, int radius)
 {
     Center = center;
     Radius = radius;
     CalculatePoints();
 }
Exemplo n.º 9
0
 public bool Intersect(VectorBase origin)
 {
     return(GetIntersect(origin) != null);
 }
Exemplo n.º 10
0
 public Rect(VectorBase position, VectorBase size)
 {
     pos       = (Vector)position;
     this.size = (Vector)size;
 }
Exemplo n.º 11
0
 /// Scales this VectorBase by [other].
 public VectorBase Scale(VectorBase obj, int other)
 {
     return(new VectorBase(obj.x * other, obj.y * other));
 }