Advertisement
kadyr

Untitled

Oct 9th, 2021
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. protected override void Attack()
  2. {
  3. switch(states)
  4. {
  5. case SniperState.patrol:
  6. if (Vector3.Distance(transform.position, player.transform.position) < area)
  7. {
  8. states = SniperState.prepare;
  9. timer = 0;
  10. }
  11. break;
  12. case SniperState.prepare:
  13. timer += Time.deltaTime;
  14. transform.LookAt(player.transform.position);
  15. if (timer >= coolDown)
  16. states = SniperState.fire;
  17. break;
  18. case SniperState.fire:
  19. GameObject buf = Instantiate(bullet);
  20. buf.transform.position = riffleStart.transform.position;
  21. buf.transform.rotation = transform.rotation;
  22. buf.GetComponent<Bullet>().setDirection(transform.forward);
  23. timer = 0;
  24. states = SniperState.patrol;
  25. break;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement