private void Update() { switch (transition) { case UITransitionState.EasingIn: timeCounter = Mathf.Clamp01(timeCounter + Time.deltaTime * transitionSpeed); if (timeCounter >= 1) { transition = UITransitionState.Steady; } break; case UITransitionState.EasingOut: timeCounter = Mathf.Clamp01(timeCounter - Time.deltaTime * transitionSpeed); if (timeCounter <= 0) { state = nextState; transition = UITransitionState.EasingIn; return; } break; default: break; } if (Input.GetKeyDown(KeyCode.F5)) { state = MainMenuState.Title; transition = UITransitionState.EasingIn; timeCounter = 0; } }
public void Start() { currentLives = startingLives; bgManager = FindObjectOfType <BackgroundManager>(); scoreController = FindObjectOfType <ScoreController>(); showHighScoreBox = false; timeCounter = 0; transition = UITransitionState.Steady; playerSpecial = FindObjectOfType <PlayerSpecial>(); referenceFrame = FindObjectOfType <ReferenceFrame>(); }
public void Update() { if (waitToReturnToTitleScreen) { if (Input.anyKeyDown) { FindObjectOfType <BackgroundManager>().FadeOut(GoToMenu); } } if (showHighScoreBox) { switch (transition) { case UITransitionState.EasingIn: timeCounter = Mathf.Clamp01(timeCounter + Time.deltaTime * 2); if (timeCounter >= 1) { transition = UITransitionState.Steady; } break; case UITransitionState.EasingOut: timeCounter = Mathf.Clamp01(timeCounter - Time.deltaTime * 2); if (timeCounter <= 0) { showHighScoreBox = false; transition = UITransitionState.Steady; } break; default: break; } } if (Input.GetKeyDown(KeyCode.F8)) { scoreController.Award(scoreController.HighScore + 1); FindObjectOfType <LifeCounter>().currentLives = 0; FindObjectOfType <PlayerLife>().OnHit(); } }
public IEnumerator PlayerLost() { foreach (var shot in GameObject.FindGameObjectsWithTag("Shot")) { Destroy(shot); } var enemies = GameObject.FindGameObjectsWithTag("EnemyController"); foreach (var enemy in enemies) { enemy.GetComponentInChildren <EnemyGun>().holdFire = true; enemy.GetComponentInChildren <EnemyMovementBase>().enabled = false; } yield return(new WaitForSeconds(respawnTime)); foreach (var enemy in enemies) { var animator = enemy.GetComponentInChildren <Animator>(); if (animator != null) { animator.SetTrigger("Celebrate"); } } bgManager.PlayDeathSong(); if (scoreController.IsNewHighScore) { showHighScoreBox = true; timeCounter = 0; transition = UITransitionState.EasingIn; } else { waitToReturnToTitleScreen = true; } }
public void OnGUI() { var style = CustomStyle.GetLabelStyle(); style.alignment = TextAnchor.UpperLeft; GUILayout.BeginArea(new Rect(5, 5, 300, 100)); { GUILayout.BeginVertical(); { GUILayout.Label(string.Format("Lives: {0}", currentLives)); if (playerSpecial.powerController != null) { GUILayout.Label(string.Format("{0} x{1}", playerSpecial.powerController.SpecialName, playerSpecial.powerCount)); } else { GUILayout.Label("No Powerup"); } } } GUILayout.EndArea(); if (showHighScoreBox) { var boxStyle = GUI.skin.GetStyle("box"); boxStyle.alignment = TextAnchor.MiddleCenter; CustomStyle.SetStyleData(GUI.skin.GetStyle("button")); var size = new Vector2(0.2f, 0.2f); var center = new Vector2(0.5f, 0.5f); var halfSize = size / 2; var topLeft = center - size / 2; var menuRect = new Rect( Screen.width * (topLeft.x + halfSize.x * (timeCounter - 1) * -1), Screen.height * (topLeft.y + halfSize.y * (timeCounter - 1) * -1), Screen.width * size.x * timeCounter, Screen.height * size.y * timeCounter); style.alignment = TextAnchor.MiddleCenter; GUILayout.BeginArea(menuRect, boxStyle); GUILayout.BeginVertical(); { GUI.enabled = transition == UITransitionState.Steady; GUILayout.FlexibleSpace(); style.alignment = TextAnchor.MiddleCenter; GUILayout.Label("Nuevo High Score!"); GUILayout.FlexibleSpace(); var textStyle = GUI.skin.GetStyle("textfield"); textStyle.fontSize = 24; textStyle.font = CustomStyle.font; winnerName = GUILayout.TextField(winnerName, 5); if (GUILayout.Button("Guardar")) { scoreController.SaveHighScore(winnerName); timeCounter = 1; transition = UITransitionState.EasingOut; waitToReturnToTitleScreen = true; } } GUILayout.EndVertical(); GUILayout.EndArea(); } }
// Use this for initialization private void Start() { timeCounter = 0; state = MainMenuState.Title; transition = UITransitionState.EasingIn; }
private void GoToState(MainMenuState state) { nextState = state; transition = UITransitionState.EasingOut; timeCounter = 1; }
public void Update() { if (waitToReturnToTitleScreen) { if (Input.anyKeyDown) { FindObjectOfType<BackgroundManager>().FadeOut(GoToMenu); } } if (showHighScoreBox) { switch (transition) { case UITransitionState.EasingIn: timeCounter = Mathf.Clamp01(timeCounter + Time.deltaTime * 2); if (timeCounter >= 1) { transition = UITransitionState.Steady; } break; case UITransitionState.EasingOut: timeCounter = Mathf.Clamp01(timeCounter - Time.deltaTime * 2); if (timeCounter <= 0) { showHighScoreBox = false; transition = UITransitionState.Steady; } break; default: break; } } if (Input.GetKeyDown(KeyCode.F8)) { scoreController.Award(scoreController.HighScore + 1); FindObjectOfType<LifeCounter>().currentLives = 0; FindObjectOfType<PlayerLife>().OnHit(); } }
public void Start() { currentLives = startingLives; bgManager = FindObjectOfType<BackgroundManager>(); scoreController = FindObjectOfType<ScoreController>(); showHighScoreBox = false; timeCounter = 0; transition = UITransitionState.Steady; playerSpecial = FindObjectOfType<PlayerSpecial>(); referenceFrame = FindObjectOfType<ReferenceFrame>(); }
public IEnumerator PlayerLost() { foreach (var shot in GameObject.FindGameObjectsWithTag("Shot")) { Destroy(shot); } var enemies = GameObject.FindGameObjectsWithTag("EnemyController"); foreach (var enemy in enemies) { enemy.GetComponentInChildren<EnemyGun>().holdFire = true; enemy.GetComponentInChildren<EnemyMovementBase>().enabled = false; } yield return new WaitForSeconds(respawnTime); foreach (var enemy in enemies) { var animator = enemy.GetComponentInChildren<Animator>(); if (animator != null) animator.SetTrigger("Celebrate"); } bgManager.PlayDeathSong(); if (scoreController.IsNewHighScore) { showHighScoreBox = true; timeCounter = 0; transition = UITransitionState.EasingIn; } else waitToReturnToTitleScreen = true; }