private void OnTriggerEnter2D(Collider2D other)
 {
     if (!hasBook && other.gameObject == targetBook)
     {
         targetBook.GetComponent <Book>().carried = true;
         hasBook         = true;
         targetBookPoint = FindNearestEmptyBookPoint();
         if (targetBookPoint != null)
         {
             targetBookPoint.GetComponent <BookPoint>().isTarget = true;
             SetTarget(targetBookPoint.transform);
         }
     }
     if (hasBook && other.gameObject == targetBookPoint)
     {
         Vector3 newPos = new Vector3(other.gameObject.transform.position.x, other.gameObject.transform.position.y, targetBook.transform.position.z);
         targetBook.transform.position            = newPos;
         targetBook.GetComponent <Book>().inPlace = true;
         BookPoint.BookPlaced();
         hasBook    = false;
         targetBook = FindNearestBook();
         if (targetBook != null)
         {
             targetBook.GetComponent <Book>().isTarget = true;
             SetTarget(targetBook.transform);
         }
         else
         {
             SetTarget(startingPos);
         }
     }
 }
Ejemplo n.º 2
0
        public List <BookPoint> GetBookPoints()
        {
            var points = new List <BookPoint>();

            try
            {
                var file = new FileInfo(mFilepath);
                if (!file.Exists)
                {
                    return(points);
                }

                FileStream            docStream = new System.IO.FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                Aspose.Words.Document doc       = new Aspose.Words.Document(docStream);
                docStream.Close();
                var curModule = "";
                var nodes     = doc.GetChildNodes(NodeType.Paragraph, true);
                foreach (var p in nodes)
                {
                    var par       = p as Aspose.Words.Paragraph;
                    var styleName = par.ParagraphFormat.Style.Name;
                    if (styleName != null && (styleName.Equals(WordStyleNames.STYLE_NAME_MODULE) || styleName.Equals(WordStyleNames.STYLE_NAME_MODULE2)))
                    {
                        curModule = par.Range.Text.Trim();
                    }
                    if (styleName != null && (styleName.Equals(WordStyleNames.STYLE_NAME_UNIT) || styleName.Equals(WordStyleNames.STYLE_NAME_UNIT2)))
                    {
                        var curUnit = par.Range.Text;
                        if (!string.IsNullOrEmpty(curModule))
                        {
                            var point = new BookPoint()
                            {
                                Book   = mFilepath?.Trim(),
                                Module = curModule?.Trim(),
                                Unit   = curUnit?.Trim()
                            };
                            points.Add(point);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                mLog.Error($"Exception: {nameof(WordFileReader)}.{nameof(GetBookPoints)} - {e}");
            }


            return(points);
        }
Ejemplo n.º 3
0
        private BookPoint GetIntersectionPoint(BookPoint lineOneMyPointOne, BookPoint lineOneMyPointTwo, BookPoint lineTwoMyPointOne, BookPoint lineTwoMyPointTwo)
        {
            float x1 = lineOneMyPointOne.X;
            float y1 = lineOneMyPointOne.Y;
            float x2 = lineOneMyPointTwo.X;
            float y2 = lineOneMyPointTwo.Y;
            float x3 = lineTwoMyPointOne.X;
            float y3 = lineTwoMyPointOne.Y;
            float x4 = lineTwoMyPointTwo.X;
            float y4 = lineTwoMyPointTwo.Y;

            float pointX = ((x1 - x2) * (x3 * y4 - x4 * y3) - (x3 - x4) * (x1 * y2 - x2 * y1))
                           / ((x3 - x4) * (y1 - y2) - (x1 - x2) * (y3 - y4));
            float pointY = ((y1 - y2) * (x3 * y4 - x4 * y3) - (x1 * y2 - x2 * y1) * (y3 - y4))
                           / ((y1 - y2) * (x3 - x4) - (x1 - x2) * (y3 - y4));

            return(new BookPoint(pointX, pointY));
        }
Ejemplo n.º 4
0
 public MainPage()
 {
     InitializeComponent();
     a = new BookPoint();
     f = new BookPoint();
     g = new BookPoint();
     e = new BookPoint();
     h = new BookPoint();
     c = new BookPoint();
     j = new BookPoint();
     b = new BookPoint();
     k = new BookPoint();
     d = new BookPoint();
     i = new BookPoint();
     CanvasView.IgnorePixelScaling = true;
     _region = new SKRegion();
     _pathA  = new SKPath();
     _pathC  = new SKPath();
 }