Advertisement
Guest User

pls

a guest
Mar 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6.  
  7.  
  8. public class GameController : MonoBehaviour
  9. {
  10. public GameObject hazard;
  11. public Vector3 spawnValues;
  12. public int hazardCount;
  13. public float spawnWait;
  14. public float startWait;
  15. public float waveWait;
  16.  
  17. private GUIText scoreText;
  18. private int score;
  19.  
  20. void Start()
  21. {
  22. score = 0;
  23. UpdateScore();
  24. StartCoroutine(SpawnWaves());
  25. }
  26.  
  27. IEnumerator SpawnWaves()
  28. {
  29. yield return new WaitForSeconds(startWait);
  30. while (true)
  31. {
  32. for (int i = 0; i < hazardCount; i++)
  33. {
  34. Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
  35. Quaternion spawnRotation = Quaternion.identity;
  36. Instantiate(hazard, spawnPosition, spawnRotation);
  37. yield return new WaitForSeconds(spawnWait);
  38. }
  39. yield return new WaitForSeconds(waveWait);
  40. }
  41. }
  42.  
  43. public void AddScore(int newScoreValue)
  44. {
  45. score += newScoreValue;
  46. UpdateScore();
  47. }
  48.  
  49. void UpdateScore()
  50. {
  51. scoreText.text = "Score: " + score;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement