void Start() { //EnInfoScript = transform.GetComponent<Scr_Enemy_info>(); EnInfoScript = new Scr_Enemy_info.BasicEnemy(unit, unit.GetComponent <Rigidbody2D>()); ShootEnable = true; StartCoroutine(EntranceDelayShoot(3)); StartCoroutine(EnemyAI()); }
//Optional Vector2 enterLoc is there for locations in which unit enters the scene. public IEnumerator spawnFunct(Vector2 source, Vector2 offset, float SpawnNum , Vector2 EnterLoc, float EnterTime) { Vector2 diff = source + offset; for (int i = 0; i < SpawnNum; i++) { Debug.Log("Spawn!"); GameObject spawn = (GameObject)Instantiate(enemytoSpawn, diff, Quaternion.identity); SpawnList.Add(spawn); Scr_Enemy_info.BasicEnemy temp = new Scr_Enemy_info.BasicEnemy(spawn, spawn.GetComponent <Rigidbody2D>()); // temp.moveTo(new Vector2(1, 2), 1.5f); StartCoroutine(temp.moveTo(EnterLoc, EnterTime)); yield return(new WaitForSeconds(timebetweenSpawn)); } }