Пример #1
0
 public void AddVector(namVect v)
 {
     this.X = this.X + v.X;
     this.Y = this.Y + v.Y;
 }
Пример #2
0
        public namDirections GetDirectionForNext(namVect curVec, namPoint curLoc)
        {
            namDirections result = namDirections.Null;

            if (curVec.Length < (this.size * 3) && curVec.Length > 0)
            {
                int offset = Convert.ToInt32(Math.Floor((this.size * 3) / curVec.Length));

                curVec.MultiplyBy(offset); // make longer to ensure it will intersect side
            }

            Line north = this.Side[(int)namDirections.North];
            Line west = this.Side[(int)namDirections.West];
            Line south = this.Side[(int)namDirections.South];
            Line east = this.Side[(int)namDirections.East];

            Line test = curVec.toLine(curLoc);

            if (this.DoLinesIntersect(north, test))
            {
                namPoint intersect = this.GetLinesIntersect(north, test);

                if (intersect == north.Start)
                {
                    result = namDirections.NorthWest;
                }
                else if (intersect == north.End)
                {
                    result = namDirections.NorthEast;
                }
                else
                {
                    result = namDirections.North;
                }
            }
            else if (this.DoLinesIntersect(west, test))
            {
                namPoint intersect = this.GetLinesIntersect(west, test);

                if (intersect == west.Start)
                {
                    result = namDirections.NorthWest;
                }
                else if (intersect == west.End)
                {
                    result = namDirections.SouthWest;
                }
                else
                {
                    result = namDirections.West;
                }
            }
            else if (this.DoLinesIntersect(south, test))
            {
                namPoint intersect = this.GetLinesIntersect(west, test);

                if (intersect == south.Start)
                {
                    result = namDirections.SouthWest;
                }
                else if (intersect == south.End)
                {
                    result = namDirections.SouthEast;
                }
                else
                {
                    result = namDirections.South;
                }
            }
            else if (this.DoLinesIntersect(east, test))
            {
                namPoint intersect = this.GetLinesIntersect(west, test);

                if (intersect == east.Start)
                {
                    result = namDirections.NorthEast;
                }
                else if (intersect == east.End)
                {
                    result = namDirections.SouthEast;
                }
                else
                {
                    result = namDirections.East;
                }
            }

            return result;
        }