Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. foreach (var pointer in Game.BufferShoots)
  2. {
  3. ref var source = ref Game.BufferShoots[pointer];
  4. ref var position = ref source.position;
  5. ref var timer = ref source.timer;
  6.  
  7. var nTarget = Phys.GetRay2D(position, source.direction, source.direction.x * delta, source.mask);
  8.  
  9. if (nTarget.entity.Exist)
  10. {
  11. source.bullet.gameObject.Release(Pool.Entities);
  12. Game.BufferShoots.Remove(pointer);
  13.  
  14. // Add Attack
  15. ref var sAttack = ref Game.bufferAttacks.Add();
  16. sAttack.attackDirection = source.direction.normalized;
  17. sAttack.damage = (int) source.damage;
  18. sAttack.target = nTarget.entity;
  19. sAttack.attackPosition = position;
  20.  
  21. continue;
  22. }
  23.  
  24. position.x += source.direction.x * delta;
  25. position.y += source.direction.y * delta;
  26.  
  27. source.bullet.position = position;
  28.  
  29. if ((timer -= delta) <= delta)
  30. {
  31. source.bullet.gameObject.Release(Pool.Entities);
  32. Game.BufferShoots.Remove(pointer);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement