//EDIT: Removed ScoreManager and added score to the player. //since the return to pool message is called on enemies when they die, this works void UpdateScore(ReturnToPool <EnemyBehaviour> enemy) { actualScore += enemy.value.PointValue * scoreMultiplier; CurrentScore = Mathf.RoundToInt(actualScore); enemiesKilled++; if (enemiesKilled >= enemiesForMulGain) { enemiesKilled = 0; scoreMultiplier += scoreMulGain; Message <ScoreMultiplierChanged> .Raise(new ScoreMultiplierChanged(scoreMultiplier, scoreMulGain)); } //update score, then update UI scoreDisplay.text = CurrentScore.ToScoreString(scoreLength); }
void SpawnPowerup(ReturnToPool <EnemyBehaviour> rEnemy) { //verify spawn if (Random.value < spawnChance) { //Get a random powerup var toSpawn = powerups[Random.Range(0, powerups.Length)]; //initialize object var spawned = M_GetPoolObject(); spawned.transform.position = rEnemy.transform.position; //set powerup (also enables the object) spawned.Powerup = toSpawn; spawnChance = baseSpawnChance; } else { //increase the spawnChance. spawnChance += ((1f - baseSpawnChance) / (float)enemyCountToAlwaysSpawn); } }
public void ReturnObjectToPool(ReturnToPool <T> obj) { //print("hello world"); obj.value.gameObject.SetActive(false); pooledObjects.Enqueue(obj); }