コード例 #1
0
    private IEnumerator GenerateClouds()
    {
        for (; ;)
        {
            Vector2 offset = new Vector2(0f, Random.Range(-2f, 2.5f));

            GameObject newCloud = CNExtensions.GetPooledObject(clouds, cloud, uiLayer, cloudGeneratorT, offset, Quaternion.identity, false);
            newCloud.GetComponent <SpriteRenderer>().sprite = cloudSprites[Random.Range(0, cloudSprites.Length)];
            CloudController cloudController = newCloud.GetComponent <CloudController>();
            cloudController.passingCloud = true;
            cloudController.cloudSpeed   = Random.Range(-0.5f, -0.2f);

            yield return(new WaitForSeconds(2f));
        }
    }
コード例 #2
0
    private IEnumerator GenerateRockets()
    {
        for (; ;)
        {
            if (gameState == GameState.gameplay)
            {
                GameObject newRocket = CNExtensions.GetPooledObject(rockets, rocket,
                                                                    defaultLayer, rocketGeneratorT, new Vector2(Random.Range(-1.5f, 1.5f), 0f), Quaternion.identity, false);
                RocketController rc = newRocket.GetComponent <RocketController>();
                SpriteRenderer   sr = newRocket.transform.GetChild(0).GetComponent <SpriteRenderer>();
                rc.speed  = rocketSpeed * (1 + currentSpeedMultiplier);
                sr.sprite = rocketSprites[Random.Range(0, rocketSprites.Length)];
            }
            else if (gameState == GameState.endgame)
            {
                yield break;
            }

            yield return(new WaitForSeconds(timeBetweenRocketLaunches));
        }
    }