public void ResetGame() { velocity = initialVelocity; // remove all active buildings foreach (var building in activeBuildings) { Destroy(building.gameObject); } activeBuildings.Clear(); Vector3 startPos = startBuilding.transform.localPosition; startPos.x = 0f; startBuilding.transform.localPosition = startPos; SpawnNewBuilding(new Vector3(24f, -1f, 0f)); SpawnNewBuilding(new Vector3(48f, -1f, 0f)); foreach (var building in toBeAdded) { activeBuildings.Add(building); } toBeAdded.Clear(); foreach (var obj in FindObjectsOfType(typeof(RunnerGamePowerup))) { RunnerGamePowerup powerup = obj as RunnerGamePowerup; Destroy(powerup.gameObject); } }
void SpawnPowerup(Combo combo, Vector3 pos) { Debug.Log("Spawning powerup with shape: " + combo.shape); RunnerGamePowerup newPowerup = Instantiate(powerup) as RunnerGamePowerup;; switch (combo.shape) { case Combo.Shape.Shape0: newPowerup.shape = Combo.Shape.Shape0; break; case Combo.Shape.Shape1: newPowerup.shape = Combo.Shape.Shape1; break; case Combo.Shape.Shape2: newPowerup.shape = Combo.Shape.Shape2; break; } newPowerup.transform.parent = transform; Vector3 spawnPos = pos; newPowerup.transform.localPosition = spawnPos; newPowerup.world = world; newPowerup.GetComponent <ComboIndicator>().SetCombo(combo); }