Ejemplo n.º 1
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "floor" || collision.gameObject.tag == "shadow")
     {
         if (n < 1)
         {
             Not_Tetris.SpawnNewTetramino();
             //this.tag = "floor";
             this.tag        = "shadow";
             rb.gravityScale = 1;
             this.enabled    = false;
             n++;
         }
     }
 }
Ejemplo n.º 2
0
    public IEnumerator ClearLine()
    {
        yield return(new WaitUntil(() => ready == true));

        yield return(new WaitForSeconds(.5f));

        // Time.timeScale = 0;

        for (int i = 0; i < toDelete.Count; i++)
        {
            try
            {
                toDelete[i].layer = 10;
            }
            catch (Exception e) { Debug.Log(e); }
        }

        for (int i = 0; i < toEnable.Count; i++)
        {
            if (toEnable[i].transform != null && toEnable[i].GetComponent <Rigidbody2D>() != null)
            {
                toEnable[i].GetComponent <Rigidbody2D>().isKinematic = false;
            }
        }

        list.Clear();
        intersectionSegments.Clear();
        toDelete.Clear();
        toEnable.Clear();

        squareArea  = 0;
        ready       = false;
        requareOnce = 0;

        sp.enabled = false;
        SetFillingLine();
        current.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;

        Not_Tetris.Score += Mathf.RoundToInt(10 * squareArea);
        Not_Tetris.Lines += 1;
        Not_Tetris.UpdateUI();
    }