예제 #1
0
    void Start()
    {
        tetraminoLoader = FindObjectOfType <TetraminoLoader>();
        gridManager     = FindObjectOfType <GridManager>();
        blockParent     = this.GetComponent <BlockParent>();

        StartCoroutine(ProcessConstantVerticalDescent());
        StartCoroutine(ProcessHorizontalMovement());
        StartCoroutine(ProcessRotationalMovement());
    }
예제 #2
0
 void SpawnNew()
 {
     if (!hasBlock) //not holding holding
     {
         GameObject block = Instantiate(blockTypes[Random.Range(0, blockTypes.Count)], transform.position, Quaternion.identity);
         reference = block.GetComponent <BlockParent>();
         block.GetComponent <BlockParent>().spawn = this;
         GridManager.instance.currentBlocks.Add(block.GetComponent <BlockParent>()); //adds to the current block list on the grid manager
         block.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     }
     isReady  = false;
     hasBlock = true;
 }
예제 #3
0
    public void New()
    {
        GridManager.instance.currentBlocks.Remove(reference);
        Destroy(reference.gameObject);

        GameObject block = Instantiate(blockTypes[Random.Range(0, blockTypes.Count)], this.transform.position, Quaternion.identity);

        reference       = block.GetComponent <BlockParent>();
        reference.spawn = this;
        GridManager.instance.currentBlocks.Add(reference); //adds to the current block list on the grid manager
        block.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);

        GridManager.instance.CheckForMoves();
        GridManager.instance.CheckForGameOver();
    }
예제 #4
0
    bool CheckAgainstProfile(int x, int y, BlockParent block)
    {
        foreach (Vector2 current in block.blockProfile)
        {
            if (OutOfBounds(x + (int)current.x, 0, 9) || OutOfBounds(y + (int)current.y, 0, 9))
            {
                return(false);
            }

            if (!slots[x + (int)current.x, y + (int)current.y].isEmpty)
            {
                return(false);
            }
        }

        return(true);
    }
예제 #5
0
 // Start is called before the first frame update
 public virtual void Start()
 {
     parent = GetComponentInParent <BlockParent>();
     game   = FindObjectOfType <Level>().gameState;
 }