Example #1
0
    private GameObject _SpawnEnemy(EnemyData enemy, int lane)
    {
        GameObject enemyUnit     = enemy.CreateInstance();
        Vector3    spawnPosition = Vector3.zero;

        if (m_enemyWall != null)
        {
            if (lane < 0)
            {
                lane = Random.Range(0, m_Lane.Count - 1);
            }
            else if (lane >= m_Lane.Count)
            {
                lane = m_Lane.Count - 1;
            }

            spawnPosition = new Vector3(m_enemyWall.transform.position.x, m_Lane[lane].transform.position.y, 0);
        }
        else
        {
            Debug.LogError("Enemy wall is missing recheck at " + this.name);
        }
        enemyUnit.transform.position = spawnPosition;
        enemyUnit.SetActive(true);
        return(enemyUnit);
    }