// Update is called once per frame void Update() { while (Time.timeSinceLevelLoad > currEnemy.spawnTime + loopOffset) { print("spawning enemy " + currEnemyIdx + " at time " + currEnemy.spawnTime); GameObject enemyType; switch (currEnemy.enemyType) { case 1: enemyType = EnemyType1; break; case 2: enemyType = EnemyType2; break; case 3: default: enemyType = EnemyType3; break; } GameObject clone = (GameObject)Instantiate(enemyType, currEnemy.spawnPos, Quaternion.identity); clone.transform.parent = this.transform; EnemyType1 script = (EnemyType1)clone.GetComponent("EnemyType1"); script.SetParams(transform.position + currEnemy.spawnPos, transform.position + currEnemy.endPos, currEnemy.speed); EnemyShoot script2 = (EnemyShoot)clone.GetComponent("EnemyShoot"); script2.target = PlayerTarget; currEnemyIdx = (currEnemyIdx + 1) % enemySpawns.Count; currEnemy = (EnemySpawn)enemySpawns[currEnemyIdx]; if (currEnemyIdx == 0) { loopOffset = Time.timeSinceLevelLoad + 5; print("restarting spawn loop"); } } }
void OnTriggerEnter(Collider info) { if (info.tag == "Player" && !steppedOn) { if (enemyType == 1) { enm1 = enemy.GetComponent <EnemyType1> () as EnemyType1; enm1.SpawnEnemy1(GameObject.FindGameObjectWithTag("Player"), spawnPoint); } else { enm2 = enemy.GetComponent <EnemyType2> () as EnemyType2; enm2.SpawnEnemy2(GameObject.FindGameObjectWithTag("Player"), spawnPoint); } steppedOn = true; } }
public override void Reset() { if (type == 1) { scType1 = gameObject.GetComponent <EnemyType1> () as EnemyType1; scType1.enabled = true; SpawnPos = scType1.GetSpawnPosition(); scType1.OnReset(); } else { scType2 = gameObject.GetComponent <EnemyType2> () as EnemyType2; scType2.enabled = true; SpawnPos = scType2.GetSpawnPosition(); scType2.OnReset(); } transform.position = SpawnPos; bxCol = GetComponent <BoxCollider> () as BoxCollider; bxCol.enabled = true; }
// add detection radius mechanic void Awake() { _type1instance = this; SetSprChild(sprChild); base.Deactivate(); }
public ShootPlayer(EnemyType1 enemy) { _enemyType1 = enemy; }
public ZigZagMovement(EnemyType1 enemy) { _enemyType1 = enemy; }