static public void AddScore(int num) { // Find the ScoreGT Text field only once. if (SCORE_GT == null) { GameObject go = GameObject.Find("ScoreGT"); if (go != null) { SCORE_GT = go.GetComponent <UnityEngine.UI.Text>(); } else { Debug.LogError("AsteraX:AddScore() - Could not find a GameObject named ScoreGT."); return; } SCORE = 0; } // SCORE holds the definitive score for the game. SCORE += num; if (!GOT_HIGH_SCORE && SaveGameManager.CheckHighScore(SCORE)) { // We just got the high score GOT_HIGH_SCORE = true; // Announce it using the AchievementPopUp AchievementPopUp.ShowPopUp("High Score!", "You've achieved a new high score."); } // Show the score on screen. For info on numeric formatting like "N0", see: // https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings SCORE_GT.text = SCORE.ToString("N0"); AchievementManager.AchievementStep(Achievement.eStepType.scoreAttained, SCORE); }
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(); } }
static public void GameOver() { SaveGameManager.CheckHighScore(SCORE); SaveGameManager.Save(); _S.EndGame(); }
//decided I'd try to only run this on an event(aka when the value changed) so after I add the value //I just call it on the script I added it from. plan on making methods later to make it simpler. /// <summary> /// make sure to call this after changing variables /// </summary> public static void AchievementCheck() { if (SaveGameManager.CheckHighScore(SCORE) && !_S._newHighScore) { _S._newHighScore = true; AchievementSettings highScoreSettings = new AchievementSettings(); highScoreSettings.title = _S.highScoreTitle; highScoreSettings.description = _S.highScoreDescription; highScoreSettings.count = SCORE; _S._settingsQueue.Enqueue(highScoreSettings); UIScript.SetGameOverText("HIGH SCORE!"); } foreach (AchievementSettings setting in _S.settings) { switch ((int)setting.achievementType) { case 0: //LuckyShot if (BULLET_WRAP_COUNT >= setting.count && !setting.complete) { setting.complete = true; _S._settingsQueue.Enqueue(setting); CustomAnalytics.SendAchievementUnlocked(setting); } break; case 1: //AsteroidHitCount if (ASTEROIDS_HIT >= setting.count && !setting.complete) { setting.complete = true; _S._settingsQueue.Enqueue(setting); CustomAnalytics.SendAchievementUnlocked(setting); } break; case 2: //BulletsFired if (BULLETS_FIRED >= setting.count && !setting.complete) { setting.complete = true; _S._settingsQueue.Enqueue(setting); CustomAnalytics.SendAchievementUnlocked(setting); } break; case 3: //Points if (SCORE >= setting.count && !setting.complete) { setting.complete = true; _S._settingsQueue.Enqueue(setting); CustomAnalytics.SendAchievementUnlocked(setting); } break; case 4: //LevelsComplete if (AsteraX.GetLevel() >= setting.count && !setting.complete) { setting.complete = true; _S._settingsQueue.Enqueue(setting); CustomAnalytics.SendAchievementUnlocked(setting); } break; default: break; } UIScript.UnlockToggleFromAchievement(setting); } SaveGameManager.Save(); }
public void OnCollisionEnter(Collision coll) { // If this is the child of another Asteroid, pass this collision up the chain if (parentIsAsteroid) { parentAsteroid.OnCollisionEnter(coll); return; } if (immune) { return; } GameObject otherGO = coll.gameObject; if (otherGO.tag == "Bullet" || otherGO.transform.root.gameObject.tag == "Player") { if (otherGO.tag == "Bullet") { GameManager.score += GameManager.AsteroidsSO.pointsForAsteroidSize[size]; if (GameManager.score >= AchievementManager.scoreToReachRookiePilot && !AchievementManager.S.Achievements[3].complete) { GameManager.HIGH_SCORE_DELEGATE(); } if (!GameManager.getHighScore && SaveGameManager.CheckHighScore(GameManager.score)) { GameManager.HIGH_SCORE_DELEGATE(); GameManager.getHighScore = true; } Bullet.BULLET_HIT_ASTEROID_DELEGATE(); if (otherGO.GetComponent <Bullet>().bDidWrap == true) { Bullet.LUCKY_SHOT_DELEGATE(); } Destroy(otherGO); } if (size > 1) { // Detach the children Asteroids Asteroid[] children = GetComponentsInChildren <Asteroid>(); for (int i = 0; i < children.Length; i++) { children[i].immune = true; if (children[i] == this || children[i].transform.parent != transform) { continue; } children[i].transform.SetParent(null, true); children[i].InitAsteroidParent(); } } int index = Random.Range(0, 2); GameObject go = GameManager.AsteroidsSO.asteroidExplosionPrefabs[index]; go.transform.localScale = gameObject.transform.localScale; ParticleSystem particleSys = go.GetComponent <ParticleSystem>(); ParticleSystem.MainModule main = particleSys.main; main.startSpeedMultiplier = 5 / gameObject.transform.localScale.x; Instantiate(go, transform.position, Quaternion.identity); Destroy(gameObject); } }