public void instantiateNewFormation(bool [,] grid)
    {
        var testGrid = new bool[5, 5]
        {
            { false, false, false, false, false },
            { false, false, false, false, false },
            { false, false, false, false, false },
            { true, false, false, false, false },
            { true, true, false, false, false },
        };

        if (counter % 5 == 0)
        {
            // timeBetweenMoveDowns -= 0.1f;
        }
        if (counter % 5 == 0)
        {
            SwitchPlayer();
        }
        // grid = null;
        var activeBlockForm = (GameObject)Instantiate(blockFormationPrefab, spawnPoint.position, Quaternion.identity);

        activeBlockFormation           = activeBlockForm.GetComponent <BlockFormation>();
        activeBlockFormation.startGrid = grid != null?activeBlockFormation.turnPieceRight(grid) : testGrid;

        counter++;
    }
Beispiel #2
0
    // Set to current captured block in trigger.
    public void CaptureBlock()
    {
        Block             CapturedBlockScript            = CapturedBlock.GetComponent <Block> ();
        SimpleFollow      CapturedBlockSimpleFollow      = CapturedBlock.GetComponent <SimpleFollow> ();
        Rigidbody         CapturedBlockRigidbody         = CapturedBlock.GetComponent <Rigidbody> ();
        ParentToTransform CapturedBlockParentToTransform = CapturedBlock.GetComponent <ParentToTransform> ();

        BlockFormation CapturedBlockParentBlockFormation = CapturedBlock.GetComponentInParent <BlockFormation> ();
        Rigidbody      CapturedBlockParentRigidbody      = CapturedBlock.GetComponentInParent <Rigidbody> ();

        if (CapturedBlockScript.isBossPart == false)
        {
            CapturedBlockRigidbody.isKinematic    = false;
            CapturedBlockScript.OverwriteVelocity = true;
            CapturedBlockScript.isStacked         = true;
            CapturedBlockScript.stack             = this;
            CapturedBlockRigidbody.velocity       = Vector3.zero;
            CapturedBlockSimpleFollow.enabled     = true;
            CapturedBlockSimpleFollow.FollowPosX  = transform;
            CapturedBlockSimpleFollow.FollowPosY  = transform;
            CapturedBlockSimpleFollow.FollowPosZ  = transform;
            isOccupied = true;

            if (stackSound.isPlaying == false)
            {
                stackSound.Play();
            }

            if (CapturedBlockParentBlockFormation != null &&
                CapturedBlockParentRigidbody != null)
            {
                CapturedBlockParentRigidbody.velocity = Vector3.zero;
                //CapturedBlockParentBlockFormation.enabled = false;
                CapturedBlockParentToTransform.ParentNow();
            }
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     parent = transform.parent.GetComponent <BlockFormation>();
 }