void FixedUpdate (){ if (isBlockingGUIInput) { if (++isBlockingGUIInputCounter == isBlockingGUIInputPeriod) isBlockingGUIInput = false; } beaconCounter++; if (beaconCounter >= beaconPeriod) beaconCounter = 0; if (!started) { livesArray.setLives(livesLeft); if (!isQuickGame) { readStack (); for (int i=0; i<10; i++) tilesArray [i].GetComponent<TilesArray> ().loadPuzzle (); started = true; isStartingAnimation = true; startAnimationCounter = 0; levelIndicators [0].GetComponent<LevelIndicator> ().setCurrent (); if (!isTutorial) summaryLevelIndicators [0].GetComponent<LevelIndicator> ().setSkipped (); Global.isGameActive = true; toggleStackOrder (); } else { isStartingAnimation = true; started = true; tilesArray [0].GetComponent<TilesArray> ().newRandomPuzzle (3); tilesArray [0].GetComponent<TilesArray> ().loadPuzzle (); tilesArray [1].GetComponent<TilesArray> ().newRandomPuzzle (3); tilesArray [1].GetComponent<TilesArray> ().loadPuzzle (); toggleZoom (); levelIndicators [0].GetComponent<LevelIndicator> ().setCurrent (); Global.isGameActive = true; showGUI (); activeTilesArray.bringForward (); activeTilesArray.resetPuzzle (); toggleStackOrder (); checkStack (); } } if (isStartingAnimation) { startAnimationCounter++; if (!isQuickGame) { cameraArray.transform.position = new Vector3 (0, -600 + 950 * startAnimationCounter / startAnimationPeriod, 0); if (startAnimationCounter == startAnimationPeriod) { isStartingAnimation = false; isFlashing = true; if ((!isZoomedIn && activeTilesArray.GetComponent<TilesArray> ().puzzle.isZoomedIn) || (isZoomedIn && !activeTilesArray.GetComponent<TilesArray> ().puzzle.isZoomedIn)) toggleZoom (); if (isTutorial) { tutorialText1.GetComponent<TextMesh>().text = "clicking on red affects the color of the surrounding tiles"; tutorialText1.GetComponent<TutorialText>().appear (); activeTilesArray.setTutorialHints(); } } if (startAnimationCounter < startAnimationPeriod * 0.9f) { guiRightPanel.transform.localPosition = new Vector3 (0, 180, 0); guiLeftPanel.transform.localPosition = new Vector3 (0, 180, 0); } else { if (!isShowingGUI) { showGUI (); } } for (int i=0; i<10; i++) if (startAnimationCounter == 10 * (i + 1) - 9) { tilesArray [9 - i].GetComponent<TilesArray> ().drawPuzzle (); if (i == 9) { activeTilesArray.bringForward (); activeTilesArray.resetPuzzle (); puzzleNumMoves = activeTilesArray.puzzle.size; puzzleStack [0] = activeTilesArray.stack [0]; puzzleStack [1] = activeTilesArray.stack [1]; puzzleStack [2] = activeTilesArray.stack [2]; checkStack (); } } } else { if (startAnimationCounter == startAnimationPeriod) isStartingAnimation = false; upperLight.GetComponent<Light> ().intensity = startAnimationCounter / startAnimationPeriod * 5.5f; } } if (isGoingToMenu) { cameraArray.transform.localPosition = new Vector3 (cameraArray.transform.localPosition.x, cameraArray.transform.localPosition.y + 20, cameraArray.transform.localPosition.z); supportingTilesArray.transform.localPosition = new Vector3 (0, 350 - 1000 * (1 - goingToMenuCounter / goingToMenuPeriod), 0); if (++goingToMenuCounter == goingToMenuPeriod) { if (isGoingToFirstLevel) Application.LoadLevel ("GameScene"); else if (isQuickGame || isTutorial) Application.LoadLevel ("MenuScene"); else Application.LoadLevel ("StackMenuScene"); isGoingToMenu = false; isGoingToFirstLevel = false; } } if (isRebuildingStack) { cameraArray.transform.position = Vector3.Lerp (rebuildingStartingLocation, rebuildingTargetLocation, rebuildingStackCounter / rebuildingStackPeriod); if (rebuildingStackCounter % rebuildingStackPeriodPerLevel == 0) { if (level > 0) { level--; tilesArray [level].GetComponent<TilesArray> ().rebuildStack (); } } rebuildingStackCounter++; if (rebuildingStackCounter > rebuildingStackPeriod) { livesLeft = Global.getGameLives(); livesArray.setLives(livesLeft); isRebuildingStack = false; showGUI (); activeTilesArray = tilesArray [0].GetComponent<TilesArray> (); activeTilesArray.resetPuzzleFromScratch (); activeTilesArray.bringForward (); for (int i=level+1; i<10; i++) tilesArray [i].GetComponent<TilesArray> ().setBack2 (activeTilesArray.puzzle.baseState); checkStack (); levelIndicators [0].GetComponent<LevelIndicator> ().setCurrent (); for (int i=1; i<10; i++) levelIndicators [i].GetComponent<LevelIndicator> ().setNull (); } } if (isShowingGUI) { showingGUICounter++; guiRightPanel.transform.localPosition = new Vector3 (0, 180 - 180 * showingGUICounter / showingGUIPeriod, 0); guiLeftPanel.transform.localPosition = new Vector3 (0, 180 - 180 * showingGUICounter / showingGUIPeriod, 0); if (showingGUICounter == showingGUIPeriod) isShowingGUI = false; } if (isHidingGUI) { hidingGUICounter++; guiRightPanel.transform.localPosition = new Vector3 (0, 180 * hidingGUICounter / hidingGUIPeriod, 0); guiLeftPanel.transform.localPosition = new Vector3 (0, 180 * hidingGUICounter / hidingGUIPeriod, 0); if (hidingGUICounter == hidingGUIPeriod) isHidingGUI = false; } if (isShowingGameSummary) { showingGameSummaryCounter++; gameSummary.transform.localPosition = new Vector3 (0, 10 - 195 * showingGameSummaryCounter / showingGameSummaryPeriod, 0); if (showingGameSummaryCounter == showingGameSummaryPeriod) isShowingGameSummary = false; } if (isHidingGameSummary) { hidingGameSummaryCounter++; gameSummary.transform.localPosition = new Vector3 (0, -185 + 195 * hidingGameSummaryCounter / hidingGameSummaryPeriod, 0); if (hidingGameSummaryCounter == hidingGameSummaryPeriod) { isHidingGameSummary = false; if (!isQuickGame) { gameSummary.GetComponent<GameSummary> ().hideGameSummary (); if (!isTutorial){ summaryLevelIndicators [0].GetComponent<LevelIndicator> ().setSkipped (); for (int i=1; i<10; i++) summaryLevelIndicators [i].GetComponent<LevelIndicator> ().setNull (); } } } } if (isShowingGameEndedScreen) { showingGameEndedScreenCounter++; gameEndedScreen.transform.localPosition = new Vector3 (0, 10 - 195 * showingGameEndedScreenCounter / showingGameEndedScreenPeriod, 0); if (showingGameEndedScreenCounter == showingGameEndedScreenPeriod) isShowingGameEndedScreen = false; } if (isHidingGameEndedScreen) { hidingGameEndedScreenCounter++; gameEndedScreen.transform.localPosition = new Vector3 (0, -185 + 195 * hidingGameEndedScreenCounter / hidingGameEndedScreenPeriod, 0); if (hidingGameEndedScreenCounter == hidingGameEndedScreenPeriod) isHidingGameEndedScreen = false; } if (isShowingPauseScreen) { showingPauseScreenCounter++; pauseScreen.transform.localPosition = new Vector3 (0, -175 * showingPauseScreenCounter / showingPauseScreenPeriod, 0); if (showingPauseScreenCounter == showingPauseScreenPeriod) isShowingPauseScreen = false; } if (isFlashing) { effectsLightArray.transform.position = new Vector3 (0, -600 + 3000 * flashCounter / flashPeriod, 0); flashCounter++; if (flashCounter == flashPeriod) flashCounter = 0; } if (isZoomingIn) { zoomCounter++; cameraArray.transform.localPosition = new Vector3 (cameraArray.transform.localPosition.x, 350 - level * 50 + 300 * (1 - zoomCounter / zoomPeriod), cameraArray.transform.localPosition.z); upperLight.transform.localPosition = new Vector3 (0, -100 - 300 * (1 - zoomCounter / zoomPeriod), 0); supportingTilesArray.transform.localPosition = new Vector3 (0, 350 - 1000 * (1 - zoomCounter / zoomPeriod), 0); if (zoomCounter == zoomPeriod) { isZoomingIn = false; isZoomedIn = true; } } if (isZoomingOut) { zoomCounter++; cameraArray.transform.localPosition = new Vector3 (cameraArray.transform.localPosition.x, 350 - level * 50 + 300 * (zoomCounter / zoomPeriod), cameraArray.transform.localPosition.z); upperLight.transform.localPosition = new Vector3 (0, -100 - 300 * (zoomCounter / zoomPeriod), 0); supportingTilesArray.transform.localPosition = new Vector3 (0, 350 - 1000 * (zoomCounter / zoomPeriod), 0); if (zoomCounter == zoomPeriod) isZoomingOut = false; } if (isOpeningMenu) { openMenuCounter++; if (openMenuCounter > openMenuPeriod) isOpeningMenu = false; } if (isAdvancingLevel) { advancingLevelCounter++; cameraArray.transform.localPosition = new Vector3 (cameraArray.transform.localPosition.x, cameraArray.transform.localPosition.y - 2, cameraArray.transform.localPosition.z); if (advancingLevelCounter == advancingLevelPeriod) { isAdvancingLevel = false; } } }
public void quickRebuild (){ level = 0; cameraArray.transform.position = rebuildingTargetLocation; isRebuildingStack = false; for (int i=0; i<10; i++) tilesArray [i].GetComponent<TilesArray> ().quickRebuildStack (); for (int i=1; i<10; i++) tilesArray [i].GetComponent<TilesArray> ().setBack2 (tilesArray[0].GetComponent<TilesArray>().puzzle.baseState); livesLeft = Global.getGameLives(); livesArray.setLives(livesLeft); showGUI (); activeTilesArray = tilesArray [0].GetComponent<TilesArray> (); activeTilesArray.resetPuzzleFromScratch (); activeTilesArray.bringForward (); checkStack (); levelIndicators [0].GetComponent<LevelIndicator> ().setCurrent (); for (int i=1; i<10; i++) levelIndicators [i].GetComponent<LevelIndicator> ().setNull (); }