Beispiel #1
0
    IEnumerator SpawnBug(BugData data)
    {
        yield return(new WaitForSeconds(data.spawnTime));

        if (!data.flying)
        {
            Transform  spawnLocation = data.fromLeft ? leftGroundSpawn : rightGroundSpawn;
            GameObject bug           = Instantiate(groundBugPrefab, spawnLocation.position, Quaternion.identity);
            Bug        bugCtrl       = bug.GetComponent <Bug>();
            bugCtrl.Init(data);
            BossBug bossBugCtrl = bug.GetComponent <BossBug>();
            bossBugCtrl.Init(data.health);
        }
    }
    IEnumerator SpawnBug(BugData data)
    {
        yield return(new WaitForSeconds(data.spawnTime));

        if (!data.flying)
        {
            Transform  spawnLocation = data.fromLeft ? leftGroundSpawn : rightGroundSpawn;
            GameObject bug           = Instantiate(groundBugPrefab, spawnLocation.position, Quaternion.identity);
            Bug        bugCtrl       = bug.GetComponent <Bug>();
            bugCtrl.Init(data);
            LinearMove movementCtrl = bug.GetComponent <LinearMove>();
            movementCtrl.Init(data.fromLeft, data.speed);
        }
        else
        {
            Transform  spawnLocation = data.fromLeft ? leftAirSpawn : rightAirSpawn;
            GameObject bug           = Instantiate(airBugPrefab, spawnLocation.position, Quaternion.identity);
            Bug        bugCtrl       = bug.GetComponent <Bug>();
            bugCtrl.Init(data);
            SineMove movementCtrl = bug.GetComponent <SineMove>();
            movementCtrl.Init(data.fromLeft, data.speed, spawnLocation.position.y, -1, -1);
        }
    }
    IEnumerator SpawnBug(int subIndex, BugData data)
    {
        yield return(new WaitForSeconds(data.spawnTime));

        Transform spawnLocation = null;

        if (bugNum == 1)
        {
            spawnLocation = SpawnPosition1;
        }
        else if (bugNum == 2)
        {
            if (subIndex == 1)
            {
                spawnLocation = SpawnPosition21;
            }
            else if (subIndex == 2)
            {
                spawnLocation = SpawnPosition22;
            }
        }
        else if (bugNum == 3)
        {
            if (subIndex == 1)
            {
                spawnLocation = SpawnPosition31;
            }
            else if (subIndex == 2)
            {
                spawnLocation = SpawnPosition32;
            }
            else if (subIndex == 3)
            {
                spawnLocation = SpawnPosition33;
            }
        }
        else if (bugNum == 4)
        {
            if (subIndex == 1)
            {
                spawnLocation = SpawnPosition41;
            }
            else if (subIndex == 2)
            {
                spawnLocation = SpawnPosition42;
            }
            else if (subIndex == 3)
            {
                spawnLocation = SpawnPosition43;
            }
            else if (subIndex == 4)
            {
                spawnLocation = SpawnPosition44;
            }
        }

        GameObject bug     = Instantiate(groundBugPrefab, spawnLocation.position, Quaternion.identity);
        Bug        bugCtrl = bug.GetComponent <Bug>();

        bugCtrl.Init(data);
    }