Example #1
0
    //Enabling the game to set the variable currentBlock to this gameobject

    private void OnEnable()
    {
        if (LastBlock == null)
        {
            //this makes it so the lastBlock becomes the gameobject 'Stack'
            LastBlock = GameObject.Find("Stack").GetComponent <StartingBlock>();
        }
        CurrentBlock = this;

        //OnEnable starts the local scale of the current cube to these set of parameters
        transform.localScale = new Vector3(LastBlock.transform.localScale.x, transform.localScale.y, LastBlock.transform.localScale.z);
    }
Example #2
0
    //if the confirm button is clicked
    public void Confirm()
    {
        print("Confirm Setup");
        foreach (GameObject StartingBlock in FindObjectsOfType <GameObject>())
        {
            if (StartingBlock.name == "Starting Block")
            {
                StartingBlock.GetComponent <Push>().Setup = true;
                StartingBlock.GetComponent <Push>().Fixed = true;
            }
        }
        //GameObject.Find("Starting Block").GetComponent<Push>().Setup = true;//Make the starting block able to be push
        //GameObject.Find("Starting Block").GetComponent<Push>().Fixed = true;//Make the sets unable to removed
        WinningDetector.SetActive(true); //Active Winning Detect

        /*GameObject[] Sets = GameObject.FindGameObjectsWithTag("Set");
         * Debug.Log(Sets.Length);
         * for (int i = 0; i < Sets.Length; i++)
         * {
         *      Sets[i].GetComponent<MeshCollider>().enabled = false;
         * }*/                           //Disable the collider of domino sets

        GameObject[] Dominos = GameObject.FindGameObjectsWithTag("Domino");
        //Debug.Log(Dominos.Length);
        for (int i = 0; i < Dominos.Length; i++)
        {
            Dominos[i].GetComponent <MeshCollider>().enabled  = true;
            Dominos[i].GetComponent <Rigidbody>().isKinematic = false;
            //Dominos[i].GetComponent<MouseMoverSnap>().Fixed = true;
        }        //Enable physics of dominos

        GameObject[] Bricks = GameObject.FindGameObjectsWithTag("Brick");
        //Debug.Log(Bricks.Length);
        for (int i = 0; i < Bricks.Length; i++)
        {
            Bricks[i].GetComponent <MeshCollider>().enabled  = true;
            Bricks[i].GetComponent <Rigidbody>().isKinematic = false;
        }

        GameObject[] UIs = GameObject.FindGameObjectsWithTag("UI");
        //Debug.Log(UIs.Length);
        for (int i = 0; i < UIs.Length; i++)
        {
            Destroy(UIs[i]);
        }        //Remove UI
    }
Example #3
0
    //This method is calling the Stop() method when the startingblock collides with the stack
    //onTrigger the Stop() method will be called and the block will be trimmed, aswell as the verticalmovement will be set to 0

    private void OnTriggerEnter2D(Collider2D other)
    {
        //calls upon the currentBlock and calls the stop method onto it
        if (other.gameObject.tag == "WallRight" || other.gameObject.tag == "WallLeft")
        {
            return; //Do nothing
        }
        if (other.gameObject.tag == "Obstacle")
        {
            return; //Do nothing
        }
        if (other.gameObject.tag == "Floor")
        {
            GameManager.gameManager.gameOver = true;
        }
        if (other.gameObject.tag == "Spike")
        {
            GameManager.gameManager.playDestroySound     = true;
            GameManager.gameManager.collidedWithObstacle = true;
            GameManager.gameManager.ResetCombo();
        }
        if (other.gameObject.tag == "Stack")
        {
            //this is done so that it checks for a single collision, and doesnt let more happen
            if (colliding == 0)
            {
                CurrentBlock.Stop();
                _verticalMovement = 0;

                //makes the currentblock into the lastblock after it is placed so that we can switch between the blocks
                //gives the block the tag 'Stack' after it is placed
                gameObject.tag = "Stack";
                LastBlock      = CurrentBlock;
                gameManager.ComboLifeSystem();
                gameManager.DifficultyProgression();
                //sets the hasStacked boolean to true
                hasStacked = true;
                colliding++;
                StartCoroutine(Reset());
                //calls the coroutine to reset the colliding integer to zero
            }
        }
    }
Example #4
0
 private void Awake()
 {
     audioSource = GetComponent <AudioSource>();
     gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
     stackBlock  = GameObject.FindWithTag("Stack").GetComponent <StartingBlock>();
 }
Example #5
0
 public object ToJson()
 {
     return(!IsSynching ? "false" : (object)new { startingBlock = StartingBlock.ToJson(), currentBlock = CurrentBlock.ToJson(), highestBlock = HighestBlock.ToJson() });
 }