Beispiel #1
0
    private IEnumerator DestroyObject()
    {
        //Play a random congratulatory sound
        AudioSource audio = GetComponent <AudioSource>();

        GetComponent <Renderer>().enabled = false;
        audio.clip = m_Sounds[m_MainController.GetRandomNum(0, m_Sounds.Length)];
        audio.Play();

        //Wait until the audio has finished playing
        yield return(new WaitForSeconds(audio.clip.length));

        //Destroy the oxygen character so the player can keep on moving
        audio.Stop();
        Destroy(gameObject);
    }
Beispiel #2
0
    private IEnumerator DestroyObject()
    {
        //Play the lose a life sound
        AudioSource audio = GetComponent <AudioSource>();

        GetComponent <Renderer>().enabled = false;
        audio.clip = m_Sounds[m_MainController.GetRandomNum(0, m_Sounds.Length)];
        audio.Play();

        //Wait until the audio has played
        yield return(new WaitForSeconds(audio.clip.length));


        //Destroy the game object so the player can keep playing
        audio.Stop();
        Destroy(gameObject);
    }
Beispiel #3
0
    private void MakeObstacle()
    {
        //Choose a random obstacle from the list of obstacles to place
        int        obstacleNum = m_GameController.GetRandomNum(0, m_Obstacles.Length);
        GameObject obstacle    = m_Obstacles[obstacleNum];

        //Instantiate the obstacle and rotate the obstacle to a random rotation
        GameObject instantiatedObstacle = Instantiate(obstacle, transform.position, transform.rotation);

        instantiatedObstacle.transform.Rotate(0f, m_GameController.GetComponent <MainErythrocyteGameController>().GetRandomNum(0, 360), 0f, Space.Self);

        //Set the player, controller and parent of the obstacle

        instantiatedObstacle.GetComponent <ObstacleController>().SetPlayer(m_PlayerCollider);
        instantiatedObstacle.GetComponent <ObstacleController>().SetMainController(m_GameController);

        instantiatedObstacle.transform.SetParent(transform);
    }