Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
SpaceShooter/SpaceShooter/Assets/Scripts/Enemy Game Controllers/GameController_1.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
119 lines (94 sloc)
2.77 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class GameController_1 : MonoBehaviour | |
{ | |
public GameObject hazard_1; | |
public Vector2 spawnValues_1; | |
public int hazardCount_1; | |
public float spawnWait_1; | |
public float startWait_1; | |
public float waveWait_1; | |
void Start() | |
{ | |
StartCoroutine(SpawnWaves()); | |
} | |
IEnumerator SpawnWaves() | |
{ | |
yield return new WaitForSeconds(startWait_1); | |
while (true) | |
{ | |
for (int i = 0; i < hazardCount_1; i++) | |
{ | |
Vector2 spawnPosition = new Vector2(Random.Range(-spawnValues_1.x, spawnValues_1.x), spawnValues_1.y); | |
Quaternion spawnRotation = Quaternion.identity; | |
Instantiate(hazard_1, spawnPosition, spawnRotation); | |
yield return new WaitForSeconds(spawnWait_1); | |
} | |
yield return new WaitForSeconds(waveWait_1); | |
} | |
} | |
//By level UFO Update | |
void Update() | |
{ | |
//level 1 | |
if (ScoreScript.scoreValue >= 100 && ScoreScript.scoreValue < 200) | |
{ | |
hazardCount_1 = 2; | |
spawnWait_1 = .70f; | |
waveWait_1 = 10; | |
} | |
//level 2 | |
if (ScoreScript.scoreValue >= 200 && ScoreScript.scoreValue < 300) | |
{ | |
hazardCount_1 = 3; | |
spawnWait_1 = .60f; | |
waveWait_1 = 9; | |
} | |
//level 3 | |
if (ScoreScript.scoreValue >= 300 && ScoreScript.scoreValue < 400) | |
{ | |
hazardCount_1 = 4; | |
spawnWait_1 = .60f; | |
waveWait_1 = 9; | |
} | |
// level 4 | |
if (ScoreScript.scoreValue >= 400 && ScoreScript.scoreValue < 500) | |
{ | |
hazardCount_1 = 4; | |
spawnWait_1 = .50f; | |
waveWait_1 = 9; | |
} | |
//From level 5 and onwards | |
if (ScoreScript.scoreValue >= 500 && ScoreScript.scoreValue < 1000000000) | |
{ | |
hazardCount_1 = 5; | |
spawnWait_1 = .50f; | |
waveWait_1 = 8; | |
} | |
if (ScoreScript.scoreValue >= 600 && ScoreScript.scoreValue < 700) | |
{ | |
hazardCount_1 = 5; | |
spawnWait_1 = .50f; | |
waveWait_1 = 7; | |
} | |
if (ScoreScript.scoreValue >= 700 && ScoreScript.scoreValue < 800) | |
{ | |
hazardCount_1 = 6; | |
spawnWait_1 = .50f; | |
waveWait_1 = 7; | |
} | |
if (ScoreScript.scoreValue >= 800 && ScoreScript.scoreValue < 900) | |
{ | |
hazardCount_1 = 6; | |
spawnWait_1 = .45f; | |
waveWait_1 = 6; | |
} | |
if (ScoreScript.scoreValue >= 900 ) | |
{ | |
hazardCount_1 = 7; | |
spawnWait_1 = .40f; | |
waveWait_1 = 7; | |
} | |
} | |
} |