예제 #1
0
        void MainFormMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            for (int i = 0; i < TOTALCOUNT; i++)
            {
                bui[i].moveble = false;
            }


            if (!bui[numnextI].inprocess)
            {
                bui[numnextI].inprocess = true;
                bui[numnextI].dx        = 0;
                bui[numnextI].dy        = POWER * 4f;
                bui[numnextI].Move();
                tmp2tt = 0;
            }
            powup = false;



            if (e.Button == MouseButtons.Left)
            {
                LB             = false;
                line[NUMLINES] = new MyLine(tmpX1, tmpY1, e.X, e.Y);


                if (this.frm.checkBoxRotLine.Checked)
                {
                    line[NUMLINES].SetRotable();
                }

                if (this.frm.checkBoxBadLine.Checked)
                {
                    line[NUMLINES].SetBad();
                }



                NUMLINES++;
            }


            if (e.Button == MouseButtons.Right)
            {
                RB    = false;
                tmpX1 = PX = e.X;
                tmpY1 = PY = e.Y;
            }
        }
예제 #2
0
        void  Proch(Building b, MyLine line)
        {
            //	for(int o=0;o<10;o++)

            {
                if (Dist(b, line.a) < b.radius)
                {
                    Proch(b, line.a);
                }
                if (Dist(b, line.b) < b.radius)
                {
                    Proch(b, line.b);
                }

                float dd1 = distance(line.a,
                                     line.b,
                                     new PointF(b.x, b.y));
                float dd2 = distance(line.a,
                                     line.b,
                                     new PointF(b.oldx, b.oldy));
                float ddmed = distance(line.a,
                                       line.b,
                                       new PointF((b.oldx + b.x) * 0.5f, (b.oldy + b.x) * 0.5f));

                if (CircleIntersects((b.oldx + b.x) * 0.5f, (b.oldy + b.y) * 0.5f, b.radius, line.Length,
                                     line.a, line.b, new PointF(0, 0)))
                {
                    if (Math.Sign(dd1) != Math.Sign(dd2))
                    {
                        b.x -= b.dx / 2;
                        b.y -= b.dy / 2;
                    }
                }
                b.fix = false;
                for ( ; CircleIntersects(b.x, b.y, b.radius, line.Length,
                                         line.a, line.b, new PointF(0, 0));
                      )

                {
                    float dd = distance(line.a,
                                        line.b,
                                        new PointF(b.x, b.y));

                    b.x += 0.1f * line.KKK().X *Math.Sign(dd) * (Math.Abs(FVector.gravity) + 0.0001f);
                    b.y -= 0.1f * line.KKK().Y *Math.Sign(dd) * (Math.Abs(FVector.gravity) + 0.0001f);



                    b.fix = true;
                    //if(Math.Abs(b.dy) >  Math.Abs(b.dx))


                    if (line.Rotable)
                    {
                        line.Angle += (b.x - line.med.X) * Math.Sign(dd) * 0.00001f;
                    }

                    if (line.Bad)
                    {
                        line.a.Y += 0.1f;
                        line.b.Y += 0.1f;
                    }
                }
            }
        }