예제 #1
0
    public static void CopyTentSegments(Tentacle source, Tentacle dest)
    {
        dest.ClearSegments();

        dest.segments   = source.segments;
        dest.startWidth = source.startWidth;
        dest.endWidth   = source.endWidth;
        dest.length     = source.length;

        dest.GenerateSegments();

        for (int i = 0; i < dest.tentJoints.Count; i++)
        {
            TentJoint destJoint   = dest.tentJoints[i];
            TentJoint sourceJoint = source.tentJoints[i];

            destJoint.transform.position            = dest.transform.position + source.transform.InverseTransformPoint(sourceJoint.transform.position);
            destJoint.gameObject.transform.position = dest.transform.position + source.transform.InverseTransformPoint(sourceJoint.gameObject.transform.position);
            //destJoint.gameObject.GetComponent<StretchTo>().RecalculateStart();
            //destJoint.gameObject.GetComponent<StretchTo>().RunStretch();
            //destJoint.lastPosition = sourceJoint.lastPosition;
            //destJoint.velocity = sourceJoint.velocity;
            ////public List<Vector2> targetPositions;
            //destJoint.tOffset = sourceJoint.tOffset;
        }

        //dest.t = source.t;
    }
예제 #2
0
    public void SetNurseDanglingFromMecha()
    {
        Transform tentAttachPoint = nurse.transform.Find("TentacleAttachPoint");

        nurseTentacle.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        nurseRippedTentacle.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);

        nurseTentacle.pullLength = 7f;
        nurseTentacle.length     = 5f;
        nurseTentacle.SetGrabbing(mechHand, mechHand.transform.position);
        nurseTentacle.AttachEnd(mechHand.GetComponent <Rigidbody2D>(), mechHand.transform.position);
        nurseTentacle.ClearSegments();
        nurseTentacle.GenerateSegments();

        Rigidbody2D nurseBody = nurse.GetComponent <Rigidbody2D>();

        nurseBody.mass = 30.0f;

        nurseRippedTentacle.AttachEnd(nurseBody, nurse.transform.position);

        nurse.transform.position = mechHand.transform.position;
        //nurseTentacle.basePoint.transform.position = nurse.transform.position;
        nurseTentacle.TeleportToBase();

        nurseTentacle.endPoint.transform.position = mechHand.transform.position;
    }
예제 #3
0
    public static void CopyTentSubSegments(Tentacle source, Tentacle dest, int start, int end)
    {
        //if (start < 0 || end > source.segments) {
        //	throw new Exception("Can't make a sub segment with these bounds.");
        //}
        dest.ClearSegments();

        dest.segments         = end - start + 1;
        dest.pack             = source.pack;
        dest.alternateSprites = source.alternateSprites;
        float width_dif = source.endWidth - source.startWidth;

        dest.startWidth = source.startWidth + width_dif * ((float)start / (float)source.segments);
        dest.endWidth   = source.startWidth + width_dif * ((float)end / (float)source.segments);
        dest.length     = source.length * ((float)dest.segments / (float)source.segments);

        dest.GenerateSegments();

        if (start > 0)
        {
            dest.transform.position = source.tentJoints[start - 1].transform.position;
        }
        else
        {
            dest.transform.position = source.transform.position;
        }
        if (end < source.segments - 1)
        {
            dest.endPoint.position = source.tentJoints[end].transform.position;
        }
        else
        {
            dest.endPoint.position = source.endPoint.position;
        }
        dest.baseSegment.transform.localPosition = Vector2.zero;

        for (int i = 0; i < dest.tentJoints.Count; i++)
        {
            TentJoint destJoint   = dest.tentJoints[i];
            TentJoint sourceJoint = source.tentJoints[i + start];

            destJoint.transform.position = sourceJoint.transform.position;

            //destJoint.transform.position = dest.transform.position + source.transform.InverseTransformPoint(sourceJoint.transform.position);
            //destJoint.gameObject.transform.position = dest.transform.position + source.transform.InverseTransformPoint(sourceJoint.gameObject.transform.position);
            //destJoint.lastPosition = sourceJoint.lastPosition;
            //destJoint.velocity = sourceJoint.velocity;
            ////public List<Vector2> targetPositions;
            //destJoint.tOffset = sourceJoint.tOffset;
        }

        //dest.AdjustJoints();


        //dest.t = source.t;
    }
예제 #4
0
    public static Tentacle Basic(TentaclePack pack, float length = 10)
    {
        Tentacle tentComp = Ungenerated();

        tentComp.pack             = pack;
        tentComp.alternateSprites = true;

        tentComp.length         = length;
        tentComp.segments       = (int)(length * 2);
        tentComp.pullLength     = 0;
        tentComp.jointWeight    = 0.16f;
        tentComp.jointDrag      = 0.9f;
        tentComp.useWiggle      = true;
        tentComp.wiggleStrength = 0.16f;
        tentComp.wiggleSpeed    = 1.0f;
        tentComp.startWidth     = 1.2f;
        tentComp.endWidth       = 0.5f;
        tentComp.GenerateSegments();

        return(tentComp);
    }