Exemplo n.º 1
0
            private void Move(MoveObject mo)
            {
                var velocity = mo.Velocity.Multiply(mo.Scalar);
                var acceleration = mo.Acceleration.Multiply(mo.Scalar);

                //this.permitedReturn = new Point(dude.location.X + velocity.X, dude.Location.Y + velocity.Y).Inverse();
                Point permittedReturn = dude.Location;

                //frameCount = 10000;
                for (int i = 0; i < mo.FrameCount; i++)
                {
                    var nextPoint = new Point(dude.location.X + velocity.X, dude.Location.Y + velocity.Y);
                    var isMoveAble = dude.OnBeforeLocationChange.Invoke(nextPoint, dude.Size);

                    if (!isMoveAble
                        //|| ((permitedReturn.X >= nextPoint.X ) && i > 1)
                        )
                        break;

                    dude.location.Offset(velocity);
                    dude.OnLocationChange.Invoke(this.dude);
                    //System.Threading.Thread.Sleep(mo.Interval);
                    velocity.Offset(acceleration);

                    permittedReturn = nextPoint;
                }
            }
Exemplo n.º 2
0
            public void Forward()
            {
                var mo = new MoveObject();

                mo.Scalar = 1;
                dude.Velocity = new Point(1, 0);
                mo.Acceleration = new Point(-1, 0);
                mo.FrameCount = 7;

                //return mo;
                //Move(mo);
            }
Exemplo n.º 3
0
            public void Jump()
            {
                var mo = new MoveObject();

                dude.Velocity = new Point(1, 3);
                //mo.Acceleration = new Point(0, -1);
                mo.Scalar = 1;
                mo.FrameCount = 10;

                //Move(mo);
            }
Exemplo n.º 4
0
            public void Backward()
            {
                var mo = new MoveObject();

                mo.Scalar = 1;
                mo.Velocity = new Point(-8, 0);
                mo.Acceleration = new Point(1, 0);
                mo.FrameCount = 7;

                //Move(mo);
            }