当前位置: 首页>>代码示例>>C#>>正文


C# FVector2类代码示例

本文整理汇总了C#中FVector2的典型用法代码示例。如果您正苦于以下问题:C# FVector2类的具体用法?C# FVector2怎么用?C# FVector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FVector2类属于命名空间,在下文中一共展示了FVector2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MouseDrag

    public virtual void MouseDrag()
    {
        // mouse press
        if(Input.GetMouseButtonDown(0) && mouseJoint == null)
        {
            Body body = GetBodyAtMouse();
            if(body != null)
            {
                FVector2 target = new FVector2(MouseXWorldPhys, MouseYWorldPhys);
                mouseJoint = JointFactory.CreateFixedMouseJoint(FSWorldComponent.PhysicsWorld, body, target);
                mouseJoint.CollideConnected = true;
                mouseJoint.MaxForce = 300f * body.Mass;
                body.Awake = true;
            }
        }
        // mouse release
        if(Input.GetMouseButtonUp(0))
        {
            if(mouseJoint != null)
            {
                FSWorldComponent.PhysicsWorld.RemoveJoint(mouseJoint);
                mouseJoint = null;
            }
        }

        // mouse move
        if(mouseJoint != null)
        {
            FVector2 p2 = new FVector2(MouseXWorldPhys, MouseYWorldPhys);
            mouseJoint.WorldAnchorB = p2;
        }
    }
开发者ID:rllamas,项目名称:Quantum,代码行数:32,代码来源:FSMouseTest.cs

示例2: CreateDistanceJoint

 public static FSDistanceJoint CreateDistanceJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
                                                 FVector2 anchorB)
 {
     FSDistanceJoint distanceJoint = new FSDistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:horsman,项目名称:survival,代码行数:7,代码来源:JointFactory.cs

示例3: EdgeShape

 public EdgeShape(FVector2 start, FVector2 end)
     : base(0)
 {
     ShapeType = ShapeType.Edge;
     _radius = Settings.PolygonRadius;
     Set(start, end);
 }
开发者ID:pracalic,项目名称:Farseer-Unity3D,代码行数:7,代码来源:EdgeShape.cs

示例4: FrictionJoint

 public FrictionJoint(Body bodyA, Body bodyB, FVector2 localAnchorA, FVector2 localAnchorB)
     : base(bodyA, bodyB)
 {
     JointType = JointType.Friction;
     LocalAnchorA = localAnchorA;
     LocalAnchorB = localAnchorB;
 }
开发者ID:pracalic,项目名称:Farseer-Unity3D,代码行数:7,代码来源:FrictionJoint.cs

示例5: CreateFrictionJoint

 public static FSFrictionJoint CreateFrictionJoint(FSWorld world, FSBody bodyA, FSBody bodyB, FVector2 anchorA,
                                                 FVector2 anchorB)
 {
     FSFrictionJoint frictionJoint = new FSFrictionJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(frictionJoint);
     return frictionJoint;
 }
开发者ID:horsman,项目名称:survival,代码行数:7,代码来源:JointFactory.cs

示例6: AttachBodiesWithSliderJoint

        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        /// <param name="minLength">Minimum length of the slider joint.</param>
        /// <param name="maxLength">Maximum length of the slider joint.</param>
        /// <returns></returns>
        public static List<FSSliderJoint> AttachBodiesWithSliderJoint(FSWorld world, List<FSBody> bodies, FVector2 localAnchorA,
                                                                    FVector2 localAnchorB, bool connectFirstAndLast,
                                                                    bool collideConnected, float minLength,
                                                                    float maxLength)
        {
            List<FSSliderJoint> joints = new List<FSSliderJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                FSSliderJoint joint = new FSSliderJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB, minLength,
                                                    maxLength);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                FSSliderJoint lastjoint = new FSSliderJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA, localAnchorB,
                                                        minLength, maxLength);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
开发者ID:horsman,项目名称:survival,代码行数:39,代码来源:PathManager.cs

示例7: CreateChainShape

 public static Body CreateChainShape(World world, Vertices vertices, FVector2 position,
                                    object userData)
 {
     Body body = CreateBody(world, position);
     FixtureFactory.AttachChainShape(vertices, body, userData);
     return body;
 }
开发者ID:frotein,项目名称:TinyUniverse,代码行数:7,代码来源:BodyFactory.cs

示例8: CircleShape

 internal CircleShape()
     : base(0)
 {
     ShapeType = ShapeType.Circle;
     _radius = 0.0f;
     _position = FVector2.Zero;
 }
开发者ID:pracalic,项目名称:Farseer-Unity3D,代码行数:7,代码来源:CircleShape.cs

示例9: GetBodyAtMouse

    public virtual Body GetBodyAtMouse(bool includeStatic)
    {
        // Make a small box
        mousePVec.X = MouseXWorldPhys;
        mousePVec.Y = MouseYWorldPhys;
        FVector2 lowerBound = new FVector2(MouseXWorldPhys - 0.001f, MouseYWorldPhys - 0.001f);
        FVector2 upperBound = new FVector2(MouseXWorldPhys + 0.001f, MouseYWorldPhys + 0.001f);
        AABB aabb = new AABB(lowerBound, upperBound);
        Body body = null;

        // Query the world for overlapping shapes
        System.Func<Fixture, bool> GetBodyCallback = delegate (Fixture fixture0)
        {
            Shape shape = fixture0.Shape;
            if(fixture0.Body.BodyType != BodyType.Static || includeStatic)
            {
                FarseerPhysics.Common.Transform transform0;
                fixture0.Body.GetTransform(out transform0);
                bool inside = shape.TestPoint(ref transform0, ref mousePVec);
                if(inside)
                {
                    body = fixture0.Body;
                    return false;
                }
            }
            return true;
        };
        FSWorldComponent.PhysicsWorld.QueryAABB(GetBodyCallback, ref aabb);
        return body;
    }
开发者ID:rllamas,项目名称:Quantum,代码行数:30,代码来源:FSMouseTest.cs

示例10: CreateDistanceJoint

 public static DistanceJoint CreateDistanceJoint(World world, Body bodyA, Body bodyB, FVector2 anchorA,
     FVector2 anchorB)
 {
     DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:pracalic,项目名称:Farseer-Unity3D,代码行数:7,代码来源:JointFactory.cs

示例11: AbstractForceController

        /// <summary>
        /// Constructor
        /// </summary>
        public AbstractForceController()
            : base(ControllerType.AbstractForceController)
        {
            Enabled = true;

            Strength = 1.0f;
            Position = new FVector2(0, 0);
            MaximumSpeed = 100.0f;
            TimingMode = TimingModes.Switched;
            ImpulseTime = 0.0f;
            ImpulseLength = 1.0f;
            Triggered = false;
            StrengthCurve = new Curve();
            Variation = 0.0f;
            Randomize = new Random(1234);
            DecayMode = DecayModes.None;
            DecayCurve = new Curve();
            DecayStart = 0.0f;
            DecayEnd = 0.0f;

            StrengthCurve.Keys.Add(new CurveKey(0, 5));
            StrengthCurve.Keys.Add(new CurveKey(0.1f, 5));
            StrengthCurve.Keys.Add(new CurveKey(0.2f, -4));
            StrengthCurve.Keys.Add(new CurveKey(1f, 0));
        }
开发者ID:horsman,项目名称:survival,代码行数:28,代码来源:AbstractForceController.cs

示例12: AttachRectangle

 public static Fixture AttachRectangle(float width, float height, float density, FVector2 offset, Body body,
                                       object userData)
 {
     Vertices rectangleVertices = PolygonTools.CreateRectangle(width / 2, height / 2);
     rectangleVertices.Translate(ref offset);
     PolygonShape rectangleShape = new PolygonShape(rectangleVertices, density);
     return body.CreateFixture(rectangleShape, userData);
 }
开发者ID:frotein,项目名称:TinyUniverse,代码行数:8,代码来源:FixtureFactory.cs

示例13: Start

	// Use this for initialization
	void Start ()
	{
		Vector3 p = transform.position;
		FVector2 aa = new FVector2(p.x + StartPoint.x, p.y + StartPoint.y);
		FVector2 bb = new FVector2(p.x + EndPoint.x, p.y + EndPoint.y);
		aabb = new AABB(aa, bb);
		buoyancyController = new BuoyancyController(aabb, Density, LinearDragCoef, RotationalDragCoef, FSWorldComponent.PhysicsWorld.Gravity);
		FSWorldComponent.PhysicsWorld.AddController(buoyancyController);
	}
开发者ID:frotein,项目名称:TinyUniverse,代码行数:10,代码来源:FSBuoyancyComponent.cs

示例14: AttachCircle

        public static Fixture AttachCircle(float radius, float density, Body body, FVector2 offset, object userData)
        {
            if (radius <= 0)
                throw new ArgumentOutOfRangeException("radius", "Radius must be more than 0 meters");

            CircleShape circleShape = new CircleShape(radius, density);
            circleShape.Position = offset;
            return body.CreateFixture(circleShape, userData);
        }
开发者ID:frotein,项目名称:TinyUniverse,代码行数:9,代码来源:FixtureFactory.cs

示例15: Path

        /// <summary>
        /// Initializes a new instance of the <see cref="Path"/> class.
        /// </summary>
        /// <param name="vertices">The vertices to created the path from.</param>
        public Path(FVector2[] vertices)
        {
            ControlPoints = new List<FVector2>(vertices.Length);

            for (int i = 0; i < vertices.Length; i++)
            {
                Add(vertices[i]);
            }
        }
开发者ID:frotein,项目名称:TinyUniverse,代码行数:13,代码来源:Path.cs


注:本文中的FVector2类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。