void SpawnMissile() { RecycleObject missile = missileFactory.Get(); missile.Activate(GetMissileSpawnPosition(), buildingManager.GetRandomBuildingPosition()); missile.Destroyed += OnMissileDestroyed; missile.OutOfScreen += OnMissileOutOfScreen; missiles.Add(missile); currentMissileCount++; }
void OnBulletDestroyed(RecycleObject usedBullet) { Vector3 lastBulletPosition = usedBullet.transform.position; usedBullet.Destroyed -= OnBulletDestroyed; bulletFactory.Restore(usedBullet); RecycleObject explosion = explosionFactory.Get(); explosion.Activate(lastBulletPosition); explosion.Destroyed += OnExplosionDestroyed; AudioManager.instance.PlaySound(SoundID.BulletExplosion); }
public void OnFireButtonPressed(Vector3 position) { if (!canShoot) { return; } RecycleObject bullet = bulletFactory.Get(); bullet.Activate(firePosition.position, position); bullet.Destroyed += OnBulletDestroyed; AudioManager.instance.PlaySound(SoundID.Shoot); canShoot = false; }
void OnBuildingDestryed(Building building) { AudioManager.instance.PlaySound(SoundID.BuildingExplosion); RecycleObject effect = effectFactory.Get(); effect.Activate(building.transform.position); effect.Destroyed += OnEffectDestroyed; building.Destroyed -= OnBuildingDestryed; int index = buildings.IndexOf(building); buildings.RemoveAt(index); GameObject.Destroy(building.gameObject); if (buildings.Count == 0) { AllBuildingsDestroyed?.Invoke(); } }