public IEnumerator spawnBorder(GridDevil gridder) { yield return(new WaitForFixedUpdate()); ChainDelegate f = o => { o.name = "border"; o.transform.parent = transform; return(true); }; nextSpawnOffset = gridder.gridBaseLowerLeft; nextSpawnOffset.x = nextSpawnOffset.x - 1; GameObject border = makeBlock(gridder.grid_height - 1, spawnOffset, borderColor); doAcrossChain(f, border); nextSpawnOffset.x = nextSpawnOffset.x + 1 + gridder.grid_width; border = makeBlock(gridder.grid_height - 1, spawnOffset, borderColor); doAcrossChain(f, border); nextSpawnOffset.y = nextSpawnOffset.y - 1; border = makeBlock(11, new Vector3(-1f, 0f, 0f), borderColor); doAcrossChain(f, border); reset(gridder.grid_height); yield return(null); }
public Row(GridDevil parent, Vector3 rowBase) { cellCount = parent.grid_width; cells = new GameObject[cellCount]; contents = new GameObject[cellCount]; Transform nextParent = parent.transform; for (int h = 0; h < parent.grid_width; ++h) { rowBase.x = h; cells[h] = parent.createGridCell(rowBase); cells[h].transform.parent = nextParent; nextParent = cells[h].transform; } baseTransform = cells[0].transform; }
public IEnumerator startBlock(LevelDevil level, ThingToDo nextThing) { yield return(new WaitForFixedUpdate()); GameObject block = makeBlock(3, spawnOffset, blockColors[nextSpawnRow]); float dropRate; bool vertical = true; Vector3 newPosition; int leftRightMove; GameObject top = getBlockParent(getBlockParent(getBlockParent(block))); GridDevil gridder = level.gridder; InputDevil player = level.player; nextSpawnRow = (nextSpawnRow + 1) % gridder.grid_width; nextSpawnOffset.x = nextSpawnRow; while (gridder.checkRange(top.transform.position, 4, vertical ? Vector3.up : Vector3.right)) { dropRate = regularDropRate * level.speed; if (player.checkOngoing(Signals.DROP)) { dropRate += fastDropRate; } dropRate = Mathf.Clamp(dropRate, .1f, maxDropRate); top.transform.Translate(0f, -dropRate, 0f); if (player.checkStarting(Signals.ROTATE) && (gridder.checkRange(top.transform.position, 4, !vertical ? Vector3.up : Vector3.right))) { if (doAcrossChain(tryRotateChain, block)) { level.logger.log(2.5f, "rotate worked"); vertical = !vertical; } } yield return(null); leftRightMove = 0; if (player.checkStarting(Signals.RIGHT)) { ++leftRightMove; } if (player.checkStarting(Signals.LEFT)) { --leftRightMove; } if (leftRightMove == 0) { continue; } newPosition = top.transform.position; newPosition.x += leftRightMove; newPosition.y += 0.6f; if (gridder.checkRange(newPosition, 4, vertical ? Vector3.up : Vector3.right)) { top.transform.Translate(leftRightMove, 0f, 0f); } } if (doAcrossChain(gridder.fixBlock, block)) { nextThing = gridder.cleanupRows; } level.nextThing = nextThing; yield return(null); }