/// <summary> /// This will Spawn a wave of walls /// </summary> /// <param name="timeBetweenSpawns">Time in seconds between wall spawns</param> /// <param name="maxWallsPerWave">How many walls per wave</param> /// <param name="wallSpeed">How fast the walls move</param> /// <param name="allowedWalls">Array of what walls are allowed [0] = 1, [1] = 2, [2] = 3</param> private void SpawnWaveSquat(float timeBetweenSpawns, int maxWallsPerWave, float wallSpeed, bool[] allowedWalls, GameObject[] walls) { // If it has been long enough to spawn a new wave if (timer >= timeBetweenSpawns) { // Make and move wall GameObject wallClone = null; int wallCountToAdd = 0; while (wallClone == null) { // Set a random number to deiced if to make a multi wall or not rand = Random.Range(0, 9); if ((rand == 7 || rand == 8) && allowedWalls[2] == true) // Make a 3 long multi-wall { // Spawn correct wall at correct position, update how many walls have spawned Vector3 spawnPos = new Vector3(this.transform.position.x - .025f, this.transform.position.y - HEIGHT_UNDER_GROUND, this.transform.position.z - 1.5f); wallClone = (GameObject)Instantiate(walls[2], spawnPos, walls[2].transform.rotation); wallCountToAdd = 3; break; } if ((rand == 4 || rand == 5 || rand == 6) && allowedWalls[1] == true) // Make a 2 long multi-wall { Vector3 spawnPos = new Vector3(this.transform.position.x - .025f, this.transform.position.y - HEIGHT_UNDER_GROUND, this.transform.position.z - 1.95f); wallClone = (GameObject)Instantiate(walls[1], spawnPos, walls[1].transform.rotation); wallCountToAdd = 2; break; } if (allowedWalls[0] == true) // Make a normal wall { Vector3 spawnPos = new Vector3(this.transform.position.x - .025f, this.transform.position.y - HEIGHT_UNDER_GROUND, this.transform.position.z - 2.4f); wallClone = (GameObject)Instantiate(walls[0], spawnPos, walls[0].transform.rotation); wallCountToAdd = 1; break; } } // Add to respective counts wallSpawnCount += wallCountToAdd; if (waveSpawns[2] == true) { wallCountAfterWarmUp += wallCountToAdd; } this.StartWallMovment(wallClone, wallSpeed * wallSpeedMultiplier); // Start the movement of the wall timer = 0; // Reset timer for next spawn // Update the custom routine stat if we are in that mode and 10 walls have spawned (To avoid boosting) if (customRoutineStatCheck == true) { if (wallSpawnCount >= 10) { AchivmentAndStatControl.IncrementStat(Constants.totalCustomRoutines); customRoutineStatCheck = false; } } } }
private void OnTriggerEnter(Collider other) { if (other.tag == "HandCol") { AchivmentAndStatControl.IncrementStat(Constants.punchingBagPunches); AchivmentAndStatControl.CheckPunchingBagAchiv(); statWall.ReloadStats(); } }
private void SpawnWaveCardio(float timeBetweenSpawns, int maxWallsPerWave, float wallSpeed, bool[] allowedWalls, GameObject[] walls) { // If it has been long enough to spawn a new wave if (timer >= timeBetweenSpawns) { // Get the allowed wall count int tCount = 0; for (int i = 0; i < allowedWalls.Length; i++) { if (allowedWalls[i] == true) { tCount++; } } // Pick a new rand int rand = Random.Range(0, walls.Length); // If the allowed walls is more than 2 to save from getting stuck in the loop if (tCount > 1) { while (rand == lastRand || allowedWalls[rand] == false) { rand = Random.Range(0, 3); } lastRand = rand; } // Make and move wall // Spawn correct wall at correct position, update how many walls have spawned Vector3 spawnPos = new Vector3(this.transform.position.x - .025f, this.transform.position.y - HEIGHT_UNDER_GROUND, this.transform.position.z - 2.4f); GameObject wallClone = (GameObject)Instantiate(walls[rand], spawnPos, walls[rand].transform.rotation); // Add to respective counts wallSpawnCount++; if (waveSpawns[2] == true) { wallCountAfterWarmUp++; } this.StartWallMovment(wallClone, wallSpeed * wallSpeedMultiplier); // Start the movement of the wall timer = 0; // Reset timer for next spawn // Update the custom routine stat if we are in that mode and 10 walls have spawned (To avoid boosting) if (customRoutineStatCheck == true) { if (wallSpawnCount >= 10) { AchivmentAndStatControl.IncrementStat(Constants.totalCustomRoutines); customRoutineStatCheck = false; } } } }
// When level is loaded private void LevelLoaded(Scene level, LoadSceneMode sceneMode) { // Prevent weird behavior with routine if (this == null) { return; } // If we are in the main menu if (level.buildIndex == 1) { AchivmentAndStatControl.IncrementStat(Constants.totalCaloriesBurned, currCount); Destroy(this.gameObject); } }
/// <summary> /// Increment the score if it is the first time doing this daily challenge (one for squat and one for cardio) /// </summary> public void IncrementDailyChallengeStatIfNew() { // Get what player pref we are looking for (either cardio or squat) string playerPrefToFind = "DailySquatID"; if (PlayerPrefs.GetInt(Constants.cardioMode) == 1) { playerPrefToFind = "DailyCardioID"; } int savedDay = PlayerPrefs.GetInt(playerPrefToFind); int CurrentDay = DaySinceUnixTime.GetDaySinceUnixTime(); // If the player pref does not match the current day. It must be a new day, increment score if (savedDay != CurrentDay) { AchivmentAndStatControl.IncrementStat(Constants.totalDailyChallenges); PlayerPrefs.SetInt(playerPrefToFind, DaySinceUnixTime.GetDaySinceUnixTime()); } }
// If something hits the player void OnTriggerEnter(Collider other) { // For the normal game if (cardioMode == false) { // If its the Top of the wall reload level (Eventually explode boxes and show player high-score) if (other.name == "SquatWallUp") { this.CheckIfEndGame(); mostRecentWallType = "Fail"; // For sound Effects } // If its the bottom (squatted under the wall) increase the player score if (other.name == "SquatWallDown") { if (checkUp.Ready == true) { squatCardioScore++; tScore.text = squatCardioScore.ToString(); gameModeMaster.PassedThroughWall(false); // Save the total stat and check for achievements AchivmentAndStatControl.IncrementStat(Constants.totalSquatWallCount); int totalSquatStat = AchivmentAndStatControl.GetStat(Constants.totalSquatWallCount); if (totalSquatStat != -1) { AchivmentAndStatControl.CheckAllTotalSquatAchivments(totalSquatStat); } if (PlayerPrefs.GetInt(Constants.gameMode) == Constants.gameModeClassic) { AchivmentAndStatControl.SetStat(Constants.highestSquatConsec, squatCardioScore); // (Will only update stat if larger) AchivmentAndStatControl.CheckAllConsecutiveSquatAchivments(squatCardioScore); } // If it is a normal sized squat wall make the player stand back up right away if (other.transform.parent.parent == null || other.transform.parent.parent.name == "SquatWall(Clone)") { checkUp.Ready = false; mostRecentWallType = "Single"; // For sound Effects if (arcadeMode == true) { scoreConsecutiveCounter += 10; // Check if we got a combo, if we did it will display a combo, if not display what we just did if (this.TestHighScoreConsecCounter() == false) { scorePopper.PopScoreMessage(0, .04f); highScore.UpdateYourScore(10); } else { mostRecentWallType = "Combo"; // For sound Effects } } } else if (other.transform.parent.parent.name == "SquatWallx2(Clone)") // If squat wall is 2 long, allow 2 { mostRecentWallType = "Double"; // For sound Effects this.ResetAfterNumberOfWalls(2); } else // If squat wall is 3 long, allow 3 { mostRecentWallType = "Tripple"; // For sound Effects this.ResetAfterNumberOfWalls(3); } } else // Did not come up from a squat { this.CheckIfEndGame(); } } } else // For cardio mode { // If the player hits the wall if (other.name == "CardioWallSolid") { this.CheckIfEndGame(); } // If the player goes through the open spot if (other.name == "CardioWallOpen") { squatCardioScore++; tScore.text = squatCardioScore.ToString(); if (arcadeMode == true) { scoreConsecutiveCounter += 10; // Check if we got a combo, if we did it will display a combo, if not display what we just did if (this.TestHighScoreConsecCounter() == false) { scorePopper.PopScoreMessage(0, .04f); highScore.UpdateYourScore(10); } else { mostRecentWallType = "Combo"; // For sound Effects } } gameModeMaster.PassedThroughWall(true); // Save the total stat and check for achievements AchivmentAndStatControl.IncrementStat(Constants.totalCardioWallCount); int totalCardioStats = AchivmentAndStatControl.GetStat(Constants.totalCardioWallCount); if (totalCardioStats != -1) { AchivmentAndStatControl.CheckAllTotalCardioAchivments(totalCardioStats); } if (PlayerPrefs.GetInt(Constants.gameMode) == Constants.gameModeClassic) { // Check if we have reached any consecutive achievements and set stat AchivmentAndStatControl.SetStat(Constants.highestCardioConsec, squatCardioScore); // (Will only update stat if larger) AchivmentAndStatControl.CheckAllConsecutiveCardioAchivments(squatCardioScore); } } } }