protected IEnumerator SpawnBlock(GridScript gridScript, Grid grid, int count, BlockDefinition[] defs, float delay) { int i = 0; int countLeft = count; for (int y = grid.height - 3; y < grid.height; y++) { for (int x = Random.Range(0, 2); x < grid.width; x += 2) { if (countLeft > 0) { var bs = gridScript.Get(x, y); if (bs != null) { var b = bs.block; if (b.IsEmpty && b.IsBeingRemoved == false) { var defToUse = defs[i % defs.Length]; b.SetDefinition(defToUse, b.IsActive); b.SetFallPosition(4); b.FallMomentum = 0f; i++; countLeft--; yield return(new WaitForSeconds(delay)); } } } } } }
public virtual bool CanUsePower(GridScript gridScript, Grid grid) { // At least one block found for (int y = 0; y < gridScript.settings.height; y++) { var b = gridScript.Get(0, y); if (b != null && b.block.IsEmpty == false && b.block.IsBeingRemoved == false) { return(true); } } return(false); }