Example #1
0
        private void test(CollisionEntity entity)
        {
            map.Collision.ResetDebugOutput();
            var res = entity.Update(pt, deg, true);

            label1.Text = "Front: " + res.Front;
        }
Example #2
0
        private void MoveMotionOne_Tick(object sender, EventArgs e)
        {
            Rectangle bounds = new Rectangle(0, 0, _Dimension[0], _Dimension[1]);

            if (up)
            {
                map.Collision.ResetDebugOutput();
                if (!entity.Update(carpanel.Location, Convert.ToInt32(carpanel.Angle + 90), true).Front)
                {
                    carpanel.Move((int)keys.up, bounds);
                }
            }
            else if (down)
            {
                //if (!entity.Update(carpanel.Location, Convert.ToInt32(carpanel.Angle), false).Back)
                carpanel.Move((int)keys.down, bounds);
            }
            else if (!up)
            {
                if (carpanel.FinishMove(new Rectangle(0, 0, _Dimension[0], _Dimension[1])))
                {
                    MoveMotionOne.Stop();
                }
            }

            if (up || down)
            {
                if (right)
                {
                    //Rectangle bounds = new Rectangle(0, 0, _Dimension[0], _Dimension[1]);
                    carpanel.Move((int)keys.right, bounds);
                }
                else if (left)
                {
                    //Rectangle bounds = new Rectangle(0, 0, _Dimension[0], _Dimension[1]);
                    carpanel.Move((int)keys.left, bounds);
                }
            }
            Invalidate();
        }
Example #3
0
        public void Move(Rectangle bounds)
        {
            if (Destroyed)
            {
                return;
            }

            Point cPosition = new Point(Location.X + Size.Width / 2, Location.Y + Size.Height / 2);

            if (Up && Down)
            {
                if (entity.Update(cPosition, Convert.ToInt32(Angle + 90), true).Front || entity.Update(cPosition, Convert.ToInt32(Angle + 90), false).Back)
                {
                    collide();
                }
                FinishMove(bounds);

                if (Left && Right)
                {
                }
                else if (Left)
                {
                    Move((int)CarController.keys.left, bounds);
                }
                else if (Right)
                {
                    Move((int)CarController.keys.right, bounds);
                }
            }
            else if (Up)
            {
                if (entity.Update(cPosition, Convert.ToInt32(Angle + 90), true).Front)
                {
                    collide();
                }
                else
                {
                    Move((int)CarController.keys.up, bounds);
                }

                if (Left && Right)
                {
                }
                else if (Left)
                {
                    Move((int)CarController.keys.left, bounds);
                }
                else if (Right)
                {
                    Move((int)CarController.keys.right, bounds);
                }
            }
            else if (Down)
            {
                if (entity.Update(cPosition, Convert.ToInt32(Angle + 90), false).Back)
                {
                    collide();
                }
                else
                {
                    Move((int)CarController.keys.down, bounds);
                }

                if (Left && Right)
                {
                }
                else if (Left)
                {
                    Move((int)CarController.keys.right, bounds); //Wenn man rückwärts fährt ist die Drehung umgekehrt
                }
                else if (Right)
                {
                    Move((int)CarController.keys.left, bounds);
                }
            }
            else
            {
                if (entity.Update(cPosition, Convert.ToInt32(Angle + 90), true).Front || entity.Update(cPosition, Convert.ToInt32(Angle + 90), false).Back)
                {
                    collide();
                }
                FinishMove(bounds);

                if (Left && Right)
                {
                }
                else if (Left)
                {
                    Move((int)CarController.keys.left, bounds);
                }
                else if (Right)
                {
                    Move((int)CarController.keys.right, bounds);
                }
            }
        }