Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        anim        = GetComponent <Animator> ();
        audioSource = GetComponent <AudioSource>();

        //Song_Parser parser = new Song_Parser();
        // Song_Parser.Metadata meta = parser.Parse(@"C:\Users\josh\CloudStation\Game Jam March 2016\Heartbeat\Assets\Music Files\Kung-Fu\KUNG%20FU%20FIGHTING.sm");
        Song_Parser.Metadata meta = Game_Data.chosenSongData;

        //TODO: Load Audio
        StartCoroutine(LoadTrack(meta.musicPath, meta));

        debugText.text = "Title: " + meta.title +
                         "\nSubtitle: " + meta.subtitle +
                         "\nArtist: " + meta.artist +
                         "\nBanner Path: " + meta.bannerPath +
                         "\nBackground Path: " + meta.backgroundPath +
                         "\nMusic Path: " + meta.musicPath +
                         "\nOffset: " + meta.offset +
                         "\nSample Start: " + meta.sampleStart +
                         "\nSample Length: " + meta.sampleLength +
                         "\nBPM: " + meta.bpm +
                         "\n\nValid: " + meta.valid;

        originalBPM = meta.bpm;

        currentBPM = originalBPM;
        prevBPM    = currentBPM;
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        Application.targetFrameRate = 60;
        audioSource = GetComponent <AudioSource>();

        //Song_Parser parser = new Song_Parser();
        // Song_Parser.Metadata meta = parser.Parse(@"C:\Users\josh\CloudStation\Game Jam March 2016\Heartbeat\Assets\Music Files\Kung-Fu\KUNG%20FU%20FIGHTING.sm");
        Song_Parser.Metadata meta = Game_Data.chosenSongData;

        //TODO: Load Audio
        //StartCoroutine(LoadTrack(meta.musicPath, meta));
        StartCoroutine(LoadTrack(meta.musicBG, meta)); //musicBG refers to background track, change to musicPath if we are scrapping audio feedback

        titleText.text = meta.title + " - " + meta.artist;

        /*debugText.text = "Title: " + meta.title +
         *               "\nSubtitle: " + meta.subtitle +
         *               "\nArtist: " + meta.artist +
         *               "\nBanner Path: " + meta.bannerPath +
         *               "\nBackground Path: " + meta.backgroundPath +
         *               "\nMusic Path: " + meta.musicPath +
         *               "\nOffset: " + meta.offset +
         *               "\nSample Start: " + meta.sampleStart +
         *               "\nSample Length: " + meta.sampleLength +
         *               "\nBPM: " + meta.bpm +
         *               "\n\nValid: " + meta.valid;*/

        originalBPM = meta.bpm;

        currentBPM = originalBPM;
        prevBPM    = currentBPM;
    }
Exemplo n.º 3
0
    IEnumerator LoadTrack(string path, Song_Parser.Metadata meta)
    {
        Debug.Log("LoadTrack:" + path);
        string url = string.Format("file://{0}", path);
        WWW    www = new WWW(url);

        while (!www.isDone)
        {
            yield return(null);
        }

        AudioClip clip = www.GetAudioClip(false, false);

        audioSource.clip = clip;

        Debug.Log("LoadTrack: Done!");

        songLoaded = true;

        audioSource.Play();

        GameObject manager = GameObject.FindGameObjectWithTag("GameManager");

        manager.GetComponent <Step_Generator>().InitSteps(meta, Game_Data.difficulty);
    }
Exemplo n.º 4
0
    IEnumerator LoadTrack(string path, Song_Parser.Metadata meta)
    {
        Debug.Log(path);
        string url = string.Format("file://{0}", path);
        WWW    www = new WWW(url);

        while (!www.isDone)
        {
            yield return(null);
        }

        AudioClip clip = www.GetAudioClip(false, false);

        audioSource.clip = clip;

        Debug.Log("Loaded");

        songLoaded = true;

        // probably can't wait, if song is not playing then it finishes the level
        // yield return new WaitForSeconds(gameOffset);
        audioSource.Play();

        GameObject manager = GameObject.FindGameObjectWithTag("GameManager");

        manager.GetComponent <Step_Generator>().InitSteps(meta, Game_Data.difficulty);
    }
Exemplo n.º 5
0
 void StartSong(Song_Parser.Metadata songData)
 {
     //Do stuff
     Debug.Log(songData.title + " Chosen!");
     Game_Data.chosenSongData = songData;
     SceneManager.LoadScene(2);
 }
Exemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        anim        = GetComponent <Animator> ();
        audioSource = GetComponent <AudioSource>();

        //Song_Parser parser = new Song_Parser();
        Song_Parser.Metadata meta = Game_Data.chosenSongData;

        StartCoroutine(LoadTrack(meta.musicPath, meta));
        debugText.text = "Title: " + meta.title +
                         "\nArtist: " + meta.artist;

/*
 *      debugText.text = "Title: " + meta.title +
 *                       "\nArtist: " + meta.artist +
 *                       "\nBanner Path: " + meta.bannerPath +
 *                       "\nBackground Path: " + meta.backgroundPath +
 *                       "\nMusic Path: " + meta.musicPath +
 *                       "\nOffset: " + meta.offset +
 *                       "\nSample Start: " + meta.sampleStart +
 *                       "\nSample Length: " + meta.sampleLength +
 *                       "\nBPM: " + meta.bpm +
 *                       "\n\nValid: " + meta.valid;
 */
        if (meta.bpm != 0)
        {
            originalBPM = meta.bpm;
        }
        else
        {
            originalBPM = 120;
        }
        currentBPM = originalBPM;
        prevBPM    = currentBPM;
    }
Exemplo n.º 7
0
 void StartSong(Song_Parser.Metadata songData)
 {
     //Do stuff
     Debug.Log(songData.title + " Chosen!");
     Game_Data.chosenSongData = songData;
     audioSource.mute         = !audioSource.mute;
     animator.SetTrigger("FadeOut");
 }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     Song_Parser.Metadata meta = Game_Data.chosenSongData;
     heart       = GameObject.FindGameObjectWithTag("Player");
     heartScript = heart.GetComponent <Heartbeat_Controller>();
     audioSource = GetComponent <AudioSource>();
     StartCoroutine(LoadTrack(meta.musicInst, meta)); //loads instrument track, omit this and the loadtrack coroutine if we are cancelling this
 }
Exemplo n.º 9
0
 public void InitSteps(Song_Parser.Metadata newSongData)//, Song_Parser.difficulties newDifficulty)
 {
     songData = newSongData;
     isInit   = true;
     //Debug.Log("bpm:"+songData.bpm);
     //Debug.Log("Offset:"+songData.offset);
     measureDuration = (60.0f / songData.bpm) * 4.0f; //= length of a measure?
     noteData        = songData.challenge;
     //Debug.Log("# measures:"+noteData.bars.Count);
 }
Exemplo n.º 10
0
    void Parse()
    {
        Debug.Log("Parsing");
        DirectoryInfo info = new DirectoryInfo(Game_Data.songDirectory);

        FileInfo[] smFiles = info.GetFiles("*.sm", SearchOption.AllDirectories);
        Debug.Log("Parsing Dir: " + Game_Data.songDirectory + " | Amount: " + smFiles.Length);
        for (int i = 0; i < smFiles.Length; i++)
        {
            Song_Parser parser = new Song_Parser();
            Debug.Log("Parsing File: " + smFiles[i].FullName);

            Song_Parser.Metadata songData = parser.Parse(smFiles[i].FullName);

            audioStartTime = songData.sampleStart;
            audioLength    = songData.sampleLength;

            if (!songData.valid)
            {
                //Song data is not valid
                Debug.Log("Song data is not valid");
                continue;
            }
            else
            {
                GameObject songObj = (GameObject)Instantiate(songSelectionTemplate, songSelectionList.transform.position, Quaternion.identity);
                songObj.GetComponentInChildren <Text>().text = songData.title + " - " + songData.artist;
                songObj.transform.parent     = songSelectionList.transform;
                songObj.transform.localScale = new Vector3(1, 1, 1); //Scale changes for some reason - reset it

                //Get access to the button control
                Button songBtn = songObj.GetComponentInChildren <Button>();
                if (File.Exists(songData.bannerPath))
                {
                    Texture2D texture = new Texture2D(275, 52);
                    texture.LoadImage(File.ReadAllBytes(songData.bannerPath));
                    Debug.Log(songData.bannerPath);
                    songBtn.image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
                    songBtn.image.material.SetColor("_Color", Color.white);
                    songObj.GetComponentInChildren <Text>().enabled = false;
                }
                songBtn.onClick.AddListener(delegate { StartSong(songData); });

                EventTrigger.Entry entry = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerEnter;
                entry.callback.AddListener(eventData => { if (songData.musicPath != currentSongPath)
                                                          {
                                                              StartCoroutine(PreviewTrack(songData.musicPath));
                                                          }
                                           });

                songBtn.GetComponent <EventTrigger>().triggers.Add(entry);
            }
        }
    }
Exemplo n.º 11
0
    // todo:
    // make it play audio
    // make it play steps
    // make it get kb input

    // Use this for initialization
    public void Start()
    {
        // System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
        // System.Windows.Forms.DialogResult result = fbd.ShowDialog();
        // Debug.Log(fbd.SelectedPath);

        // load game directory
        // Game_Data.songDirectory = "C:\\Users\\Jacqueline Liang\\Desktop\\simfile";
        // Game_Data.validSongDir = true;
        // Debug.Log(Game_Data.songDirectory);

        // set up audiosource
        audioSource = GetComponent <AudioSource>();

        // Song_Parser.Metadata meta = Parse(); // the simfile
        Song_Parser parser = new Song_Parser();
        // Song_Parser.Metadata meta = parser.Parse("Dir: D:\\ddrvr\\ddrvr\\Assets\\simfile | Amount: 0");
        //Song_Parser.Metadata
        // meta = parser.Parse("D:\\ddrvr\\ddrvr\\Assets\\simfile\\Eros and Apollo\\eros.sm");

        var menu = FindObjectOfType <Menufy>();
        var path = menu.songPath;

        audioSource.clip = menu.songClip;
        DestroyObject(menu);


        meta = parser.Parse(path);

        // meta = parser.Parse("D:\\ddrvr\\ddrvr\\Assets\\simfile\\Vinyl\\Vinyl.sm");
        //audioSource.PlayDelayed(meta.offset); // can pas a delay an an argument
        GameObject manager = GameObject.FindGameObjectWithTag("GameManager");

        manager.GetComponent <Step_Generator>().InitSteps(meta);//, Game_Data.difficulty);

        /*int i;
         * for (i=0;i<meta.challenge.bars.Count;i++)
         * {
         *      Debug.Log(""+meta.challenge.bars[i][0].up);
         * }*/
        audioSource.Play();
        //audioSource.PlayDelayed(300000);
        StartCoroutine(stopDelay(audioSource.clip.length));

        //Song_Parser.NoteData notes = parser.ParseNotes("D:\\ddrvr\\ddrvr\\Assets\\simfile\\Vinyl\\Lone Digger.sm");
        // StartCoroutine(LoadTrack(meta.musicPath, meta));

        // start the game
    }
Exemplo n.º 12
0
    // safe to delete, not called
    Song_Parser.Metadata Parse() // calls Song_Parser.cs
    {
        Debug.Log("Parsing");

        // get all simfiles in a FileInfo[] array
        DirectoryInfo info = new DirectoryInfo(Game_Data.songDirectory);

        FileInfo[] smFiles = info.GetFiles("*.sm", SearchOption.AllDirectories);
        Debug.Log("Parsing Dir: " + Game_Data.songDirectory + " | Amount: " + smFiles.Length);

        Song_Parser parser = new Song_Parser();

        Song_Parser.Metadata songData = parser.Parse(Game_Data.songDirectory);
        return(songData);
    } // end parse fxn
Exemplo n.º 13
0
    public void InitSteps(Song_Parser.Metadata newSongData, Song_Parser.difficulties newDifficulty)
    {
        songData   = newSongData;
        isInit     = true;
        barTime    = (60.0f / songData.bpm) * 4.0f;
        difficulty = newDifficulty;
        distance   = originalDistance;

        switch (difficulty)
        {
        //beginner and challenge are irrelevant
        //adjust accordingly for medium and easy, i've only done for hard so far
        case Song_Parser.difficulties.beginner:
            arrowSpeed = 0.007f;
            noteData   = songData.beginner;
            break;

        case Song_Parser.difficulties.easy:
            arrowSpeed = 0.077f;     //original value = 0.011f
            noteData   = songData.easy;
            break;

        case Song_Parser.difficulties.medium:
            originalDistance = 7.5f;
            arrowSpeed       = 0.154f; //original value = 0.011f
            noteData         = songData.medium;
            break;

        case Song_Parser.difficulties.hard:
            arrowSpeed = 0.195f;     //original value = 0.013f
            noteData   = songData.hard;
            break;

        case Song_Parser.difficulties.challenge:
            originalArrowSpeed = 0.009f;
            arrowSpeed         = 0.016f;
            noteData           = songData.challenge;
            break;

        default:
            goto case Song_Parser.difficulties.easy;
        }

        originalArrowSpeed = arrowSpeed;
    }
Exemplo n.º 14
0
    IEnumerator LoadTrack(string path, Song_Parser.Metadata meta)
    {
        Debug.Log(path);
        string url = string.Format("file://{0}", path);
        WWW    www = new WWW(url);

        while (!www.isDone)
        {
            yield return(null);
        }

        AudioClip clip = www.GetAudioClip(false, false);

        audioSource.clip = clip;

        Debug.Log("Loaded");
        audioSource.Play();
    }
Exemplo n.º 15
0
    void Start()
    {
        anim        = GetComponent <Animator>();
        audioSource = GetComponent <AudioSource>();
        Song_Parser.Metadata meta = Game_Data.chosenSongData;

        StartCoroutine(LoadTrack(meta.musicPath, meta));

        if (meta.bpm != 0)
        {
            originalBPM = meta.bpm;
        }
        else
        {
            originalBPM = 120;
        }
        currentBPM = originalBPM;
    }
Exemplo n.º 16
0
    /// <summary>
    /// inits the steps
    /// </summary>
    /// <param name="newSongData">metadata</param>
    /// <param name="newDifficulty">new difficulty</param>
    public void InitSteps(Song_Parser.Metadata newSongData, Song_Parser.difficulties newDifficulty)
    {
        songData   = newSongData;
        isInit     = true;
        barTime    = (60.0f / songData.bpm) * 4.0f;
        difficulty = newDifficulty;
        distance   = originalDistance;

        switch (difficulty)
        {
        case Song_Parser.difficulties.beginner:
            arrowSpeed = 0.007f;
            noteData   = songData.beginner;
            break;

        case Song_Parser.difficulties.easy:
            arrowSpeed = 0.009f;
            noteData   = songData.easy;
            break;

        case Song_Parser.difficulties.medium:
            arrowSpeed = 0.011f;
            noteData   = songData.medium;
            break;

        case Song_Parser.difficulties.hard:
            arrowSpeed = 0.013f;
            noteData   = songData.hard;
            break;

        case Song_Parser.difficulties.challenge:
            originalArrowSpeed = 0.009f;
            arrowSpeed         = 0.016f;
            noteData           = songData.challenge;
            break;

        default:
            goto case Song_Parser.difficulties.easy;
        }

        originalArrowSpeed = arrowSpeed;
    }
Exemplo n.º 17
0
    // Start is called before the first frame update
    void Start()
    {
        videoPlayer = GetComponent <VideoPlayer>();
        Song_Parser.Metadata songData = Game_Data.chosenSongData;
        SpriteRenderer       image    = GetComponent <SpriteRenderer>();

        if (File.Exists(songData.backgroundPath))
        {
            Texture2D texture = new Texture2D(800, 600);
            texture.LoadImage(File.ReadAllBytes(songData.backgroundPath));
            Debug.Log(songData.bannerPath);
            image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
        }
        if (songData.movies)
        {
            videoPlayer.clip = movies;
            videoPlayer.time = music.GetComponent <AudioSource>().time;
            videoPlayer.Play();
        }
    }
Exemplo n.º 18
0
    IEnumerator LoadTrack(string path, Song_Parser.Metadata meta)
    {
        string url = string.Format("file://{0}", path);
        WWW    www = new WWW(url);

        while (!www.isDone)
        {
            yield return(null);                          // download isnt finished
        }
        AudioClip clip = www.GetAudioClip(false, false); // doesnt matter if it's 2d or 3d, no need to be downloaded completely

        audioSource.clip = clip;

        songLoaded = true;
        audioSource.Play();

        GameObject manager = GameObject.FindGameObjectWithTag("GameManager");

        manager.GetComponent <Step_Generator>().InitSteps(meta, Game_Data.difficulty);
    }
Exemplo n.º 19
0
 /// <summary>
 /// starts the selected song
 /// </summary>
 /// <param name="songData"> song metadata</param>
 void StartSong(Song_Parser.Metadata songData)
 {
     Game_Data.chosenSongData = songData;
     SceneManager.LoadScene(2);
 }
Exemplo n.º 20
0
    /// <summary>
    /// get song data when song is selected
    /// </summary>
    void Parse()
    {
        DirectoryInfo info = new DirectoryInfo(Game_Data.songDirectory);

        FileInfo[] smFiles = info.GetFiles("*.sm", SearchOption.AllDirectories);
        for (int i = 0; i < smFiles.Length; i++) // loop all files
        {
            Song_Parser          parser   = new Song_Parser();
            Song_Parser.Metadata songData = parser.Parse(smFiles[i].FullName);

            audioStartTime = songData.sampleStart;
            audioLength    = songData.sampleLength;

            if (songData.valid)
            {
                //Instantiate(Object original, Vector3 position, Quaternion rotation);
                // Quaternion.identity - "no rotation" - the object is perfectly aligned with the world or parent axes
                GameObject songObj = (GameObject)Instantiate(songSelectionTemplate, songSelectionList.transform.position, Quaternion.identity);
                songObj.GetComponentInChildren <Text>().text = songData.title + " - " + songData.artist; //the text that is inside the new songObj becomes titl - artist (example - Bad Romance - Gaga)


                songObj.transform.parent = songSelectionList.transform; //the songObj depends on the whole list position

                songObj.transform.localScale = new Vector3(1, 1, 1);    // scale of the transform relative to the parent.


                //Get access to the button control
                Button songBtn = songObj.GetComponentInChildren <Button>();

                //if there is a bannerPath file inside of the songData object, load the banner instead of the text
                if (File.Exists(songData.bannerPath))
                {
                    Texture2D texture = new Texture2D(275, 52);                // 275 width, 52 height,
                    texture.LoadImage(File.ReadAllBytes(songData.bannerPath)); // add banner as texture image


                    // init a sprite that uses the texture, a sharp edged (edge radius - 0) rectangle, a pivot equal to the vector and 100pixels per unit
                    songBtn.image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100.0f);
                    songBtn.image.material.SetColor("_Color", Color.white);  //no color tin over the button

                    songObj.GetComponentInChildren <Text>().enabled = false; //don't show the button text
                }

                //once the button is clicked, start the song, and if there is an error, handle it
                songBtn.onClick.AddListener(delegate { StartSong(songData); });

                //the event is triggered when the pointer enters the trigger zone of the button
                EventTrigger.Entry entry = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerEnter;


                //if you aren't already playing the song preview start a song preview of the song
                entry.callback.AddListener(eventData => { if (songData.musicPath != currentSongPath)
                                                          {
                                                              StartCoroutine(PreviewTrack(songData.musicPath));
                                                          }
                                           });

                //add the new trigger to the list of triggers in the button
                songBtn.GetComponent <EventTrigger>().triggers.Add(entry);
            }
        }
    }
    public void InitSteps(Song_Parser.Metadata newSongData, Song_Parser.difficulties newDifficulty)
    {
        Debug.Log("Step_Generator.InitSteps()");

        songData   = newSongData;
        isInit     = true;
        barTime    = (60.0f / songData.bpm) * 4.0f;
        difficulty = newDifficulty;
        distance   = originalDistance;



        switch (difficulty)
        {
        case Song_Parser.difficulties.beginner:
            if (songData.beginnerExists)
            {
                Debug.Log("Step_Generator.InitSteps() - beginner");
                arrowSpeed = 0.007f;
                noteData   = songData.beginner;
            }
            else
            {
                goto case Song_Parser.difficulties.easy;
            }
            break;

        case Song_Parser.difficulties.easy:
            if (songData.easyExists)
            {
                Debug.Log("Step_Generator.InitSteps() - easy");
                arrowSpeed = 0.009f;
                noteData   = songData.easy;
            }
            else
            {
                goto case Song_Parser.difficulties.medium;
            }
            break;

        case Song_Parser.difficulties.medium:
            if (songData.mediumExists)
            {
                Debug.Log("Step_Generator.InitSteps() - medium");
                arrowSpeed = 0.011f;
                noteData   = songData.medium;
            }
            else
            {
                goto case Song_Parser.difficulties.hard;
            }
            break;

        case Song_Parser.difficulties.hard:
            if (songData.hardExists)
            {
                Debug.Log("Step_Generator.InitSteps() - hard");
                arrowSpeed = 0.013f;
                noteData   = songData.hard;
            }
            else
            {
                goto case Song_Parser.difficulties.challenge;
            }
            break;

        case Song_Parser.difficulties.challenge:
            if (songData.challengeExists)
            {
                Debug.Log("Step_Generator.InitSteps() - challenge");
                originalArrowSpeed = 0.009f;
                arrowSpeed         = 0.016f;
                noteData           = songData.challenge;
            }
            else
            {
                goto case Song_Parser.difficulties.beginner;
            }
            break;

        default:
            Debug.Log("Step_Generator.InitSteps() - default");
            goto case Song_Parser.difficulties.beginner;
        }

        originalArrowSpeed = arrowSpeed;
    }