void Start() { tetraminoLoader = FindObjectOfType <TetraminoLoader>(); gridManager = FindObjectOfType <GridManager>(); blockParent = this.GetComponent <BlockParent>(); StartCoroutine(ProcessConstantVerticalDescent()); StartCoroutine(ProcessHorizontalMovement()); StartCoroutine(ProcessRotationalMovement()); }
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; }
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(); }
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); }
// Start is called before the first frame update public virtual void Start() { parent = GetComponentInParent <BlockParent>(); game = FindObjectOfType <Level>().gameState; }