示例#1
0
    public void LoadData()
    {
        TextAsset itemData = Resources.Load <TextAsset>("CSVSounds");

        string[] data = itemData.text.Split(new char[] { '\n' });
        //Debug.Log(data.Length); // note there's a line too much at the end.

        for (int i = 1; i < data.Length; i++)
        {
            //  Skip the first line, since it's the labels: SoundTag, TimeStep, Mund, Ojne, Krop
            string[] row = data[i].Split(new char[] { ',' });
            if (row[0] != "")
            {
                tempSoundAnimation = new SoundAnimation();
                AnimationDatabase.Instance.SoundAnimationDictionary.Add(row[0], tempSoundAnimation);
                tempSoundAnimation.Tag = row[0];
            }
            tempTimeStep = new SoundAnimation.TimeStep();
            tempSoundAnimation.TimeStepList.Add(tempTimeStep);
            float.TryParse(row[1], out tempTimeStep.time);
            tempTimeStep.Mund      = row[2];
            tempTimeStep.Ojne      = row[3];
            tempTimeStep.Krop      = row[4];
            tempTimeStep.Animation = row[5].Trim(); //Added trim to remove newline
        }
    }
示例#2
0
 public All_Info_Page()
 {
     this.InitializeComponent();
     voice.Play();
     //voice.
     SoundAnimation.Begin();
     voice.MediaEnded += NextPage;
 }
 private void IdleSoundAnimationGenerator()
 {
     IdleSoundAnimation = new SoundAnimation();
     SoundAnimation.TimeStep timeStep = new SoundAnimation.TimeStep();
     timeStep.Animation = "0";
     timeStep.Krop      = "1";
     timeStep.Mund      = "1";
     timeStep.Ojne      = "1";
     timeStep.time      = 0.0f;
     IdleSoundAnimation.TimeStepList.Add(timeStep);
 }
示例#4
0
    public IEnumerator PlayAnimation(string tag, UnityAction animationCallback)
    {
        AnimationDatabase.Instance.SoundAnimationDictionary.TryGetValue(tag, out currentSoundAnimation);

        if (!audioSource)
        {
            audioSource = GetComponent <AudioSource>();
        }
        audioSource.clip = Resources.Load("Sounds/" + tag) as AudioClip;
        audioSource.Play();
        audioTime  = audioSource.clip.length;
        timeWaited = 0.0f;

        for (int i = 0; i < currentSoundAnimation.TimeStepList.Count + 1; i++)
        {
            if (i == currentSoundAnimation.TimeStepList.Count)
            {
                yield return(new WaitForSecondsRealtime(audioTime - timeWaited));

                currentSoundAnimation = AnimationDatabase.Instance.IdleSoundAnimation;
                SetSprites(0);
                AnimatorAssist("0"); // idle
                animationCallback();
            }
            else
            {
                AnimatorAssist(currentSoundAnimation.TimeStepList[i].Animation);

                while (currentSoundAnimation.TimeStepList[i].time > timeWaited)
                {
                    yield return(waitForEnd);

                    timeWaited += Time.deltaTime;
                    SetSprites(i);
                }

                /*
                 * yield return new WaitForSecondsRealtime(currentSoundAnimation.TimeStepList[i].time - timeWaited);
                 * yield return waitForEnd;
                 * timeWaited = currentSoundAnimation.TimeStepList[i].time;
                 * SetSprites(i);
                 * AnimatorAssist(currentSoundAnimation.TimeStepList[i].Animation);
                 */
            }
        }

        yield return(true);
    }