Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GameControl : MonoBehaviour {
  6.  
  7. public GameObject lanePrefab;
  8. public int numberOfLanes = 20;
  9.  
  10. // Use this for initialization
  11. void Start () {
  12. int laneNumber = 0;
  13. while(laneNumber < numberOfLanes)
  14. {
  15. GameObject go = (GameObject)Instantiate(lanePrefab);
  16. Vector3 pos = new Vector3(0, 0, laneNumber * 3);
  17. go.GetComponent<Transform>().position = pos;
  18.  
  19. bool pf = Random.Range(0, 1) == 1 ? true : false;
  20. go.GetComponent<LaneController>().positiveFlow = pf;
  21. bool tr = Random.Range(0, 5) == 1 ? false : true;
  22. go.GetComponent<LaneController>().traffic= tr;
  23. float dens = Random.Range(0.001f, 0.02f);
  24. go.GetComponent<LaneController>().density = dens;
  25. float spd = Random.Range(1.0f, 20.0f);
  26. go.GetComponent<LaneController>().speed = spd;
  27.  
  28. laneNumber = laneNumber + 1;
  29. }
  30. }
  31.  
  32. // Update is called once per frame
  33. void Update () {
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement