Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class EnemyBehavior : MonoBehaviour {
  6. float timer;
  7. public float time;
  8. Vector3 one = new Vector3(-8.5f, 3, 0);
  9. Vector3 two = new Vector3(-8.5f, -0.3f, 0);
  10. Vector3 three = new Vector3(-8.5f, -3.3f, 0);
  11. int lane = 0;
  12. public Transform fly;
  13.  
  14. void Timer()
  15. {
  16. timer -= Time.deltaTime;
  17. if (timer <= 0.0f)
  18. {
  19. /*if (gameObject.tag == "flying")
  20. {
  21. findLane();
  22. int r = Random.Range(1, 3);
  23. if(lane == 1 && r == 1 || lane == 3 && r == 1)
  24. {
  25. gameObject.transform.position = two;
  26. }
  27. else if(lane == 1 && r == 2 || lane == 2 && r == 2)
  28. {
  29. gameObject.transform.position = three;
  30. }
  31. else if (lane == 2 && r == 1 || lane == 3 && r == 1)
  32. {
  33. gameObject.transform.position = one;
  34. }
  35. }*/
  36. Destroy(this.gameObject);
  37. timer = time;
  38. }
  39. }
  40.  
  41. void findLane()
  42. {
  43. if (transform.position.y == 3)
  44. {
  45. lane += 1;
  46. }
  47. else if (transform.position.y == -0.3f)
  48. {
  49. lane += 2;
  50. }
  51. else if (transform.position.y == -3.3f)
  52. {
  53. lane += 3;
  54. }
  55. }
  56. // Use this for initialization
  57. void Start () {
  58. timer = time;
  59. }
  60.  
  61. void move()
  62. {
  63. transform.Translate(-0.08f, 0, 0);
  64. }
  65.  
  66. // Update is called once per frame
  67. void Update () {
  68. move();
  69. Timer();
  70. Debug.Log(lane.ToString());
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement