void SetNewStoryText() { if (myIntroStoryState > myStoryTextString.Length - 1) { return; } myStoryText.CrossFadeAlpha(1.0f, 0.1f, false); myStoryText.text = myStoryTextString[myIntroStoryState]; myAudioSource.PlayOneShot(myTalkClips[myIntroStoryState]); Invoke("FadeOutStoryText", 2.0f); }
IEnumerator FadeText() { yield return(new WaitForSeconds(1f)); while (displayPressText) { pressText.CrossFadeAlpha(255, 1f, false); yield return(new WaitForSeconds(1f)); pressText.CrossFadeAlpha(0, 1f, false); yield return(new WaitForSeconds(1f)); } }
public void StartGame() { Debug.Log("PLAYER STARTED"); // Fading animation between game states StartCoroutine(FadeOutStartingUI()); scoreText.CrossFadeAlpha(1.0f, 1.0f, false); InvokeRepeating("SpawnPipes", 0f, pipesSpawnDelay); }
IEnumerator GameplayCountdown() { //get hotseat text UnityEngine.UI.Text hotseatText = GameObject.Find("WarningHotseatText").GetComponent <UnityEngine.UI.Text>(); //modulate text opacity back and forth hotseatText.CrossFadeAlpha(0f, .7f, false); yield return(new WaitForSeconds(.7f)); for (int i = 3; i > 0; i--) { hotseatText.text = "Warning!\nApproaching astrobelt\n" + i; hotseatText.CrossFadeAlpha(1f, .7f, false); yield return(new WaitForSeconds(.7f)); hotseatText.CrossFadeAlpha(0f, .7f, false); yield return(new WaitForSeconds(.7f)); } //activate spawner to begin gameplay spawner.SetActive(true); flightStartTime = Time.time; }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); musicPlayer = GameObject.Find("MusicPlayer"); GameObject scoreGO = GameObject.Find("ScoreText"); if (scoreGO) { scoreText = scoreGO.GetComponent <UnityEngine.UI.Text> (); } GameObject timerGO = GameObject.Find("TimerText"); if (timerGO) { timerText = timerGO.GetComponent <UnityEngine.UI.Text> (); timerText.text = string.Format("{0:0} : {1:00} : {2:00}", (int)Mathf.Floor(timeLeft / 60.0f), (int)(timeLeft % 60.0f), (int)((timeLeft % 1.0f) * 100.0f)); } GameObject timeGO = GameObject.Find("TimeText"); if (timeGO) { timeUpText = timeGO.GetComponent <UnityEngine.UI.Text> (); timeUpText.CrossFadeAlpha(0.0f, 0.0f, true); } GameObject restartGO = GameObject.Find("RestartText"); if (restartGO) { restartText = restartGO.GetComponent <UnityEngine.UI.Text> (); restartText.CrossFadeAlpha(0.0f, 0.0f, true); } foreach (GameObject spawnPoint in GameObject.FindGameObjectsWithTag("EnemySpawnPoint")) { spawnPoints.Add(spawnPoint); } ballSpawnPoint = GameObject.FindGameObjectWithTag("BallSpawnPoint"); }
// Update is called once per frame void Update() { if (gameRunning) { if (timerRunning) { timeLeft -= Time.deltaTime; if (timeLeft < 0.0f) { timeLeft = 0.0f; gameRunning = false; foreach (GameObject GO in balls) { Destroy(GO); } ballTarget = 0; enemyTarget = 0; AudioSource audio = GetComponent <AudioSource> (); timeUpText.CrossFadeAlpha(1.0f, 0.2f, false); if (score == enemyScore) { timeUpText.text = "Time Up! Draw!"; audio.clip = drawSound; } else if (score > enemyScore) { timeUpText.text = "Time Up! You Win!"; audio.clip = winSound; } else { timeUpText.text = "Time Up! You Lose!"; audio.clip = loseSound; } audio.Play(); musicPlayer.GetComponent <AudioSource> ().Stop(); restartText.CrossFadeAlpha(1.0f, 0.2f, false); } timerText.text = string.Format("{0:0} : {1:00} : {2:00}", (int)Mathf.Floor(timeLeft / 60.0f), (int)(timeLeft % 60.0f), (int)((timeLeft % 1.0f) * 100.0f)); } if (balls.Count < ballTarget) { Vector3 SpawnPos = ballSpawnPoint.transform.position; SpawnPos.y += Random.Range(2.0f, 10.0f); Vector3 kickTarget = new Vector3(Random.Range(-1.0f, 1.0f), 0.0f, Random.Range(-1.0f, 1.0f)); GameObject newBall = Instantiate(ballClass, SpawnPos, Quaternion.identity); newBall.GetComponent <Rigidbody> ().AddForce(kickTarget * spawnKickForce, ForceMode.Impulse); } if (enemySpawnCooldown > 0.0f) { enemySpawnCooldown -= Time.deltaTime; } if (enemies.Count < enemyTarget && enemySpawnCooldown <= 0.0f) { GameObject spawnPoint = GetSpawnPoint(); Vector3 SpawnPos = spawnPoint.transform.position; SpawnPos.y += 1.0f; Instantiate(enemyClass, SpawnPos, Quaternion.identity); enemySpawnCooldown = enemyRate; } } else { if (Input.GetButton("Submit")) { UnityEngine.SceneManagement.SceneManager.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex); } } }