Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        myBody = GetComponentInParent <Rigidbody2D>();

        leftIdle  = transform.Find("LeftIdle");
        rightIdle = transform.Find("RightIdle");

        for (int i = 0; i < tentaclesPerSide; i++)
        {
            Tentacle tentacle = TentacleMaker.Basic(pack, 9);
            tentacle.transform.parent        = transform;
            tentacle.transform.localPosition = Vector2.zero;
            tentacle.AttachBase(myBody, myBody.transform.position);
            tentacle.AttachEnd(myBody, RightIdlePosition());
            rightSideTentacles.Add(tentacle);
        }

        for (int i = 0; i < tentaclesPerSide; i++)
        {
            Tentacle tentacle = TentacleMaker.Basic(pack, 9);
            tentacle.transform.parent        = transform;
            tentacle.transform.localPosition = Vector2.zero;
            tentacle.AttachBase(myBody, myBody.transform.position);
            tentacle.AttachEnd(myBody, LeftIdlePosition());
            leftSideTentacles.Add(tentacle);
        }
    }
Exemplo n.º 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;
    }
Exemplo n.º 3
0
    public void AttachTentacleToNurse()
    {
        Transform tentAttachPoint = nurse.transform.Find("TentacleAttachPoint");

        tentacle.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        tentacleSecond.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        tentacleRipped.gameObject.SetActive(true);
        tentacleRipped.AttachBase(nurse.GetComponent <Rigidbody2D>(), tentAttachPoint.position);
        tentacleRipped.gameObject.SetActive(false);
        Transform tentIdle = nurse.transform.Find("Tentacle Idle");

        tentacle.AttachEnd(tentIdle.GetComponent <Rigidbody2D>(), tentIdle.position);

        Transform tentIdle2 = nurse.transform.Find("Tentacle Idle (1)");

        tentacleSecond.AttachEnd(tentIdle2.GetComponent <Rigidbody2D>(), tentIdle2.position);
    }
Exemplo n.º 4
0
    public static void SeverTentacle(Tentacle tentacle)
    {
        int severPoint = (int)Mathf.Ceil(tentacle.segments * Random.Range(0.2f, 0.5f));

        Tentacle baseHalf = Ungenerated();

        CopyTentSubSegments(tentacle, baseHalf, 0, severPoint);
        baseHalf.AttachBase(tentacle.connectBody);
        Transform endPoint = baseHalf.transform.Find("EndPoint");

        MakeEndDangling(endPoint);
        SpringJoint2D endSpringJoint = endPoint.GetComponent <SpringJoint2D>();

        endSpringJoint.connectedBody = tentacle.connectBody;
        endSpringJoint.distance      = tentacle.length * ((float)severPoint / (float)tentacle.segments) * 0.5f;

        Tentacle endHalf = Ungenerated();

        CopyTentSubSegments(tentacle, endHalf, severPoint, tentacle.segments - 1);
        MakeEndDangling(endHalf.transform);
        if (tentacle.Grabbing)
        {
            endHalf.AttachEnd(tentacle.endAttachSpring.connectedBody, tentacle.GetEndPosition());
        }
        else
        {
            Transform endHalfEndPoint = endHalf.transform.Find("EndPoint");
            MakeEndDangling(endHalfEndPoint);
            SpringJoint2D endHalfEndSpring = endHalfEndPoint.gameObject.GetComponent <SpringJoint2D>();
            endHalfEndSpring.enabled = false;

            Rigidbody2D endBody = endHalf.gameObject.GetComponent <Rigidbody2D>();
            endBody.gravityScale = 1;
            Rigidbody2D endPointBody = endHalfEndPoint.gameObject.GetComponent <Rigidbody2D>();
            endPointBody.gravityScale = 1;
        }
        SpringJoint2D spring = endHalf.gameObject.GetComponent <SpringJoint2D>();

        spring.connectedBody = endHalf.transform.Find("EndPoint").gameObject.GetComponent <Rigidbody2D>();
        spring.distance      = (tentacle.length - endSpringJoint.distance) * 0.5f;

        ExplosionManager.BloodSplatter(tentacle.tentJoints[severPoint].transform.position, 3, 0);

        tentacle.StopGrabbing();
        GameObject.Destroy(tentacle.gameObject);
    }