Exemplo n.º 1
0
        /// <summary>
        /// Generate a path from actors current position to the extent of the Codespace in given direction
        /// </summary>
        /// <param name="ord"></param>
        /// <param name="a"></param>
        /// <returns></returns>
        public static PathGeometry OrdinalPath(Codespace.Ordinal ord, DynamicElement el)
        {
            PathFigure pFigure = new PathFigure();

            pFigure.StartPoint = el.MidPoint;

            Point endpoint = el.MidPoint;

            switch (ord)
            {
            case Codespace.Ordinal.Right:
                endpoint.Offset(el.Parent.Right, 0);
                break;

            case Codespace.Ordinal.Left:
                endpoint.Offset(el.Parent.Left, 0);
                break;

            case Codespace.Ordinal.Up:
                endpoint.Offset(0, el.Parent.Top);
                break;

            case Codespace.Ordinal.Down:
                endpoint.Offset(0, el.Parent.Bottom);
                break;
            }


            pFigure.Segments.Add(new LineSegment(endpoint, true));


            PathGeometry animationPath = new PathGeometry();

            animationPath.Figures.Add(pFigure);
            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();
            return(animationPath);
        }
Exemplo n.º 2
0
        internal PathGeometry GenerateMagneticPath(VisualElement el)
        {
            if (!this.HasMagneticBorder)
            {
                return(null);
            }

            DynamicElement de = el as DynamicElement;

            if (null != de)
            {
                Codespace.Ordinal direction = _magnetism.Value;

                if (de.MagneticState == DynamicElement.Magnestism.Antimagnetic)
                {
                    direction = PathHelper.InvertDirection(direction);
                }

                return(PathHelper.OrdinalPath(direction, de));
            }

            return(null);
        }
Exemplo n.º 3
0
 public virtual void EndInteract(DynamicElement path)
 {
     //Default behaviour is to regenerate a default path
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handle interaction with other actors - e.g. change path, color, sound etc
 /// </summary>
 /// <param name="path"></param>
 public virtual void BeginInteract(DynamicElement path)
 {
 }