Exemple #1
0
    //public Vector2 targetPosition;

    public void Initialize(Tentacle parent, int index)
    {
        parentTentacle = parent;
        this.index     = index;
        tOffset        = (float)index / (float)parentTentacle.segments * Mathf.PI * 2.0f;

        //myRigidBody = gameObject.AddComponent<Rigidbody2D>();
        //myRigidBody.bodyType = RigidbodyType2D.Kinematic;
        //myRigidBody.gravityScale = 0;

        float w = parentTentacle.GetTentSegmentWidth(index);

        GameObject stretchSegment = Object.Instantiate(parentTentacle.GetTentSegmentPrefab(index), transform);

        stretchSegment.name = string.Format("Segment {0}", index);
        stretchSegment.transform.localScale    = new Vector3(1.0f, w, 1.0f);
        stretchSegment.transform.localPosition = Vector2.zero;
        stretchTo = stretchSegment.GetComponent <StretchTo>();

        GameObject roundSegment = Object.Instantiate(parent.pack.tentacleSpriteRounderPrefab, transform);

        roundSegment.name = string.Format("Rounder {0}", index);
        roundSegment.transform.localScale    = new Vector3(w, w, 1.0f);
        roundSegment.transform.localPosition = new Vector3(0, 0, 1);

        lastPoint = parentTentacle.GetTentSegmentLastPoint(index);
        nextPoint = parentTentacle.endPoint;
        parentTentacle.UpdateTentSegmentNextPointMaybe(this);
    }