SpermicidalWaveManager.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using UnityEngine;
  2. using System.Collections;
  3. public class SpermicidalWaveManager : MonoBehaviour
  4. {
  5. public PoolObject spermicidalWavePrefab;
  6. public Transform anchor;
  7. public SpermicidalWaveFollower spermicidalWaveParticleSystem;
  8. Pool _pool;
  9. public CondomDispenser condomDispenser;
  10. #region Unity Callbacks
  11. void Awake()
  12. {
  13. _pool = Pool.Create(spermicidalWavePrefab, 2);
  14. NotificationCenter.AddListener(OnFireSpermicidalWave, NotificationType.FireSpermicidalWave);
  15. }
  16. void OnDestroy()
  17. {
  18. NotificationCenter.RemoveListener(OnFireSpermicidalWave, NotificationType.FireSpermicidalWave);
  19. }
  20. #endregion
  21. void OnFireSpermicidalWave(Notification note)
  22. {
  23. SoundManager.Play(SoundEvent.spermicidalWaveFire);
  24. PoolObject wave = _pool.Spawn();
  25. condomDispenser.condoms.Add(wave.GetComponent<CondomBase>());
  26. Transform waveTransform = wave.transform;
  27. spermicidalWaveParticleSystem.StartFollowing(waveTransform);
  28. Vector3 originalScale = waveTransform.localScale;
  29. waveTransform.parent = anchor;
  30. waveTransform.localScale = originalScale;
  31. waveTransform.localPosition = Vector3.zero;
  32. }
  33. }