void Update() { if (Entities.Count > 0 && Reset == false) // Makes sure that there are still entities alive { foreach (GameObject e in Entities) // For each entity that we are managing { if (e) // If its still alive { if (e.transform.position.x < ScreenBorders.m_bottomLeft.x - 10) // If the entity is off the screen { Destroy(e); // Destroy it } } if (!e) // Sees if the entity has been destroyed { Entities.Remove(e); // Remove them from the list for (int i = 0; i < Entities.Count; i++) { if (Entities[i].GetComponent <LgEnemy>()) { if (i == Entities.Count - 1) { Entities[i].GetComponent <LgEnemy>().CallForHelp(); } else { continue; } } else { return; // and restart the check } } return; } } } else if (Reset == true) { foreach (GameObject e in Entities) { Destroy(e); } Reset = false; SpawnNextWave(); } else if (++m_currentWave < EntityWaves.Count) // If all the entites are dead { // AND there is a NEXT wave SpawnNextWave(); // spawn the next wave } else // If there is no next wave { StartCoroutine(EndWait()); GameStates.ChangeState("GameOver"); // Gameover } }
// Update is called once per frame void Update() { if (mainEventSystem.enabled == true) { if (Input.GetButtonDown("Cancel")) { if (GameStates.GetState() != "MainMenu") { Messenger.Broadcast("BackToMenu"); // LoadLevel.ClearLevel(); GameStates.ChangeState("MainMenu"); // Debug.Break(); } else { GameObject buttonGO = GameObject.Find("Back"); if (buttonGO != null) { Button backButton = buttonGO.GetComponent <Button>(); backButton.onClick.Invoke(); } } } } }
/// <summary> /// Turning off gui elements to able to load scene to GamePlay /// </summary> public void PlayButton() { GUIManager.instance.Activate("UIBackground", false); GUIManager.instance.Activate("UIPlayButton", false); GUIManager.instance.Activate("UIOptionsButton", false); GUIManager.instance.Activate("UICreditButton", false); GUIManager.instance.Activate("UIQuitButton", false); GameStates.ChangeState("Game"); }
/// <summary> /// Turning off gui elements to able to load scene /// </summary> public void PlayButton() { GUIManager.instance.Activate("UITitle", false); GUIManager.instance.Activate("UIPlayButton", false); GUIManager.instance.Activate("UIOptionsButton", false); GUIManager.instance.Activate("UICreditButton", false); GUIManager.instance.Activate("UIQuitButton", false); GameStates.ChangeState("Game"); // Load GamePlay scene }
/// <summary> /// Turning off gui elements to able to load scene to Main Menu /// </summary> public void MainMenu() { GUIManager.instance.Activate("UIPauseText", false); GUIManager.instance.Activate("UIResumeButton", false); GUIManager.instance.Activate("UIQuitButton", false); GUIManager.instance.Activate("UIMainMenu", false); GUIManager.instance.Activate("UIGameOver", false); GUIManager.instance.Activate("UIHighScores", false); GUIManager.instance.Activate("UICurrentScore", false); GameStates.ChangeState("MainMenu"); }
void Update() { // this is for level skipping in Tricky mode. There may well be a better place for this code, but it lives here for now if (Input.GetButtonDown("NextLevel") && modeManager.GetMode() == Mode.Tricky) { // Messenger.Broadcast("Success"); GameStates.ChangeState("Transition", "Skip"); Messenger <TransitionReason> .Broadcast("Transition", TransitionReason.levelSkip); gameObject.SetActive(false); } }
// checks if (and then does) load main game if nothing is unlocked - or load the "PlayWhat?" menu public void PressPlay() { if (statsManager.GetModeTimesCompleted(Mode.Main) > 0) { // load menu // playMenuGO.SetActive(true); mainMenuController.OpenPlaySub(); } else { // just Play Main GameStates.ChangeState("Transition", null); } }
public void PlayerDamage() { _cAction = PLAYERACTIONS.takeDamage; if (shield != true) { currentHealth -= 1; } else { shield = false; AddShield(shield); } if (playerGUI != null) { playerGUI.HPChange(currentHealth); } if (currentHealth == 0) { Instantiate(Resources.Load("BigExsplosion"), transform.position, transform.localRotation); EntityManager.ResetWave(); acceleration = Vector3.zero; velocity = Vector3.zero; _fsm.Transition(_fsm.state, PLAYERSTATES.dead); livesRemaining -= 1; if (livesRemaining >= 0) { LivesRemaining.RemoveLife(); _cAction = PLAYERACTIONS.die; transform.position = spawnPosition; well.transform.position = spawnPosition; PlayerSpawn(); currentHealth = maxHealth; if (GODMODE == true) { livesRemaining += 1; } } else if (livesRemaining < 0) { _fsm.Transition(_fsm.state, PLAYERSTATES.destroyed); GameStates.ChangeState("GameOver"); } } DylanGamePlay.UpdatePlayer(currentHealth, livesRemaining); }
IEnumerator Timer() { while (currentTime > 0) { currentTime -= Time.deltaTime; yield return(null); } // make the game be over // Debug.Log("Local: " + currentTime + " Stats: " + CalculateTimeFromStats()); Debug.Log("Outta Time Baby"); needsReset = true; Messenger.Broadcast("LevelOver"); Messenger.Broadcast("Failure"); GameStates.ChangeState("Transition", "Bad"); Messenger <TransitionReason> .Broadcast("Transition", TransitionReason.levelFailure); }
void Update() { if (Entities.Count > 0 && Reset == false) // Makes sure that there are still entities alive { foreach (GameObject e in Entities) // For each entity that we are managing { if (!e) // Sees if the entity has been destroyed { Entities.Remove(e); // Remove them from the list return; // and restart the check } else if (e.transform.position.x < ScreenBorders.m_bottomLeft.x - 10) // Check to see if they are still on the screen { // if they're not... Destroy(e); // Destroy them Entities.Remove(e); // Remove them from the list return; // and restart the check } } } else if (Reset == true) { foreach (GameObject e in Entities) { Destroy(e); } Reset = false; SpawnNextWave(); } else if (++m_currentWave < EntityWaves.Count) // If all the entites are dead { // AND there is a NEXT wave SpawnNextWave(); // spawn the next wave } else { GameStates.ChangeState("GameOver"); } }
public void PlayerDamage() { _cAction = PLAYERACTIONS.takeDamage; currentHealth -= 1; if (playerGUI != null) { playerGUI.HPChange(currentHealth); } if (currentHealth == 0) { EntityManager.ResetWave(); acceleration = Vector3.zero; velocity = Vector3.zero; FindObjectOfType <AudioManager>().PlayExplodeAudio(); _fsm.Transition(_fsm.state, PLAYERSTATES.dead); livesRemaining -= 1; if (livesRemaining >= 0) { _cAction = PLAYERACTIONS.die; transform.position = spawnPosition; well.transform.position = spawnPosition; PlayerSpawn(); currentHealth = maxHealth; if (GODMODE == true) { livesRemaining += 1; } } else if (livesRemaining < 0) { _fsm.Transition(_fsm.state, PLAYERSTATES.destroyed); GameStates.ChangeState("GameOver"); } } }
// Use this for initialization void Start() { GameStates.ChangeState("TestTransition"); }
public void MainMenuclick() { GameStates.ChangeState("MainMenu"); }
IEnumerator Transition() { transitioning = true; if (transitionReason == TransitionReason.levelSuccess) { // Tells LoadLevel a level has been completed, and returns whether that was the last level // gameCompleted = LoadLevel.LevelCompleted(); levelManager.LevelCompleted(); gameCompleted = levelManager.CheckForGameOver(); } if (transitionReason == TransitionReason.levelLoad) { // Tells LoadLevel a level has been completed, and returns whether that was the last level // gameCompleted = LoadLevel.LevelCompleted(); // levelManager.LevelCompleted(); gameReset = levelManager.CheckForGameOver(); if (gameReset == true) { // statsManager.ClearModeStats(modeManager.GetMode()); levelManager.ResetModeLevels(); } if (modeManager.GetMode() == Mode.Time && timeChallengeManager.CheckResetNeed() == true) { levelManager.ResetModeLevels(); } if (modeManager.GetMode() == Mode.Lives && livesChallengeManager.CheckResetNeed() == true) { levelManager.ResetModeLevels(); } } if (transitionReason == TransitionReason.levelFailure) { if (modeManager.GetMode() == Mode.OneShot) { gameOver = true; } if (modeManager.GetMode() == Mode.Time && timeChallengeManager.GetTime() <= 0) { gameOver = true; } if (modeManager.GetMode() == Mode.Lives && livesChallengeManager.GetLives() <= 0) { gameOver = true; } } // if (transitionReason == TransitionReason.levelSuccess) // { // // Reset Game if you start to play and levels are all complete // if (LoadLevel.CheckComplete()) // { // LoadLevel.Reset(); // // Debug.Log("R"); // } // } // Debug.Log("About To Start Phase One"); // Debug.Break(); // HANGS AFTER HERE yield return(transitionScreen.StartPhaseOne()); // Debug.Log("Just After Phase One"); // Debug.Break(); transitionText.UpdateText(); string text = transitionText.GetText(); // string text = "Hello There"; MinMax waitTime = new MinMax(0.25f, 1f); MinMax stringLength = new MinMax(8, 30); float lerpValue = Mathf.InverseLerp(stringLength.min, stringLength.max, text.Length); float actualWaitTime = Mathf.Lerp(waitTime.min, waitTime.max, lerpValue); // Debug.Log("Wait Time: " + actualWaitTime); // yield return transitionScreen.StartPhaseOne(); // BUT BEFORE HERE // Debug.Log("About To Start Phase Two"); // Debug.Break(); yield return(transitionScreen.StartPhaseTwo(actualWaitTime)); // if (gameCompleted) // { // levelManager.ClearLevel(); // } yield return(transitionScreen.StartPhaseThree()); if (gameCompleted == false && gameOver == false) { GameStates.ChangeState("Playing"); } else { GameStates.ChangeState("Complete"); } Messenger.Broadcast("StopConstantShake"); // Debug.Log("Transition Done"); // Debug.Log("T Still running y'all"); transitioning = false; yield return(null); }
public void PauseGame() { GameStates.ChangeState("Pause"); }
void OnTriggerEnter2D(Collider2D other) { if (Application.loadedLevelName == "LevelTesting" || Application.loadedLevelName == "GraphicsTesting" || Application.loadedLevelName == "Aesthetics") { if (other.gameObject.tag == "Wall" || other.gameObject.tag == "Frame") { Application.LoadLevel(Application.loadedLevel); } if (other.gameObject.tag == "End") { Application.LoadLevel(Application.loadedLevel); Debug.Log("Did It!"); } } else { if (other.gameObject.tag == "Wall" || other.gameObject.tag == "Frame") { // LoadLevel.StopTimer(); Messenger.Broadcast("LevelOver"); Messenger.Broadcast("Failure"); GameStates.ChangeState("Transition", "Bad"); // modify intensity and shake duration based on playerSpeed MinMax playerSpeedValues = new MinMax(1, 16); MinMax intensityValues = new MinMax(0.05f, 0.16f); MinMax durationValues = new MinMax(0.05f, 0.12f); float l = Mathf.InverseLerp(playerSpeedValues.min, playerSpeedValues.max, speedL); float shakeIntensity = Mathf.Lerp(intensityValues.min, intensityValues.max, l); float shakeDuration = Mathf.Lerp(durationValues.min, durationValues.max, l); Messenger <float, float> .Broadcast("screenshake", shakeIntensity, shakeDuration); // Messenger<float, float>.Broadcast("screenshake", 0.08f, 0.03f); Messenger <PlayerControl> .Broadcast("SetPlayer", this); // Testing new thing - trying to make it recognise which player hit a wall Messenger <TransitionReason> .Broadcast("Transition", TransitionReason.levelFailure); Transform endPoint = GameObject.Find("EndPoint").transform; float distance = Vector2.Distance(transform.position, endPoint.position); float convertedDistance = distance - (transform.localScale.x / 2) - (endPoint.localScale.x / 2); // Debug.Log("Distance " + distance + " Converted Distance " + convertedDistance); Messenger <bool> .Broadcast("CloseCall", convertedDistance < 0.4f); // TRYING NEW THINGS // gameObject.SetActive(false); // graphicsGO.SetActive(false); // gameObject.GetComponent<Collider2D>().enabled = false; } if (other.gameObject.tag == "End") { // LoadLevel.StopTimer(); Messenger.Broadcast("LevelOver"); Messenger.Broadcast("Success"); GameStates.ChangeState("Transition", "Good"); // Messenger<float, float>.Broadcast("screenshake", 0.04f, 0.75f); Messenger <float> .Broadcast("StartConstantShake", 0.04f); Messenger <TransitionReason> .Broadcast("Transition", TransitionReason.levelSuccess); Vector2 collisionPoint = other.gameObject.GetComponent <Collider2D>().bounds.ClosestPoint(transform.position); if (GameObject.Find("LevelCamera") != null) { Camera cam = GameObject.Find("LevelCamera").GetComponent <Camera>(); collisionPoint = cam.WorldToViewportPoint(collisionPoint); collisionPoint = Camera.main.ViewportToWorldPoint(collisionPoint); } levelCompletePS.Fire(collisionPoint); // TRYING NEW THINGS // gameObject.SetActive(false); // graphicsGO.SetActive(false); // gameObject.GetComponent<Collider2D>().enabled = false; } } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Reset")) { Restart(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { t1 = !t1; Debug.Log("Changing t1 to " + t1); } if (Input.GetKeyDown(KeyCode.Alpha2)) { t2 = !t2; Debug.Log("Changing t2 to " + t2); } if (Input.GetKeyDown(KeyCode.Alpha3)) { t3 = !t3; Debug.Log("Changing t3 to " + t3); } if (Input.GetKeyDown(KeyCode.Alpha0)) { t1 = false; t2 = false; t3 = false; Debug.Log("Changing t's to false"); } if (Input.GetKeyDown("escape")) { // Restart(); // Application.Quit(); } // if (Input.GetKeyDown("f9")) // { // TakeScreenshot(); // } if (Input.GetButtonDown("Fire3")) { Debug.Log("Muting Level Audio"); MuteLevelAudio(); } if (Input.GetButtonDown("Jump")) { Debug.Log("Reset Camera Settings"); ResetCameraSettings(); } if (Input.GetKeyDown("l")) { Debug.Log("Skipping level"); Messenger.Broadcast("Success"); GameStates.ChangeState("Transition", "Good"); Messenger <TransitionReason> .Broadcast("Transition", TransitionReason.levelSuccess); } }
public void ResumeClick() { GameStates.ChangeState("Pause"); }
// void BeginTransition (TransitionState tS) { // StartCoroutine(Go(tS)); // } public IEnumerator Go(string e) { // public IEnumerator Go () { // Debug.Log("T"); bool complete = false; // whether the player has completed the main mode if (e == "Good") { complete = LoadLevel.LevelCompleted(); // transitionText.text = complete == true ? completeText : goodText[Random.Range(0, goodText.Length)]; } else if (e == "Bad") { // transitionText.text = badText[Random.Range(0, badText.Length)]; } else if (e == "Load") { // transitionText.text = loadText[Random.Range(0, loadText.Length)]; if (LoadLevel.CheckComplete()) { LoadLevel.Reset(); // Debug.Log("R"); } } GameObject startPoint; if (e != "Load") { startPoint = GameObject.Find("Player"); // Debug.Log(startPoint.transform.position); // GameObject.Find("Player").SetActive(false); } else { startPoint = GameObject.Find("Play"); } float startingXScale = startPoint.transform.localScale.x * 0.058f; panel.transform.localScale = new Vector3(startingXScale, startPoint.transform.localScale.y * 0.1f, 1); panel.transform.position = new Vector3(startPoint.transform.position.x, startPoint.transform.position.y, panel.transform.position.z); float target = 2f; float growthSpeed = 0.1f; while (panel.transform.localScale.x < target && panel.transform.localScale.y < target) { panel.transform.localScale = new Vector3(panel.transform.localScale.x + growthSpeed, panel.transform.localScale.y + growthSpeed, 1); yield return(null); } // GameStates.ChangeState("GameOver"); // if (LoadLevel.CheckLevel()) if (complete == false && e != "Test") { LoadLevel.GetLevel(); // levelInfo.SetActive(true); } else { LoadLevel.ClearLevel(); completeInfo.SetActive(true); } transitionGO.SetActive(true); yield return(new WaitForSeconds(0.25f)); GameObject endPoint; // if (LoadLevel.CheckLevel()) if (complete == false) { completeInfo.SetActive(false); levelInfo.SetActive(true); endPoint = GameObject.Find("Player"); } else { // GameStates.ChangeState("Complete"); // LoadLevel.ClearLevel(); // completeInfo.SetActive(false); endPoint = GameObject.Find("Play"); } // levelInfo.SetActive(true); // Messenger.Broadcast("UpdateColour"); Messenger.Broadcast("TransitionMiddle"); transitionGO.SetActive(false); panel.transform.position = new Vector3(endPoint.transform.position.x, endPoint.transform.position.y, panel.transform.position.z); while (panel.transform.localScale.x > startingXScale) { panel.transform.localScale = new Vector3(panel.transform.localScale.x - growthSpeed, panel.transform.localScale.y - growthSpeed, 1); yield return(null); } // if (LoadLevel.CheckLevel()) if (complete == false) { GameStates.ChangeState("Playing"); } else { GameStates.ChangeState("Complete"); } yield return(null); }
public void ExitClick() { GameStates.ChangeState("Exit"); }
IEnumerator EndWait() { yield return(new WaitForSeconds(3.0f)); GameStates.ChangeState("GameOver"); }