Exemplo n.º 1
0
 private static AudioClip GetAudioClip(Sound sound)
 {
     foreach (GameAssets.SoundAudioClip soundAudioClip in GameAssets.getInstance().soundAudioClipArray)
     {
         if (soundAudioClip.sound == sound)
         {
             return(soundAudioClip.audioClip);
         }
     }
     Debug.LogError("Sound " + sound + " not found!");
     return(null);
 }
Exemplo n.º 2
0
    private void SpawnInitialGround()
    {
        groundList = new List <Transform>();
        Transform groundTransform;
        float     groundY     = -47.5f;
        float     groundWidth = 192f;

        groundTransform = Instantiate(GameAssets.getInstance().pfGround, new Vector3(0, groundY, 0), Quaternion.identity);
        groundList.Add(groundTransform);
        groundTransform = Instantiate(GameAssets.getInstance().pfGround, new Vector3(groundWidth, groundY, 0), Quaternion.identity);
        groundList.Add(groundTransform);
        groundTransform = Instantiate(GameAssets.getInstance().pfGround, new Vector3(groundWidth * 2f, groundY, 0), Quaternion.identity);
        groundList.Add(groundTransform);
    }
Exemplo n.º 3
0
    private void CreatePipe(float height, float xPosition, bool createBottom)
    {
        // Set up Pipe Head
        Transform pipeHead = Instantiate(GameAssets.getInstance().pfPipeHead);
        float     pipeHeadYPosition;

        if (createBottom)
        {
            pipeHeadYPosition = -CAMERA_ORTHO_SIZE + height - PIPE_HEAD_HEIGHT * 0.5f;
        }
        else
        {
            pipeHeadYPosition = +CAMERA_ORTHO_SIZE - height + PIPE_HEAD_HEIGHT * 0.5f;
        }
        pipeHead.position = new Vector2(xPosition, pipeHeadYPosition);

        // Set up Pipe Body
        Transform pipeBody = Instantiate(GameAssets.getInstance().pfPipeBody);
        float     pipeBodyYPosition;

        if (createBottom)
        {
            pipeHeadYPosition = -CAMERA_ORTHO_SIZE;
        }
        else
        {
            pipeHeadYPosition   = +CAMERA_ORTHO_SIZE;
            pipeBody.localScale = new Vector2(1, -1);
        }
        pipeBody.position = new Vector2(xPosition, pipeHeadYPosition);


        SpriteRenderer pipeBodySpriteRenderer = pipeBody.GetComponent <SpriteRenderer>();

        pipeBodySpriteRenderer.size = new Vector2(PIPE_WIDTH, height);

        BoxCollider2D pipeBodyBoxCollider = pipeBody.GetComponent <BoxCollider2D>();

        pipeBodyBoxCollider.size   = new Vector2(PIPE_WIDTH, height);
        pipeBodyBoxCollider.offset = new Vector2(0f, height * 0.5f);

        Pipe pipe = new Pipe(pipeHead, pipeBody, createBottom);

        pipeList.Add(pipe);
    }