Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void Attack()
- {
- switch(states)
- {
- case SniperState.patrol:
- if (Vector3.Distance(transform.position, player.transform.position) < area)
- {
- states = SniperState.prepare;
- timer = 0;
- }
- break;
- case SniperState.prepare:
- timer += Time.deltaTime;
- transform.LookAt(player.transform.position);
- if (timer >= coolDown)
- states = SniperState.fire;
- break;
- case SniperState.fire:
- GameObject buf = Instantiate(bullet);
- buf.transform.position = riffleStart.transform.position;
- buf.transform.rotation = transform.rotation;
- buf.GetComponent<Bullet>().setDirection(transform.forward);
- timer = 0;
- states = SniperState.patrol;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement