Ejemplo n.º 1
0
    void Spawner()
    {
        int randomSpawnPosIndex = Random.Range(0, 4);

        //Probability for monster 1 to 20.
        obstacleRandomIndex = Random.Range(0, 20);

        int obstacleIndex;

        if (obstacleRandomIndex >= 1)
        {
            obstacleIndex = 0;
        }
        else
        {
            obstacleIndex = 1;
        }

        Instantiate(obstaclePrefab[obstacleIndex], ScreenUtility.GetRandomPos()[randomSpawnPosIndex], Quaternion.identity);
    }
Ejemplo n.º 2
0
    public void PowerUpSpawner()
    {
        int randomIndex = Random.Range(0, 4);

        GameObject[] randomPowerUp = { shieldPowerUp, destroyAllPowerUp };
        int          powerUpIndex;
        int          randomPowerUpIndex = Random.Range(0, 10);

        if (randomPowerUpIndex < 2)
        {
            powerUpIndex = 1;
        }
        else
        {
            powerUpIndex = 0;
        }

        if (Time.time > nextPowerUp)
        {
            float randomInterval = Random.Range(8, 54);
            nextPowerUp = Time.time + randomInterval;
            Instantiate(randomPowerUp[powerUpIndex], ScreenUtility.GetRandomPos()[randomIndex], Quaternion.identity);
        }
    }