void PassOrFail() { if (levelPass && success == false) { // You succeeded! // Show success panel and mark as complete gameController.GetComponent <GameController>().passChallenge = true; success = true; faceController.SetHappyImage(99f); StartCoroutine(LevelCompleteCoroutine()); if (challengeNumber < 36) { PlayerPrefs.SetInt("Challenge_" + (challengeNumber + 1).ToString(), 1); } //challengeHighScore = PlayerPrefs.GetFloat("ChallengeScore_" + challengeNumber.ToString()); Debug.Log("Challenge High Score is: " + challengeHighScore); if (gameController.score > challengeHighScore) { PlayerPrefs.SetFloat("ChallengeScore_" + challengeNumber.ToString(), gameController.score); } // if score is higher than high score, mark in PlayerPrefs as the new high score } else if (levelFail && fail == false && gameController.lives > 0) { // GAME OVER BUDDY! // Exit and do NOT mark as complete fail = true; faceController.SetArghImage(99f); if (FistTable.instance.fistSpecial == 17) { gameController.CalculateFist20BonusCoins(); } gameController.GetComponent <GameController>().savedCoinScore += gameController.GetComponent <GameController>().coinScore; gameController.GetComponent <GameController>().bonusCoinScore++; //Get 1 coin for losing as long as you "tried" gameController.GetComponent <GameController>().savedCoinScore += gameController.GetComponent <GameController>().bonusCoinScore; PlayerPrefs.SetInt(GamePreferences.CoinScore, gameController.GetComponent <GameController>().savedCoinScore); gameOverController.GetComponent <GameOverController>().GameOver(); } }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && gameOver == false && lifeLost == false && gamePaused == false) { float tempX = Input.mousePosition.x / pixelsPerX; float tempY = Input.mousePosition.y / pixelsPerY; Debug.Log("TempY is: " + tempY); mouseX = tempX - (worldWidth / 2); // You COULD add Camera.main.transform.position.x but it is always 0 mouseY = tempY - (worldHeight / 2) + Camera.main.transform.position.y; if (tempY > 1.28f) //So you don't accidentally "punch" something below the status screen { InstantiateSocko(); } } if (lives <= 0 && gameOver == false) { gameOver = true; savedCoinScore += coinScore; if (FistTable.instance.fistSpecial == 17) { CalculateFist20BonusCoins(); } faceController.SetArghImage(99f); if (MasterControl.instance.set_difficulty == MasterControl.difficulty.CHALLENGE) { bonusCoinScore++; //Get 1 coin for losing as long as you "tried" savedCoinScore += bonusCoinScore; } if (MasterControl.instance.set_difficulty != MasterControl.difficulty.CHALLENGE) { CalculateBonusCoins(); savedCoinScore += bonusCoinScore; } PlayerPrefs.SetInt(GamePreferences.CoinScore, savedCoinScore); if (score > highScore) { SetHighScore(); } if (MasterControl.instance.scoreAttack && score > highScoreScoreAttack) { SetHighScoreScoreAttack(); } gameOverController.GameOver(); } //For fist specials 12 (100000 = 1 life), 14 (50000 = 1 life), and 15 (every 25000 = 1 life) if (score >= 100000f && collectedLifeWithFistSpecial14 == false && FistTable.instance.fistSpecial == 14) { collectedLifeWithFistSpecial14 = true; lives++; UpdateLives(); } else if (score >= 50000f && collectedLifeWithFistSpecial12 == false && FistTable.instance.fistSpecial == 12) { collectedLifeWithFistSpecial12 = true; lives++; UpdateLives(); } else if (score >= extraLifeForFist24 && extraLifeForFist24 < 1000000f && FistTable.instance.fistSpecial == 15) { extraLifeForFist24 += extraLife25000; lives++; UpdateLives(); } }