Exemplo n.º 1
0
    public void SoftDrop()
    {
        // Modify position
        transform.position += new Vector3(0, -1, 0);

        // See if valid
        if (IsValidGridPos())
        {
            // It's valid. Update grid.
            score.GetComponent <ScoreBehaviour>().AddToScore(1);
            updateGrid();
            canMoveDown = false;
            Invoke("DelayMoveDown", mainSpeed * 0.078f);
            CheckLastStep();
            keepBeforeHardDrop = false;
        }
        else if (keepBeforeHardDrop == false)
        {
            keepBeforeHardDrop = true;
            canMoveDown        = false;
            Invoke("DelayMoveDownBeforeHardDrop", 0.75f);
            // It's not valid. revert.
            transform.position += new Vector3(0, 1, 0);
        }
        else
        {
            keepBeforeHardDrop       = false;
            lockDelay                = mainSpeed;
            transform.gameObject.tag = "DeadGroup";
            // It's not valid. revert.
            transform.position += new Vector3(0, 1, 0);
            CheckTSpin();
            if (GridBehavior.CheckIfFullRows() > 0)
            {
                Invoke("OnDropDown", 0.0f);
            }
            else
            {
                Invoke("OnDropDown", 0.0f);
            }

            // Disable script
            isDown = true;
            if (particles != null)
            {
                Instantiate(particles, transform.position, particles.transform.rotation);
            }
            audios[2].Play();
        }
        lastFall = Time.time;
    }
Exemplo n.º 2
0
    public void HardDrop()
    {
        bool end = false;

        keepBeforeHardDrop = false;
        ghostLine.HardDrop();
        while (end == false)
        {
            // Modify position
            transform.position += new Vector3(0, -1, 0);

            // See if valid
            if (IsValidGridPos())
            {
                // It's valid. Update grid.
                score.GetComponent <ScoreBehaviour>().AddToScore(2);
                updateGrid();
            }
            else
            {
                lockDelay = mainSpeed;
                // It's not valid. revert.
                transform.position += new Vector3(0, 1, 0);
                CheckTSpin();
                if (GridBehavior.CheckIfFullRows() > 0)
                {
                    Invoke("OnDropDown", 0.0f);
                }
                else
                {
                    Invoke("OnDropDown", 0.0f);
                }

                // Disable script
                isDown = true;
                transform.gameObject.tag = "DeadGroup";
                end = true;
                if (particles != null)
                {
                    Instantiate(particles, transform.position, particles.transform.rotation);
                }
                audios[2].Play();
                score.GetComponent <ScoreBehaviour>().AddToScore(2);
            }
        }
    }