示例#1
0
    void Update()
    {
        ScoreText.text = "Score: " + Score;

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(0);
        }
        if (Input.GetKeyDown(KeyCode.F) && SavedPiece == null)
        {
            SavedPiece        = ControlledPiece;
            tempPieces.Placed = true;
            ControlledPiece.SetActive(false);
        }
        else if (Input.GetKeyDown(KeyCode.F) && SavedPiece != null)
        {
            Destroy(ControlledPiece);
            ControlledPiece = SavedPiece;
            tempPieces      = ControlledPiece.GetComponent <Pieces>();
            SavedPiece      = null;

            ControlledPiece.transform.position             = new Vector3(0, 12, 0);
            ControlledPiece.GetComponent <Pieces>().Placed = false;
            ControlledPiece.SetActive(true);
            StartCoroutine(tempPieces.Descend(0));
        }

        if (tempPieces.Placed)
        {
            int i = Random.Range(0, Pieces.Count);
            ControlledPiece = Instantiate(Pieces[i], Spawner.transform.position, Spawner.transform.rotation);
            tempPieces      = ControlledPiece.GetComponent <Pieces>();
        }
    }
示例#2
0
    public IEnumerator ReCheck()
    {
        yield return(new WaitForSeconds(0f));

        SeesOne             = false;
        IsSelf              = false;
        piecesScript.Refall = true;

        if (!piecesScript.LostOne)
        {
            RaycastHit BottomHit;
            Debug.DrawRay(transform.position, -Vector3.up, Color.red);

            if (Physics.Raycast(transform.position, -Vector3.up, out BottomHit, 0.75f) && BottomHit.collider.gameObject.GetComponentInParent <Pieces>().Placed)
            {
                Sighted = true;

                foreach (GameObject Block in piecesScript.BlockParts)
                {
                    if (BottomHit.collider.gameObject == Block)
                    {
                        IsSelf = true;
                    }
                }
            }
            else
            {
                Sighted = false;
            }

            if (!IsSelf && Sighted)
            {
                SeesOne = true;
            }
            else if (!Sighted)
            {
                SeesOne = false;
                StartCoroutine(piecesScript.Descend(0));
            }

            if (SeesOne)
            {
                piecesScript.Refall = false;
            }
            if (SeesOne && !IsSelf)
            {
                Landing.Play();
            }
        }
        else
        {
            RaycastHit BottomHit2;
            Debug.DrawRay(transform.position, -Vector3.up, Color.red);

            if (Physics.Raycast(transform.position, -Vector3.up, out BottomHit2, 0.75f))
            {
                StopCoroutine(piecesScript.Descend(0));
                piecesScript.AllClear = false;
            }
            else
            {
                piecesScript.AllClear = true;
                transform.position    = new Vector3(Xpos, Ypos - 1, Zpos);
                StartCoroutine(ReCheck());
            }
        }
    }