float end_timer = 0; // used to delay level transition before win sound plays void ProcessCurrBlock() { Block currBlock = GetBlockBelow(alpaca.GetCurrAlpacaLocation()); if (currBlock == null) { return; } switch (currBlock.b_type) { case Block.BlockType.GATE: end_timer += Time.deltaTime; if (end_timer >= 0.2f) { currBlock.b_type = Block.BlockType.NONE; // stop processing this block sceneLoadController.LoadScene(currBlock.getCoords()); // Load next scene } break; // if(end_timer == 0) { // winSound.Play(); // } // end_timer += Time.deltaTime; // if(end_timer > 0.2f) { // // Update Farther Reached Level stat // if(PlayerPrefs.GetInt("LevelPassed") < level) { // PlayerPrefs.SetInt("LevelPassed", level); // } // // Wait for just a sec, then load next level // if(end_timer < 100f) { // end_timer = 999f; // if(level != numberOfLevels){ // scoreboardController.processFinalScore(level); // Debug.Log("T: " + PlayerPrefs.GetFloat("Level" + level+ "BestTime")); // Debug.Log("N: " + PlayerPrefs.GetInt("Level" + level + "BestNumMovesMade")); // Debug.Log("S: " + PlayerPrefs.GetFloat("Level" + level + "BestScore")); // SceneManager.LoadSceneAsync("B" + (level+1), LoadSceneMode.Single); // } // } // // While waiting, check if we're on the final level -- if yes load credits sequence instead. // else { // FinalWinBlockController final = gameObject.GetComponent<FinalWinBlockController>(); // if(final != null) final.BeatFinalLevel(); // currBlock.b_type = Block.BlockType.NONE; // stop processing this block // } // } //break; case Block.BlockType.GRASS: case Block.BlockType.MOVEABLE: // do nothing return; default: //Debug.Log("Alpaca is on a none block! // Can occur @ beating level"); return; } }
float end_timer = 0; // used to delay level transition before wind sound plays /** * Checks what block the alpaca is on currently and handles its logic. * (Dies for lava and wins for win block.) */ void ProcessCurrBlock() { Block currBlock = GetBlockBelow(alpaca.GetCurrAlpacaLocation()); if (currBlock == null) { return; } switch (currBlock.b_type) { case Block.BlockType.LAVA: alpaca.SetFlamed(); break; case Block.BlockType.WIN: if (end_timer == 0) { winSound.Play(); } end_timer += Time.deltaTime; if (end_timer > 0.25f) { if (level != GoHome.numLevels) { levelCompleteScreen.GetComponent <LevelCompleteScreen>().CompletedLevel(level, scoreboardController); levelCompleteScreen.SetActive(true); } else { scoreboardController.processFinalScore(level); FinalWinBlockController final = gameObject.GetComponent <FinalWinBlockController>(); if (final != null) { final.BeatFinalLevel(); } } // Update Farther Reached Level stat if (PlayerPrefs.GetInt("LevelPassed") < level) { PlayerPrefs.SetInt("LevelPassed", level); } currBlock.b_type = Block.BlockType.NONE; // stop processing this block } break; case Block.BlockType.GRASS: case Block.BlockType.MOVEABLE: // do nothing return; default: //Debug.Log("Alpaca is on a none block! // Can occur @ beating level"); return; } }
// Update is called once per frame void Update() { Vector3 alpacaPos = alpaca.GetCurrAlpacaLocation(); switch (step) { case 0: //approach shrub if (equals(alpacaPos, alpacaApproachLeft) || equals(alpacaPos, alpacaApproachRight)) { step += 1; arrowRight.active = false; } break; case 1: // hold to pick up if (equals(alpacaPos, alpacaApproachLeft) || equals(alpacaPos, alpacaApproachRight)) { approachShrub.active = false; arrowRight.active = false; if (equals(alpacaPos, alpacaApproachLeft) && alpaca.dir == FacingDirection.NE) { holdLeft.enabled = background.enabled = true; } else if (equals(alpacaPos, alpacaApproachRight) && alpaca.dir == FacingDirection.NW) { holdLeft.enabled = background.enabled = /*quadrant0.enabled =*/ true; } else { holdLeft.enabled = background.enabled = false; } } else if (!alpaca.HasBlock()) { approachShrub.active = true; arrowRight.active = true; holdLeft.enabled = background.enabled = false; } if (alpaca.HasBlock()) { step += 1; holdLeft.enabled = background.enabled = /*quadrant0.enabled =*/ false; // holdRight.enabled = quadrant1.enabled = false; } break; case 2: dropLeft.enabled = background.enabled = alpaca.HasBlock() && onEdge(alpacaPos, alpaca.dir); break; default: break; } }