public void AddToFruitDestroyedScore(int length = 0, bool correct = false) { //if the GameControllers "gameModes" var is set to GameModes.Classic then... if (GameController.GameControllerInstance.gameModes == GameModes.Classic) { //then ClassicModeScore gets incremented by 1 :-) if (!correct) { GameVariables.ClassicModeScore += length; } else { GameVariables.ClassicModeScore += length; TwoTimesScoreEffect tw = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); if (tw.twoTimesScoreIsOn) { GameVariables.ClassicModeScore += length; } } } ////if the GameControllers "gameModes" var is set to GameModes.Classic then... //if (GameController.GameControllerInstance.gameModes == GameModes.Classic) //{ // //then ClassicModeScore gets incremented by 1 :-) // GameVariables.ClassicModeScore++; //} //if the GameControllers "gameModes" var is set to GameModes.Relax then... if (GameController.GameControllerInstance.gameModes == GameModes.Relax) { //then RelaxModeScore gets incremented by 1 :-) GameVariables.RelaxModeScore++; } }
private int numOfTimesScoreTimesTwoLaunched; // the number of times that the Freeze Banana has been launched // Use this for pre-initialization void Awake() { //make sure our static LaunchController Instance is set to THIS gameObject LaunchControllerInstance = this; //our timer reference by calling GetComponent on THIS gameObject timer = GetComponent <CountdownTimer>(); //Use GameObjects FindObjectWithTag method to setup our references to the freeze,frenzy, and 2xScore objects/classes. Using our Const Strings in "Tags" freezeEffectReference = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>(); frenzyEffectReference = GameObject.FindGameObjectWithTag(Tags.frenzyEffectGameObjectTag).GetComponent <FrenzyEffect>(); twoTimesScoreEffectReference = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); //Use GameObjects FindObjectWithTag method to setup our references to the bottom and side fruitLaunchers. bottomFruitLaunchers = GameObject.FindGameObjectsWithTag(Tags.bottomFruitLaunchers); sideFruitLaunchers = GameObject.FindGameObjectsWithTag(Tags.sideFruitLaunchers); //Initialize the lists "bottomLaunchersScriptReference" && "sideLaunchersScriptReference" bottomLaunchersScriptReference = new List <FruitLauncher>(); sideLaunchersScriptReference = new List <FruitLauncher>(); //loop through all of the bottom fruit launchers for (int i = 0; i < bottomFruitLaunchers.Length; i++) { //now add each bottom fruit launcher to our List ("bottomLaunchersScriptReference") bottomLaunchersScriptReference.Add(bottomFruitLaunchers[i].GetComponent <FruitLauncher>()); } //loop through all of the side fruit launchers for (int j = 0; j < sideFruitLaunchers.Length; j++) { //now add each side fruit launcher to our List ("sideLaunchersScriptReference") sideLaunchersScriptReference.Add(sideFruitLaunchers[j].GetComponent <FruitLauncher>()); } }
private GameObject[] menuFruitGameObjects; // the array of fruit in the scene (if we are not in a game scene), we GetComponent all of these fruit's CapsuleColliders for changing to inactive. //if a menu fruit has already been sliced... that way you cannot attempt to load other levels after finishing a selection. // Use this for initialization void Start() { SetupFruitDebirsArray(); // we will use resetPos as the level origin 0,0,0 resetPos = new Vector3(0, 0, 0); //if inGameScene (checked true in the inspector)... (only uncheck if the fruit is for a Menu Scene) if (inGameScene) { ///Setup Scene References with GameObject.FindGameObjectWithTag... //setup our animator reference... pineappleTweenIconAnim = GameObject.FindGameObjectWithTag(Tags.PineappleTweenIcon).GetComponent <Animator>(); //setup our ComboCounter reference... comboCounter = GameObject.FindGameObjectWithTag(Tags.comboCanvasTag).GetComponent <FruitDestroyCombo>(); //setup our TwoTimesScoreEffectGameObject reference... (All PowerUp Effects have a script on a GameObject in the game scenes (i.e. scenes 2.3,4); twoXScore = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); } else { //if not in game scene then we are in menu scene. Lets get this fruits audio source so we can use it on slice... thisObjectsAudioSource = GetComponent <AudioSource>(); //finish initializing our List of CapsuleColliders. fruitCollidersInScene = new List <CapsuleCollider>(); //we fill the menuFruitColliders array with the menu fruit gameobjects.. menuFruitGameObjects = GameObject.FindGameObjectsWithTag(Tags.fruitTag); //now we loop through all of the menu fruit... for (int i = 0; i < menuFruitGameObjects.Length; i++) { //with each iteration and each "Fruit" found we do a GetCompoennt for the CapsuleCollider... and add that collider to the list. fruitCollidersInScene.Add(menuFruitGameObjects[i].GetComponent <CapsuleCollider>()); } //so now that, that is done later we can disable all the fruit colliders. After someone cuts a menu fruit that level will be selected... //there is no need to allow them to cut another. it will only produce a weird scene load issue, where half way through loading one level //another load starts... Fader would blink out a few times. etc... Now that cannot happen :0 } //Some of these References are for Menu Scenes only.. others are just references that we need to setup... //this gets all of the MeshRenderers for the attached fruit.. some of the prefabs are setup minutely different. fruitChildMeshRenderers = GetComponentsInChildren <MeshRenderer>(); //reference to this rigidbody thisRB = GetComponent <Rigidbody>(); //reference to Game Music Audio Source (Child of ScreenFaderSingletons "MODFaderPrefab(DontDestroyOnLoad)" The only prefab in the Resources folder. ////////gameMusicAudioSource = GameObject.FindGameObjectWithTag(Tags.GameMusicAudio).GetComponent<AudioSource>(); //reference to Game Sfx Audio Source (Child of ScreenFaderSingletons "MODFaderPrefab(DontDestroyOnLoad)" The only prefab in the Resources folder. gameSfxAudioSource = GameObject.FindGameObjectWithTag(Tags.GameSfxAudio).GetComponent <AudioSource>(); //setup the temple bell audio source for when not in a game scene. thisObjectsAudioSource = GetComponent <AudioSource>(); }
void Awake() { //I usually use awake for setting up references, so we will do that first. //the next three lines will get a reference to the 3 gameObjects in the game scenes that control the powerUp //effects. These gameObjects each have a spriteRenderer that is used to display the powerUp labels and some have //borders (like Freeze Effect). //all of the tags in the game are stored in [const readonly strings], in our Tags Class. There was quite a few //different tags, and since I would prefer the scripts to autoComplete, I created read only strings for them. freezeEffectGameObject = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>(); frenzyEffectGameObject = GameObject.FindGameObjectWithTag(Tags.frenzyEffectGameObjectTag).GetComponent <FrenzyEffect>(); twoTimesScoreEffectGameObject = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); //cache a reference to this gameObject. thisGameObject = this.gameObject; //Setup Shake and Chroma Script References... both scripts are on the main camera shake = Camera.main.GetComponent <SimpleCameraShake>(); chroma = Camera.main.GetComponent <ChromaticAberration>(); }
/// <summary> /// MonitorGameState is the main Method in the GameController Class. The Method /// </summary> public void MonitorGameState() { //////////////////////////////// ////_____Classic-MODE_______//// /////////////////////////////// //if the current game mode is Classic... if (gameModes == GameModes.Classic) { //if roundTimer.timeLeft is less than or equal to 0.01 && gameHasStarted //Physics.gravity = g + new Vector3(0, -0.1f * GameVariables.ClassicModeScore/3, 0); if (roundTimer.timeLeft <= 0.01 && gameHasStarted) { // gameover and compute score again, update ui if (GameVariables.correct.Length > 0) { AddToFruitDestroyedScore(GameVariables.correct.Length, true); TwoTimesScoreEffect tw = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); if (tw.twoTimesScoreIsOn) { AddToFruitDestroyedScore(GameVariables.correct.Length, true); } GameController.GameControllerInstance.UpdateUIText(); Debug.Log(GameVariables.correct); } //Debug.Log("Game Over"); //activate the gameOverPanel gameOverPanel.SetActive(true); //FNCTouchSlicer gets disabled slicerGO.SetActive(false); //invoke our settings/menu canvas to provoke a response... Invoke("LocalPauseAndSettingsMenuCall", waitForMenuAtEnd); //if GameVariables.ClassicModeHighestScore is less than GameVariables.ClassicModeScore then clearly we need to update the highest score if (GameVariables.ClassicModeHighestScore < GameVariables.ClassicModeScore) { //we update the highest score by calling UpdateHighestScore(GameVariables.ClassicModeScore(ClassicModeScore)) UpdateHighestScore(GameVariables.ClassicModeScore); } //We also need to update player experience... we pass in our new score to do that. UpdatePlayerExperienceAndLevel(GameVariables.ClassicModeScore); //and we set gameIsRunning to false gameIsRunning = false; } //else... game clock is still running, and we should still be launching... else { //Access the LaunchControllers static Instance and call ReduceLaunchTimersAndLaunchObjects... LauncherController.LaunchControllerInstance.ReduceLaunchTimersAndLaunchObjects(); } } //////////////////////////////// ////______RELAX-MODE_______//// /////////////////////////////// //if the current game mode is Classic... if (gameModes == GameModes.Relax) { //if roundTimer.timeLeft is less than or equal to 0.01 && gameHasStarted if (roundTimer.timeLeft <= 0.01 && gameHasStarted) { //Debug.Log("Game Over"); //activate the gameOverPanel gameOverPanel.SetActive(true); //FNCTouchSlicer gets disabled slicerGO.SetActive(false); //invoke our settings/menu canvas to provoke a response... Invoke("LocalPauseAndSettingsMenuCall", waitForMenuAtEnd); //if GameVariables.ClassicModeHighestScore is less than GameVariables.ClassicModeScore then clearly we need to update the highest score if (GameVariables.RelaxModeHighestScore < GameVariables.RelaxModeScore) { //we update the highest score by calling UpdateHighestScore(GameVariables.ClassicModeScore(ClassicModeScore)) UpdateHighestScore(GameVariables.RelaxModeScore); } //We also need to update player experience... we pass in our new score to do that. UpdatePlayerExperienceAndLevel(GameVariables.RelaxModeScore); //and we set gameIsRunning to false gameIsRunning = false; } //else... game clock is still running, and we should still be launching... else { //Access the LaunchControllers static Instance and call ReduceLaunchTimersAndLaunchObjects... LauncherController.LaunchControllerInstance.ReduceLaunchTimersAndLaunchObjects(); } } }