public override void Reset(GameObject shooterGameObject) { //Sets start delay currentDelay = new Timer(startDelay, 0); GameObjectsTransformList tl = shooterGameObject.GetComponent <GameObjectsTransformList>(); for (int i = 0; i < spreadShotList.Count; i++) { spreadShotList[i].bulletSpawnPosition.Clear(); //If there is bulletspawns and the transformlist is not empty if (spreadShotList[i].bulletSpawnList.Count > 0 && tl.transformList.Count > 0 && tl != null) { for (int pi = 0; pi < spreadShotList[i].bulletSpawnList.Count; pi++) { for (int si = 0; si < spreadShotList[i].bulletSpawnList[pi].spawnPointIndex.Length; si++) { //If that transform isn't null if (tl.transformList[spreadShotList[i].bulletSpawnList[pi].phaseIndex].bulletSpawnList[spreadShotList[i].bulletSpawnList[pi].spawnPointIndex[si]] != null) { bool alreadyInList = false; //Checks if if that transform already is being used for (int t = 0; t < spreadShotList[i].bulletSpawnPosition.Count; t++) { //If that transform is being used, break and set bool to true if (spreadShotList[i].bulletSpawnPosition[t] == tl.transformList[spreadShotList[i].bulletSpawnList[pi].phaseIndex].bulletSpawnList[spreadShotList[i].bulletSpawnList[pi].spawnPointIndex[si]]) { alreadyInList = true; break; } } //Add it if it isn't in the list if (alreadyInList == false) { spreadShotList[i].bulletSpawnPosition.Add(tl.transformList[spreadShotList[i].bulletSpawnList[pi].phaseIndex].bulletSpawnList[spreadShotList[i].bulletSpawnList[pi].spawnPointIndex[si]]); } } } } } if (spreadShotList[i].bulletSpawnPosition.Count == 0) { spreadShotList[i].bulletSpawnPosition.Add(shooterGameObject.transform); } } for (int i = 0; i < spreadShotList.Count; i++) { spreadShotList[i].shotIndex = 0; listIndex = 0; currentWave = 1; } ClampValues(); }
public override void Reset(GameObject shooterGameObject) { spawnList.Clear(); //Gets the objects TransfromList GameObjectsTransformList tl = shooterGameObject.GetComponent <GameObjectsTransformList>(); //If there is bulletspawns and the transformlist is not empty if (bulletSpawnList.Count > 0 && tl.transformList.Count > 0 && tl != null) { for (int pi = 0; pi < bulletSpawnList.Count; pi++) { for (int si = 0; si < bulletSpawnList[pi].spawnPointIndex.Length; si++) { //If that transform isn't null if (tl.transformList[bulletSpawnList[pi].phaseIndex].bulletSpawnList[bulletSpawnList[pi].spawnPointIndex[si]] != null) { bool alreadyInList = false; //Checks if if that transform already is being used for (int t = 0; t < spawnList.Count; t++) { //If that transform is being used, break and set bool to true if (spawnList[t] == tl.transformList[bulletSpawnList[pi].phaseIndex].bulletSpawnList[bulletSpawnList[pi].spawnPointIndex[si]]) { alreadyInList = true; break; } } //Add it if it isn't in the list if (alreadyInList == false) { spawnList.Add(tl.transformList[bulletSpawnList[pi].phaseIndex].bulletSpawnList[bulletSpawnList[pi].spawnPointIndex[si]]); } } } } } //If a point is null in the list, remove it for (int i = 0; i < spawnList.Count; i++) { if (spawnList[i] == null) { spawnList.RemoveAt(i); i--; } } //If the list is empy, add itself if (spawnList.Count == 0) { spawnList.Add(shooterGameObject.transform); } actualRotation = -(360f / (float)bulletsPerWave); rotateTimer = -rotateSpeed / fireRate; shootTimer = 1; ClampValues(); }
public override void Reset(GameObject shooterGameObject) { player = GameObject.FindGameObjectWithTag("Player"); currentDelay = new Timer(startDelay, 0); bulletSpawnPosition.Clear(); GameObjectsTransformList tl = shooterGameObject.GetComponent <GameObjectsTransformList>(); //If there is bulletspawns and the transformlist is not empty if (bulletSpawnList.Count > 0 && tl.transformList.Count > 0 && tl != null) { for (int pi = 0; pi < bulletSpawnList.Count; pi++) { for (int si = 0; si < bulletSpawnList[pi].spawnPointIndex.Length; si++) { //If that transform isn't null if (tl.transformList[bulletSpawnList[pi].phaseIndex].bulletSpawnList[bulletSpawnList[pi].spawnPointIndex[si]] != null) { bool alreadyInList = false; //Checks if if that transform already is being used for (int t = 0; t < bulletSpawnPosition.Count; t++) { //If that transform is being used, break and set bool to true if (bulletSpawnPosition[t] == tl.transformList[bulletSpawnList[pi].phaseIndex].bulletSpawnList[bulletSpawnList[pi].spawnPointIndex[si]]) { alreadyInList = true; break; } } //Add it if it isn't in the list if (alreadyInList == false) { bulletSpawnPosition.Add(tl.transformList[bulletSpawnList[pi].phaseIndex].bulletSpawnList[bulletSpawnList[pi].spawnPointIndex[si]]); } } } } } //Removes empty spawns for (int i = 0; i < bulletSpawnPosition.Count; i++) { if (bulletSpawnPosition[i] == null) { bulletSpawnList.RemoveAt(i); i--; } } //If it does not have spawnpoint, set it as the own if (bulletSpawnPosition.Count == 0) { bulletSpawnPosition.Add(shooterGameObject.transform); } //Aim directly at player if it has if (aimAtPlayerAtStart == true) { for (int i = 0; i < bulletSpawnPosition.Count; i++) { Vector2 targetDir = bulletSpawnPosition[i].position - player.transform.position; bulletSpawnPosition[i].rotation = Quaternion.LookRotation(targetDir, Vector3.forward); } } delayBetweenBullets = timePerWave / (float)bulletsPerWave; ClampValues(); }