コード例 #1
0
ファイル: WillHelper.cs プロジェクト: Cyberbanan/fukami
        public static BoneBody AddBone(this ConnectionSlotBody slotBody, BoneModel boneModel)
        {
            var slot = slotBody.Model;

            slot.IsOccupied = true;

            var slotPos   = slotBody.State.Position;
            var slotSize  = slotBody.Model.Size;
            var centerLoc = Vector2D.FromLengthAndAngle((boneModel.Length + slotSize) * 0.5, slotPos.Angular);

            var bonePos = new ALVector2D(slotPos.Angular, slotPos.Linear + centerLoc);

            var rectBody = CreateRectangle(boneModel.Thickness, boneModel.Length, 0.00001, bonePos);

            var newBone = rectBody.CopyAsBone(slotBody.ModelId);

            newBone.Model  = boneModel;
            newBone.Parent = slotBody;

            var joints = slotBody.ConnectWith(newBone, (2 * bonePos.Linear + 8 * slotBody.State.Position.Linear) * 0.1f);

            Will.Instance.AddBody(newBone);
            Will.Instance.AddJoint(joints.Item1);
            Will.Instance.AddJoint(joints.Item2);

            return(newBone);
        }
コード例 #2
0
ファイル: WillHelper.cs プロジェクト: Cyberbanan/fukami
        public static ConnectionSlotBody CreateConnectionSlotBody(IConnectionSlot slot, Guid modelId)
        {
            var size = slot.Size;

            var vertexList = VertexHelper.CreateRectangle(slot.Size, slot.Size).ToList();

            vertexList.Insert(0, new Vector2D(size, 0));

            var vertices = VertexHelper.Subdivide(vertexList.ToArray(), Math.Min(size, size) / 5);

            var boxShape = ShapeFactory.GetOrCreateColoredPolygonShape(vertices, Math.Min(size, size) / 5);

            var rectBody = new Body(new PhysicsState(ALVector2D.Zero), boxShape, 0.0001, Coefficients.Duplicate(), new Lifespan());

            rectBody.Coefficients = new Physics2DDotNet.Coefficients(0.1, 0.7);

            var newSlot = new ConnectionSlotBody(rectBody.State, rectBody.Shape, rectBody.Mass, rectBody.Coefficients, rectBody.Lifetime, modelId)
            {
                Model        = slot,
                IsCollidable = false
            };

            return(newSlot);
        }