Beispiel #1
0
        /// <summary>
        /// Activates the figure.
        /// </summary>
        /// <param name="fig">The fig.</param>
        public static void activateFigure(StickObject fig)
        {
            for (int i = 0;i < figureList.Count;i++)
                figureList[i].isActiveFig = false;

            fig.isActiveFig = true;
        }
Beispiel #2
0
    public void Fire(Vector3 targetPos, float scale)
    {
        GameObject  go = new GameObject("stick");
        StickObject so = go.AddComponent <StickObject>();

        so._scl *= scale;
        if (scale > 1)
        {
            so._beChameleon = true;
            so._pos         = _sprite.PositionAt("リボン");
        }
        else
        {
            so._pos = _sprite.PositionAt("前手");
        }
        so._zpos         = -0.1f;
        so._sprite.hFlip = _sprite.hFlip;
        so.Init(targetPos);
    }
Beispiel #3
0
        public static void recalcFigureJoints(StickObject figure)
        {
            for (int i = 0; i < figure.Joints.Count; i++)
            {
                if (figure.Joints[i].parent != null)
                {
                    figure.Joints[i].CalcLength(null);
                }
            }

            for (int i = 0; i < figure.Joints.Count; i++)
            {
                if (figure.Joints[i].parent != null)
                {
                    if (!(figure.Joints[i].parent.children.IndexOf(figure.Joints[i]) >= 0))
                        figure.Joints[i].parent.children.Add(figure.Joints[i]);
                }
            figure.Joints[i].ParentFigure = figure;
            }
        }
Beispiel #4
0
 public static Point getFigureCenter(StickObject fig, int derp)
 {
     PointF center = getFigureCenter(fig);
     return new Point((int)Math.Round(center.X), (int)Math.Round(center.Y));
 }
Beispiel #5
0
        public static PointF getFigureCenter(StickObject fig)
        {
            float? x1 = null, y1 = null;
            float? x2 = null, y2 = null;

            foreach(StickJoint joint in fig.Joints)
            {
                x1 = x1 != null ? Math.Min(x1.Value, joint.location.X) : joint.location.X;
                y1 = y1 != null ? Math.Min(y1.Value, joint.location.Y) : joint.location.Y;
                x2 = x2 != null ? Math.Max(x2.Value, joint.location.X) : joint.location.X;
                y2 = y2 != null ? Math.Max(y2.Value, joint.location.Y) : joint.location.Y;
            }

            // Drawing.DrawGraphics(0, Color.Green, new Point((int)Math.Round(x1.Value), (int)Math.Round(y1.Value)), 2, 0, new Point((int)Math.Round(x1.Value), (int)Math.Round(y2.Value)));
            // Drawing.DrawGraphics(0, Color.Green, new Point((int)Math.Round(x1.Value), (int)Math.Round(y2.Value)), 2, 0, new Point((int)Math.Round(x2.Value), (int)Math.Round(y2.Value)));
            // Drawing.DrawGraphics(0, Color.Green, new Point((int)Math.Round(x2.Value), (int)Math.Round(y2.Value)), 2, 0, new Point((int)Math.Round(x2.Value), (int)Math.Round(y1.Value)));
            // Drawing.DrawGraphics(0, Color.Green, new Point((int)Math.Round(x2.Value), (int)Math.Round(y1.Value)), 2, 0, new Point((int)Math.Round(x1.Value), (int)Math.Round(y1.Value)));

            return new PointF((x2.Value + x1.Value) / 2, (y2.Value + y1.Value) / 2);
        }
Beispiel #6
0
 /// <summary>
 /// Adds the figure.
 /// </summary>
 /// <param name="figure">The figure.</param>
 public static void addFigure(StickObject figure)
 {
     figureList.Add(figure);
 }
Beispiel #7
0
        //Note: These events are hooked with the GLControl and not the canvas
        //Debug stuff, and dragging joints.
        /// <summary>
        /// Handles the MouseMove event of the Canvas control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (selectedJoint == null)
                return;

            //Set the cursor position in the toolbox
            Program.ToolboxForm.lbl_xPos.Text = "X Pos: " + e.X.ToString();
            Program.ToolboxForm.lbl_yPos.Text = "Y Pos: " + e.Y.ToString();

            //If the canvas is to be drawn, and the user isn't holding down the right mouse button
            //This is mostly so that you won't be dragging the entire figure at the same time
            //That you're dragging a joint
            if (draw & !(e.Button == MouseButtons.Right))
            {
                //To prevent exceptions being thrown.
                if (selectedJoint != null)
                {
                    if (selectedJoint.ParentFigure != null)
                        if (!(selectedJoint.ParentFigure.type == 3 || selectedJoint.ParentFigure.type == 10 || selectedJoint.ParentFigure.type == 7))
                        {
                            selectedJoint.SetPos(e.X, e.Y);
                            Program.ToolboxForm.lbl_dbgAngleToParent.Text = "AngleToParent: " + selectedJoint.AngleToParent;
                            Refresh();
                        }
                        else
                        {
                            Point p = selectedJoint.location;

                            selectedJoint.SetPosAbs(e.X, e.Y);

                            if (selectedJoint.ParentFigure.type == 3 || selectedJoint.ParentFigure.type == 7)
                            {
                                if (selectedJoint.ParentFigure.type == 3)
                                    ((StickRect)selectedJoint.ParentFigure).onRectJointMoved(selectedJoint, p);
                                else
                                    ((StickImage)selectedJoint.ParentFigure).onJointMoved(selectedJoint);
                            }
                        }
                }

                //This prevents any other figures from becoming active as you are dragging a joint.
                //Deprecated for now, possibly of some use in the future.

                /*
                foreach (StickObject fig in figureList)
                {
                    if (!(fig == activeFigure))
                        fig.isActiveFig = false;
                }
                */
            }
            else if (draw & e.Button == MouseButtons.Right)
            {
                //This prevents the context menu from popping up after you release the right
                //mouse button when you're dragging a figure.
                mousemoved = true;

                //This basically keeps the distance from the cursor and the figure constant
                //as the user drags it around.
                for (int i = 0;i < activeFigure.Joints.Count;i++)
                {
                    activeFigure.Joints[i].location.X = fx[i] + (e.X - ox);
                    activeFigure.Joints[i].location.Y = fy[i] + (e.Y - oy);
                }

                //Refresh the canvas or the user won't see any difference.
                Refresh();
            }

            //This is what sets the active figure to whatever figure owns the joint that you
            //moused over. I'm pretty sure that activeFigure is deprecated because multiple figures can't be on the same
            //layer anymore (for now).
            for (int i = 0;i < figureList.Count;i++)
            {
                if (figureList[i].getPointAt(new Point(e.X, e.Y), 6) != -1 && figureList[i].drawHandles)
                {
                    if (activeFigure != null)
                        activeFigure.isActiveFig = false;

                    activeFigure = figureList[i];
                    activeFigure.isActiveFig = true;

                    Refresh();
                    break;
                }
            }

            //If the active figure exists (isn't null), and we aren't supposed to redraw, then..
            //This is what sets the cursor to the hand when you mouse over a joint.
            if (!(activeFigure == null) & !draw)
            {
                if (activeFigure.getPointAt(new Point(e.X, e.Y), 6) != -1)
                    this.Cursor = Cursors.Hand;
                else
                    this.Cursor = Cursors.Default;
            }
        }
Beispiel #8
0
 /// <summary>
 /// Removes the specified tween figure from the tween figures list.
 /// </summary>
 /// <param name="figure">The figure.</param>
 public static void removeTweenFigure(StickObject figure)
 {
     tweenFigs.Remove(figure);
 }
Beispiel #9
0
 /// <summary>
 /// Removes the figure.
 /// </summary>
 /// <param name="figure">The figure.</param>
 public static void removeFigure(StickObject figure)
 {
     figureList.Remove(figure);
 }
Beispiel #10
0
 /// <summary>
 /// Adds the tween figure.
 /// </summary>
 /// <param name="figure">The figure.</param>
 public static void addTweenFigure(StickObject figure)
 {
     tweenFigs.Add(figure); figure.isTweenFig = true;
 }