示例#1
0
        public override void Think(Time dt)
        {
            if (_vectoringOn)
            {
                if (((Player)Parent).ADown)
                {// -
                    Rotation = _vectoringMinMax.X;
                }
                else if (((Player)Parent).DDown)
                {// +
                    Rotation = _vectoringMinMax.Y;
                }
                else
                {
                    Rotation = _restingRotation;
                }
            }

            if (((Player)Parent).WDown)
            {
                var force = new Vector2f(0, -_acceleration * dt.AsSeconds());
                force = Vector2Extended.Rotate(force, Parent.Rotation + Rotation);

                ((Dynamic)Parent).Body.ApplyForce(Vector2Extended.SFMLToXNA(force), ConvertUnits.ToSimUnits(Vector2Extended.SFMLToXNA(Sprite.Position)));
            }
            //((Ship)Parent).Velocity -= Vector2Extended.Rotate(new Vector2f(0, _acceleration), Rotation + Parent.Rotation) * dt.AsSeconds();

            base.Think(dt);
        }