// Start is called before the first frame update void Start() { // Where the Custom Routine data should be located CUSTOM_DATA_PATH = Application.persistentDataPath + "/CustomRoutineData.txt"; // If we have the main game music destroy it GameObject oldMusic = GameObject.Find("KeepMusic"); if (oldMusic != null) { Destroy(oldMusic.gameObject); } // Delete old info about the custom routine if (File.Exists(CUSTOM_DATA_PATH) == true) { File.Delete(CUSTOM_DATA_PATH); } // The position that the buttons will go to when transitioning forwordPos = new Vector3(-.3f, 1.55f, .861f); backPos = new Vector3(-.3f, 1.55f, 1.2f); buttonTimer = float.PositiveInfinity; // Active all button sets so we can get their components for (int i = 0; i < buttonSet.Length; i++) { if (buttonSet[i] != null) { buttonSet[i].SetActive(true); } } // Get control objects gymAndSongSelectControl = buttonSet[1].transform.Find("GymSongSelect").GetComponent <GymAndSongSelectControl>(); gymSongStart = buttonSet[1].transform.Find("Start").GetChild(0).GetComponent <MainMenuButton>(); gymSongBack = buttonSet[1].transform.Find("Back").GetChild(0).GetComponent <MainMenuButton>(); dailyChallengeControl = buttonSet[2].transform.GetChild(0).GetComponent <DailyChallengeMaster>(); customRutineControl = buttonSet[3].transform.GetChild(0).GetComponent <CustomRutineButtonOptionsMaster>(); gameModeSelector = buttonSet[4].transform.GetChild(0).GetComponent <WorkOutSelectControl>(); levelLoader = GameObject.Find("MainMenuLevelLoader").GetComponent <MainMenuLevelLoader>(); levelToLoad = -1; GameObject.Find("MainMenuMusic").GetComponent <MusicVolumeControl>().AudioSetUp(); // Set up to display the main menu (and deactivate all the others) this.ActivateButtonSet("MainMenu"); // Make sure weight is set properly if (PlayerPrefs.GetInt("PlayerWeight") == 0) { PlayerPrefs.SetInt("PlayerWeight", 160); } AchivmentAndStatControl.CheckAllAchivments(); }
/// <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; } } } }
// Use this for initialization void Start() { if (PlayerPrefs.GetInt(Constants.gameMode) != Constants.gameModeArcade) { Destroy(this.gameObject); return; } highScoreText = this.transform.Find("HighScoreNumber").GetComponent <TextMeshPro>(); yourScoreText = this.transform.Find("YourScoreNumber").GetComponent <TextMeshPro>(); highScoreText.text = AchivmentAndStatControl.GetStat(Constants.highScore).ToString(); yourScoreText.text = currentScore.ToString(); }
// 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); } }
// Start is called before the first frame update void Start() { // Error message to be changed if we connect to steam string statSummary = "Error connecting to Steam stats, try relaunching Steam..."; // If we connect to steam fill out with stats if (SteamManager.Initialized == true) { statSummary = "Total Squat Walls Passed: " + AchivmentAndStatControl.GetStat(Constants.totalSquatWallCount) + "\n"; statSummary += "Classic Mode Highest Consecutive Squats: " + AchivmentAndStatControl.GetStat(Constants.highestSquatConsec) + "\n"; statSummary += "Total Cardio Walls Passed: " + AchivmentAndStatControl.GetStat(Constants.totalCardioWallCount) + "\n"; statSummary += "Classic Mode Highest Consecutive Cardio Walls: " + AchivmentAndStatControl.GetStat(Constants.highestCardioConsec) + "\n"; statSummary += "Number of Daily Challenges Completed: " + AchivmentAndStatControl.GetStat(Constants.totalDailyChallenges) + "\n"; statSummary += "Number of Custom Routines Played: " + AchivmentAndStatControl.GetStat(Constants.totalCustomRoutines) + "\n"; statSummary += "Punching Bag Hits: " + AchivmentAndStatControl.GetStat(Constants.punchingBagPunches) + "\n"; statSummary += "Arcade Mode High Score: " + AchivmentAndStatControl.GetStat(Constants.highScore); } statText.text = statSummary; }
/// <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()); } }
// Start is called before the first frame update void Start() { alpha = 1; if (this.transform.Find("Sprite") != null) { spriteRend = this.transform.Find("Sprite").GetComponent <SpriteRenderer>(); } else { spriteRend = this.transform.parent.Find("Sprite").GetComponent <SpriteRenderer>(); } if (forceUnlock == true && lockedUnlockedGloves.Length < 1) { unlocked = true; descTexts[0].text = unlockedDescString; return; } button = this.GetComponent <CosmeticSelectionButton>(); boxCol = this.GetComponent <BoxCollider>(); if (displayProgress == true) { if (this.transform.Find("StatsOutOf") != null) { statOutOfText = this.transform.Find("StatsOutOf").GetComponent <TextMeshPro>(); } else { statOutOfText = this.transform.parent.Find("StatsOutOf").GetComponent <TextMeshPro>(); } } if (SteamManager.Initialized == true) { bool steamAch = false; SteamUserStats.GetAchievement(achivName, out steamAch); if (steamAch == true || forceUnlock == true) { unlocked = true; descTexts[0].text = unlockedDescString; if (button != null) { button.enabled = true; } if (displayProgress == true) { statOutOfText.text = statMax + "/" + statMax; } spriteRend.sprite = lockedUnlockedSprite[1]; lockedUnlockedGloves[0].SetActive(false); lockedUnlockedGloves[1].SetActive(true); } else { if (button != null) { button.enabled = false; } if (boxCol != null) { boxCol.enabled = false; } if (displayProgress == true) { statOutOfText.text = AchivmentAndStatControl.GetStat(assocaitedStat) + "/" + statMax; } spriteRend.sprite = lockedUnlockedSprite[0]; lockedUnlockedGloves[0].SetActive(true); lockedUnlockedGloves[1].SetActive(false); } } }
// 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); } } } }
/// <summary> /// Destroy all walls and end the game /// </summary> public void EndGame(bool viaPauseMenu = false) { // If we have already done the ending stuff return out if (gameOver == true) { return; } //// If we are in classic mode, update the consecutive cardio //if (PlayerPrefs.GetInt(Constants.gameMode) == Constants.gameModeClassic) //{ // if (PlayerPrefs.GetInt(Constants.cardioMode) == 1) // { // // 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); // } // else // { // AchivmentAndStatControl.SetStat(Constants.highestSquatConsec, squatCardioScore); // (Will only update stat if larger) // AchivmentAndStatControl.CheckAllConsecutiveSquatAchivments(squatCardioScore); // } //} // Save Score if in classic mode or if in daily challenge if (PlayerPrefs.GetInt(Constants.gameMode) == Constants.gameModeClassic || PlayerPrefs.GetInt(Constants.gameMode) == Constants.gameModeDaily) { SteamLeaderBoardUpdater.UpdateLeaderBoard(squatCardioScore); } // If arcade, update based on the score if (PlayerPrefs.GetInt(Constants.gameMode) == Constants.gameModeArcade) { // Save score to steam leader board int currScore = highScore.GetYourScore(); SteamLeaderBoardUpdater.UpdateLeaderBoard(currScore); AchivmentAndStatControl.SetStat(Constants.highScore, currScore); // Dont enable the player score pop up if (viaPauseMenu == false) { // Pop up the name select ArcadeNameSelector nameSelector = GameObject.Find("ArcadeNameSelector").GetComponent <ArcadeNameSelector>(); nameSelector.SetPlayerScore(currScore); nameSelector.SetToSize(); } // Prevent loading level so we can pick name GameObject.Find("GameModeMaster").GetComponent <GameModeMaster>().PreventLevelFromLoading = true; } if (GameObject.Find("GYM") != null) { Transform st = GameObject.Find("GYM").transform.Find("SquatTrack"); st.Find("SquatBars").GetComponent <GuideRail>().LowerRail(); st.Find("DoorA").GetComponent <SquatTrackDoor>().CloseDoor(); st.Find("DoorB").GetComponent <SquatTrackDoor>().CloseDoor(); } // Disable hand block so it doesnt get in your way this.EnableDisableHands(false); // Gib all walls this.DestroyAllWalls(!viaPauseMenu); // Let the arcade mode handle ending the game if we are in arcade mode GameModeMaster gameMaster = GameObject.Find("GameModeMaster").GetComponent <GameModeMaster>(); gameMaster.EndGame(); gameOver = true; }