public void LevelComplete() { _currentLevel++; Achievements.AchievementCheck(); asteroidInfo.SetCurrentAsteroidCount(); UIScript.SetLevelSettings(asteroidInfo.targetAsteroidCount, (int)asteroidInfo.targetChildCount); if (_currentLevel > 10) { RestartAfterTime(0); return; } CustomAnalytics.SendLevelStart(_currentLevel); onLevelComplete.Invoke(); string tag = "Bullet"; if (gameObject.DoesTagExist(tag)) { foreach (GameObject bullet in GameObject.FindGameObjectsWithTag(tag)) { Destroy(bullet); } } CreateAsteroids(); _levelCompleteOneShot = false; }
//should probably change so that it adds the score and such on Achievements or AsteraX /// <summary> /// Handles destruction of the Asteroid when its hit /// </summary> /// <param name="collision"></param> public void AsteroidHit(Collision collision) { int childCount = transform.childCount; //getting position before destroying the bullet Vector3 collisionPosition = collision.transform.position; //updates score and destroys bullet if (collision.gameObject.GetComponent <Bullet>()) { //the score seemed to be like binary so thought I'd just calculate for any size if the player didn't die already. //added more to score while dead so fixed that. if (!AsteraX.DEAD) { playerController.AddPoints((int)Mathf.Pow(2, _asteroidInfo.size - size) * 100); Achievements.ASTEROIDS_HIT++; Achievements.AchievementCheck(); if (collision.gameObject.GetComponent <Bullet>().bulletWrapped) { Achievements.BULLET_WRAP_COUNT++; Achievements.AchievementCheck(); } } UIScript.UpdateScore(playerController.GetScore()); Destroy(collision.gameObject); } for (int i = 0; i < childCount; i++) { Transform child = transform.GetChild(0); child.SetParent(null, true); if (child.GetComponent <Asteroid>()) { Asteroid asteroidComp = child.GetComponent <Asteroid>(); asteroidComp.EnableRB(); asteroidComp.AddForceFromPoint(collisionPosition, Random.Range(_asteroidInfo.minVelocity, _asteroidInfo.maxVelocity)); asteroidComp.AddAngularVelocity(Random.insideUnitSphere * _asteroidInfo.maxAngularVelocity); } } //dont need to check for get component since this is the component its looking for. AsteraX.RemoveAsteroid(this); //starts onDestroy Event onDestroy.Invoke(); AsteraX.ExplosionEffect(transform, size); //destroys this asteroid #if MOBILE_INPUT foreach (GameObject col in compoundColliders) { Destroy(col); } #endif Destroy(gameObject); }
public void Fire() { if (bullet != null && firingPoint != null) { Achievements.BULLETS_FIRED++; Achievements.AchievementCheck(); Vector3 firingVector = firingPoint.position; firingVector.z = 0; Instantiate(bullet, firingVector, firingPoint.rotation); } }
//pause public void SetPause() { _pause = UIScript.Paused(); if (_pause) { Time.timeScale = 0; Achievements.AchievementCheck(); UIScript.ShowPause(true); } else { Time.timeScale = 1; UIScript.ShowPause(false); } }
public void RemovePoints(int amount) { _score = _score - amount > 0 ? _score - amount : 0; Achievements.SCORE = _score; Achievements.AchievementCheck(); }
public void AddPoints(int amount) { _score = _score + amount < _MAXSCORE ? _score + amount : _MAXSCORE; Achievements.SCORE = _score; Achievements.AchievementCheck(); }