Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Generation : MonoBehaviour {
  5.  
  6. public GameObject Prefab1;
  7. public GameObject Prefab2;
  8. public GameObject Prefab3;
  9. public GameObject Prefab4;
  10. public GameObject Prefab5;
  11. public float Timer = 1;
  12. public float Xposition = 0;
  13. public float Yposition = 6;
  14. public float areaA = 0.0f;
  15. public float areaB = 4.0f;
  16.  
  17. // Use this for initialization
  18. void Start () {
  19. StartCoroutine(Loop(Timer));
  20. }
  21.  
  22. // Update is called once per frame
  23. void Update () {
  24.  
  25. }
  26.  
  27. // Update is called once per frame
  28. private IEnumerator Loop (float time) {
  29. while (true){
  30. yield return new WaitForSeconds(Timer);
  31. float area = Random.Range(areaA,areaB);
  32. int seisuu = Random.Range(0,5);
  33. var array = new []{Prefab1,Prefab2,Prefab3,Prefab4,Prefab5};
  34.  
  35. Instantiate(array[seisuu],new Vector2(area,Yposition),Quaternion.identity);
  36. }
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement