public IEnumerator loseGame(LevelDevil l, ThingToDo ignoredThing) { logger.log(0f, "lost!"); gameRunning = false; updateValence("TETRAZZO INFERNO", currentColor = badColor); nextThing = runLevel; //this might eventually lead to a stack overflow but no one should be playing more than one game of this anyway yield return(null); }
public IEnumerator winGame(LevelDevil l, ThingToDo ignoredThing) { gameRunning = false; if (score == maxScore) { updateValence("PERFECT PARADISE", currentColor = Color.white); } yield return(null); }
public IEnumerator runLevel(LevelDevil l, ThingToDo ignoredThing) { gameRunning = true; updateValence("TETRAZZO PARADISO", currentColor = goodColor); linesRemaining = lineTarget; nextThing = blocker.startBlock; gridder.clearGrid(); blocker.reset(gridder.grid_height); score = 0; maxScore = 0; while (gameRunning) { speed = 1 + (int)((((float)(lineTarget - linesRemaining) / (float)lineTarget)) * 10f); logger.log(3f, "next step: {0}", nextThing.Method); yield return(StartCoroutine(nextThing(this, loseGame))); if (linesRemaining <= 0) { nextThing = winGame; } } }
public IEnumerator cleanupRows(LevelDevil level, ThingToDo nextThing) { logger.log(1f, "cleanupRow"); int completeRows = 0; nextThing = level.blocker.startBlock; for (int r = 0; r < grid_height; r = r + 1) { if (checkRowCompletion(r)) { completeRows += 1; grid[r].clear(); } int targetRow = r + completeRows; while (targetRow > r && (targetRow < grid_height) && grid[targetRow].filledCells != 0) { if (checkRowCompletion(targetRow)) { completeRows += 1; grid[targetRow].clear(); targetRow = r + completeRows; continue; } logger.log(3f, "swap rows: {0} and {1}", r, targetRow); swapRows(r, targetRow); break; } } level.processClearedLines(completeRows); level.nextThing = nextThing; yield return(null); }
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); }