Example #1
0
    public BrokenPiece SpawnBrokenPiece(GameObject parent, float pieceWidth, float pieceHeight)
    {
        GameObject holder = GameObject.Instantiate(pieceReference, Vector3.zero, Quaternion.identity);

        holder.transform.SetParent(parent.transform);

        BrokenPiece brokenPiece = holder.GetComponent <BrokenPiece> ();

        brokenPiece.SetSize(pieceWidth, pieceHeight);

        holder.SetActive(true);

        return(brokenPiece);
    }
Example #2
0
    void Awake()
    {
        this.clone         = GetComponentInChildren <BrokenClone> ();
        this.fractionLabel = GetComponentInChildren <BrokenFractionLabel> ();

        this.rectTransform = GetComponent <RectTransform> ();
        this.rigidBody2D   = GetComponent <Rigidbody2D> ();
        this.boxCollider   = GetComponent <BoxCollider2D> ();

        this.brokenPiece    = GetComponentInChildren <BrokenPiece> ();
        this.spriteRenderer = GetComponent <SpriteRenderer> ();
        this.lineRenderer   = GetComponent <LineRenderer> ();

        this.widthWhole  = this.rectTransform.rect.width;
        this.widthSingle = this.widthWhole / this.GetDenominator();
        this.widthPiece  = this.widthSingle * this.GetNumerator();
        this.height      = this.rectTransform.rect.height;

        this.fractionLabel.SetFraction((int)this.GetNumerator(), (int)this.GetDenominator());
    }