IEnumerator GameOver(GameObject player) { Destroy(player.GetComponent <PlayerShip>().shipExhaustEffectPrefab); Destroy(player); finalScoreBoard.text += score.ToString(); finalLevelBoard.text += curLevel.ToString(); if (getHighScore) { finalScreenTitle.text = "New Highscore"; } else { finalScreenTitle.text = "Game Over"; } GAME_STATE = eGameState.gameOver; SaveGameManager.CheckHighScore(score); SaveGameManager.Save(); CustomAnalytics.SendFinalShipPartChoice(); CustomAnalytics.SendGameOver(); yield return(new WaitForSeconds(timeUntilRestart)); SceneManager.LoadScene(levelToRestart); }
static public void GameOver() { SaveGameManager.CheckHighScore(SCORE); SaveGameManager.Save(); CustomAnalytics.SendFinalShipPartChoice(); CustomAnalytics.SendGameOver(); _S.EndGame(); }
public IEnumerator TryJump() { if (_currentJumps > 0) { OnJump.Invoke(); _playerCollider.enabled = false; yield return(new WaitForSeconds(respawnTime)); Vector3 randomPosition = ScreenBounds.RANDOM_ON_SCREEN_LOC_HALF; List <Asteroid> asteroids = AsteraX.ASTEROIDS; int infLoopSave = 0; int distance = 5; for (int i = 0; i < asteroids.Count;) { infLoopSave++; if (Vector3.Distance(randomPosition, asteroids[i].transform.position) > distance) { i++; } else { //one was in the way so trying again i = 0; randomPosition = ScreenBounds.RANDOM_ON_SCREEN_LOC_HALF; } //in case it doesn't work I reduce the distance so it will spawn eventually. if (infLoopSave > asteroids.Count * 100) { distance = distance >= 1 ? distance / 2 : 0; Debug.Log("Distance set too high, reduced to: " + distance); infLoopSave = 0; } } RemoveJumps(1); UIScript.UpdateJumps(_currentJumps); transform.position = randomPosition; OnRespawn.Invoke(); _playerCollider.enabled = true; jumping = false; } else { dead = true; _playerCollider.enabled = false; SaveGameManager.CheckHighScore(_score); UIScript.SetFinalScore(_score, AsteraX.GetLevel()); CustomAnalytics.SendGameOver(); CustomAnalytics.SendFinalShipPartChoice(); OnDeath.Invoke(); } }