private void Start() { Damagable damagable = GetComponent <Damagable>(); BlockLevel level = FindObjectOfType <BlockLevel>(); Audible audible = GetComponent <Audible>(); damagable.RegisterOnKilled((d) => audible.playSound()); damagable.RegisterOnKilled((d) => level.removeBlock(d)); Animatable animatable = GetComponent <Animatable>(); damagable.RegisterOnDamaged((healthRemaining) => animatable.changeSprite(healthRemaining)); }
public void SpawnLevel() { // restart the current level if (LaunchBlockInstance != null) { LaunchBlockInstance.DestroyLaunchedProjectiles(); } _allBlocks.Clear(); BlockLevel.DeleteAllTheThings(); var level = _levels[_index]; level.gameObject.SetActive(true); level.SpawnLevel(_allBlocks); Score.ShotsFired = 0; Score.MaxStars = Block.GetCount(Block.Type.Special); TimeController.ResumeTime(); NextLevelStartTime = -1.0f; }
private void Awake() { if (FindObjectsOfType <GameSession>().Length > 1) { gameObject.SetActive(false); Destroy(gameObject); } else { DontDestroyOnLoad(gameObject); } foreach (Damagable d in FindObjectsOfType <Damagable>()) { d.RegisterOnKilled((damagable) => ChangeScore(damagable.getPointValue())); } BlockLevel level = FindObjectOfType <BlockLevel>(); level.updateScore(score); onScoreUpdated.RemoveAllListeners(); onScoreUpdated.AddListener((score) => level.updateScore(score)); }