Exemplo n.º 1
0
    public void spawn()
    {
        int type = Random.Range(0, (powerUps.Count) / 3) * 3;

        for (int a = 0; a < 3; a++)
        {
            if (!powerUps[type + a].gameObject.activeInHierarchy)
            {
                powerUps[type + a].spawn(leftBound, rightBound, astroids.getSpeed());
                break;
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator spawnComet()
    {
        running = true;

        //hold astroid generation
        astroidGenerator.enabled = false;
        yield return(new WaitForSeconds(0.5f));

        //create commet
        GameObject comet = cometPool.getPooledObject();

        comet.SetActive(true);

        float spawnX = Random.Range(leftSpawn.transform.position.x, rightSpawn.transform.position.x);
        float spawnY = leftSpawn.transform.position.y;

        float rise = spawnY - this.transform.position.y;
        float run  = spawnX - (this.transform.position.x + Random.Range(-1.2f, 1.2f));

        float velY  = astroidGenerator.getSpeed();
        float scale = velY / rise;
        float velX  = run * scale;

        float theta    = Mathf.Atan(rise / run) * Mathf.Rad2Deg;
        float rotation = 90 - (theta < 0 ? -theta : theta);

        if (theta > 0)
        {
            rotation *= -1;
        }

        comet.SetActive(true);
        CometController controller = comet.GetComponent <CometController>();

        controller.enabled = true;
        controller.spawn(new Vector3(spawnX, spawnY, 0), velX, velY);
        comet.transform.eulerAngles = new Vector3(0, 0, rotation);
        //wait n seconds then turn astroids back on
        yield return(new WaitForSeconds(0.5f));

        astroidGenerator.enabled = true;

        running = false;
    }
Exemplo n.º 3
0
    public void spawn()
    {
        Vector3    pos = new Vector3(Random.Range(-bound, bound), spawnHeight.transform.position.y, 1);
        GameObject obj = miniAstroids.getPooledObject();

        obj.transform.position = pos;
        obj.SetActive(true);
        float scale = Random.Range(minSize, maxSize);

        obj.transform.localScale = new Vector3(scale, scale, scale);
        AstroidBitPad pad = pads.getPooledObject().GetComponent <AstroidBitPad>();

        pad.attemptSpawn(pos, obj);
        AstroidController ac = obj.GetComponent <AstroidController>();

        ac.setVelocity(0, gen.getSpeed());
        ac.shouldMove(true);
        next = Time.time + stormDensity;
    }