Advertisement
Guest User

help

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