Пример #1
0
    //Remove everything from screen (READY SCREEN)
    public void clearScreen()
    {
        helpScreen.SetActive(false);
        CancelInvoke();                                          //To not spawn UFO

        player.GetComponent <PlayerCollision>().cancelRespawn(); //Not respawn player accidentally
        player.SetActive(false);
        BigUFO.SetActive(false);
        SmallUFO.SetActive(false);
        BigAsteroids.inactiveAll();
        MedAsteroids.inactiveAll();
        SmallAsteroids.inactiveAll();
    }
Пример #2
0
    //Where the asteroids and UFO plays in Main Menu
    public void startDemo()
    {
        player.SetActive(false);
        BigUFO.SetActive(false);
        SmallUFO.SetActive(false);

        spawnAsteroids(); //Spawn 4 asteroids

        MedAsteroids.inactiveAll();
        SmallAsteroids.inactiveAll();

        Invoke("spawnUFO", 15f); //Spawn UFO each 15 seconds
    }
Пример #3
0
    //Gameplay screen
    public void startGameplay()
    {
        player.SetActive(true);
        player.transform.position = new Vector3(0f, 0f); //Set player to the center of the screen

        BigUFO.SetActive(false);
        SmallUFO.SetActive(false);

        spawnAsteroids(); //Spawn 4 asteroids at begining

        MedAsteroids.inactiveAll();
        SmallAsteroids.inactiveAll();

        Invoke("spawnUFO", 15f);
    }
Пример #4
0
    //Spawn a new UFO on Screen
    public void spawnUFO()
    {
        //IF it's not active on stage
        if (!SmallUFO.activeInHierarchy && !BigUFO.activeInHierarchy)
        {
            //random numbers
            sbyte rnd  = 0;
            sbyte side = (sbyte)(Random.Range(-5, 5) < 0 ? 1 : -1); // Can be -1 or 1

            //If Score lower than 40,000 , show both UFO's, if score is Higher than 40,000 , show only the small ones
            if (Score.score < 40000)
            {
                rnd = (sbyte)Random.Range(-5, 5);
            }
            else
            {
                rnd = 5; // positive number to spawn only Small UFO's
            }


            if (rnd <= 0)
            {
                BigUFO.SetActive(true);

                float randY = Random.Range(-Boundaries.halfY, Boundaries.halfY);         //Random Y position to spawn

                BigUFO.transform.position = new Vector3(Boundaries.halfX * side, randY); // From the left or the right ?

                BigUFO.GetComponent <UFOBehaviour>().direction = (sbyte)(side * -1);     // where it spawns, define direction to go
            }
            else
            {
                SmallUFO.SetActive(true);

                float randY = Random.Range(-Boundaries.halfY, Boundaries.halfY);           //Random Y position to spawn

                SmallUFO.transform.position = new Vector3(Boundaries.halfX * side, randY); // From the left or the right ?

                SmallUFO.GetComponent <UFOBehaviour>().direction = (sbyte)(side * -1);     // where it spawns, define direction to go
            }

            Invoke("spawnUFO", 15f); // Respawn the next in 15seconds
        }
        else
        {
            Invoke("spawnUFO", 5f); //If have some active on Stage, try again in 5 seconds
        }
    }