BulletManager.cs 815 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections.Generic;
  2. public class BulletManager
  3. {
  4. readonly List<Bullet> mBullets = new List<Bullet> ();
  5. public List<Bullet> AllBullets { get { return mBullets; } }
  6. public int BulletCnt
  7. {
  8. get { return mBullets.Count; }
  9. }
  10. public void Update (float deltaTime)
  11. {
  12. for (int i = mBullets.Count - 1; i >= 0; i--) {
  13. if (mBullets [i].IsDisposed)
  14. mBullets.RemoveAt (i);
  15. else
  16. mBullets [i].Update (deltaTime);
  17. }
  18. }
  19. public void Add (Fighter caster,Fighter target, SkillActionAttackInfo attackInfo,BattleBuff battleBuff)
  20. {
  21. mBullets.Add (new Bullet (caster, target, attackInfo, battleBuff));
  22. }
  23. public void Clear ()
  24. {
  25. for (int i = mBullets.Count - 1; i >= 0; i--) {
  26. if (!mBullets [i].IsDisposed)
  27. mBullets [i].Dispose ();
  28. }
  29. mBullets.Clear ();
  30. }
  31. }