Permalink
Cannot retrieve contributors at this time
using UnityEngine; | |
using System.Collections; | |
public class EnemySpawner : MonoBehaviour { | |
//Numbers | |
public int randomNum = 0; | |
//Enemy Spawns | |
public GameObject enemy1_left1; | |
public int enemy1count = 0; | |
public GameObject enemy1_left2; | |
public GameObject enemy1_left3; | |
public GameObject enemy1_right1; | |
public GameObject enemy1_right2; | |
public GameObject enemy1_right3; | |
//vectors | |
public Vector3 spawn1 = new Vector3(-17.0f, 17.0f, 5.0f); | |
public Vector3 spawn2 = new Vector3(-14.0f, 17.0f, 5.0f); | |
public Vector3 spawn3 = new Vector3(-11.0f, 17.0f, 5.0f); | |
public Vector3 spawn4 = new Vector3(-8.0f, 17.0f, 5.0f); | |
public Vector3 spawn5 = new Vector3(-5.0f, 17.0f, 5.0f); | |
public Vector3 spawn6 = new Vector3(-2.0f, 17.0f, 5.0f); | |
public Vector3 spawn7 = new Vector3(1.0f, 17.0f, 5.0f); | |
public Vector3 spawn8 = new Vector3(4.0f, 17.0f, 5.0f); | |
public Vector3 spawn9 = new Vector3(7.0f, 17.0f, 5.0f); | |
public Vector3 spawn10 = new Vector3(10.0f, 17.0f, 5.0f); | |
public Vector3 spawn11 = new Vector3(13.0f, 17.0f, 5.0f); | |
public Vector3 spawn12 = new Vector3(16.0f, 17.0f, 5.0f); | |
public Vector3 enemyAngle = new Vector3 (0.0f, 90.0f, 270.0f); | |
//Enemy Types | |
public GameObject enemy1; | |
public GameObject enemy2; | |
// Use this for initialization | |
void Start () { | |
randomNum = 1; | |
} | |
public void Onslaught() | |
{ | |
// randomNum = Random.Range (1,3); | |
StartCoroutine(EnemySpawn()); | |
} | |
// Update is called once per frame | |
void Update () { | |
if (randomNum > 0) | |
Onslaught(); | |
} | |
public void EdgeSpawn() | |
{ | |
enemy1_left1 = (GameObject)Instantiate(enemy1, spawn1, Quaternion.Euler(enemyAngle)); | |
enemy1_right1 = (GameObject)Instantiate(enemy1, spawn12, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("LeftCurve1"), "time", 10)); | |
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("RightCurve1"), "time", 10)); | |
} | |
public void EdgeSpawnIn() | |
{ | |
enemy1_left2 = (GameObject)Instantiate(enemy1, spawn2, Quaternion.Euler(enemyAngle)); | |
enemy1_right2 = (GameObject)Instantiate(enemy1, spawn11, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left2, iTween.Hash("path", iTweenPath.GetPath("LeftCurve2"), "time", 10)); | |
iTween.MoveTo(enemy1_right2, iTween.Hash("path", iTweenPath.GetPath("RightCurve2"), "time", 10)); | |
} | |
public void EdgeSpawnLast() | |
{ | |
enemy1_left3 = (GameObject)Instantiate(enemy1, spawn3, Quaternion.Euler(enemyAngle)); | |
enemy1_right3 = (GameObject)Instantiate(enemy1, spawn10, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left3, iTween.Hash("path", iTweenPath.GetPath("LeftCurve3"), "time", 10)); | |
iTween.MoveTo(enemy1_right3, iTween.Hash("path", iTweenPath.GetPath("RightCurve3"), "time", 10)); | |
} | |
public void MidSpawnEdges() | |
{ | |
enemy1_left1 = (GameObject)Instantiate(enemy2, spawn4, Quaternion.Euler(enemyAngle)); | |
enemy1_right1 = (GameObject)Instantiate(enemy2, spawn9, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Left 1"), "time", 10)); | |
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Right 1"), "time", 10)); | |
} | |
public void MidSpawnMids() | |
{ | |
enemy1_left1 = (GameObject)Instantiate(enemy2, spawn5, Quaternion.Euler(enemyAngle)); | |
enemy1_right1 = (GameObject)Instantiate(enemy2, spawn8, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Left 2"), "time", 10)); | |
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("CrossPath Mid-Right 2"), "time", 10)); | |
} | |
//IEnumerator | |
IEnumerator EnemySpawn() | |
{ | |
if (enemy1count < 1) | |
{ | |
if (randomNum == 1) | |
{ | |
Debug.Log("Enumerator Starts"); | |
enemy1count = 1; | |
enemy1_left1 = (GameObject)Instantiate(enemy1, spawn1, Quaternion.Euler(enemyAngle)); | |
enemy1_right1 = (GameObject)Instantiate(enemy1, spawn12, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left1, iTween.Hash("path", iTweenPath.GetPath("LeftCurve1"), "time", 10)); | |
iTween.MoveTo(enemy1_right1, iTween.Hash("path", iTweenPath.GetPath("RightCurve1"), "time", 10)); | |
// EdgeSpawn(); | |
yield return new WaitForSeconds(0.2f); | |
enemy1_left2 = (GameObject)Instantiate(enemy1, spawn2, Quaternion.Euler(enemyAngle)); | |
enemy1_right2 = (GameObject)Instantiate(enemy1, spawn11, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left2, iTween.Hash("path", iTweenPath.GetPath("LeftCurve2"), "time", 10)); | |
iTween.MoveTo(enemy1_right2, iTween.Hash("path", iTweenPath.GetPath("RightCurve2"), "time", 10)); | |
// EdgeSpawnIn(); | |
yield return new WaitForSeconds(0.2f); | |
enemy1_left3 = (GameObject)Instantiate(enemy1, spawn3, Quaternion.Euler(enemyAngle)); | |
enemy1_right3 = (GameObject)Instantiate(enemy1, spawn3, Quaternion.Euler(enemyAngle)); | |
iTween.MoveTo(enemy1_left3, iTween.Hash("path", iTweenPath.GetPath("LeftCurve3"), "time", 10)); | |
iTween.MoveTo(enemy1_right3, iTween.Hash("path", iTweenPath.GetPath("RightCurve3"), "time", 10)); | |
// EdgeSpawnLast(); | |
yield return new WaitForSeconds(2f); | |
MidSpawnEdges(); | |
yield return new WaitForSeconds(2f); | |
MidSpawnMids(); | |
yield return new WaitForSeconds(2f); | |
EdgeSpawn(); | |
MidSpawnEdges(); | |
yield return new WaitForSeconds(2f); | |
Debug.Log("enumerator Ends"); | |
} | |
} | |
yield return new WaitForSeconds(1f); | |
} | |
} |