private void FixedUpdate() { if (!jumping && AsteraX.GetLevel() != 0) { SimpleMove(axis, speed); TiltWithVelocity(axis); } }
static public void SendGameOver() { AnalyticsEvent.GameOver(null, new Dictionary <string, object> { { "time", DateTime.Now }, { "score", Achievements.SCORE }, { "level", AsteraX.GetLevel() }, { "gotHighScore", Achievements.GOT_HIGH_SCORE } }); }
public void DisplayLevelSettingsForTime(float time) { if (levelChangeCanvas != null && _currentLevelText != null) { levelChangeCanvas.enabled = true; _currentLevelText.text = "Level " + AsteraX.GetLevel(); Time.timeScale = 0; StartCoroutine("HideLevelDisplay", time); } }
//normally i'd do the updating in another script, but want to save some time. void Update() { axis = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal"), CrossPlatformInputManager.GetAxis("Vertical")); bool fire = CrossPlatformInputManager.GetButtonDown("Fire1"); if (fire && !jumping && AsteraX.GetLevel() != 0 && Time.timeScale > 0) { Fire(); } }
public void SetCurrentAsteroidCount() { string[] splitAsteroidArray = _levelProgression.Split(','); string splitAsteroid = splitAsteroidArray[AsteraX.GetLevel() - 1]; string ignoreLevel = splitAsteroidArray[AsteraX.GetLevel() - 1].Split(':')[1]; string[] childrenAndParents = ignoreLevel.Split('/'); targetAsteroidCount = int.Parse(childrenAndParents[0].ToString()); targetChildCount = int.Parse(childrenAndParents[1].ToString()); }
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(); } }
//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(); }