Exemplo n.º 1
0
    private void ActivateSoundBaby()
    {
        AudioRepository audioRepository = AudioRepository.GetInstance();

        audioRepository.gameObject.GetComponent <AudioSource>().clip = audioRepository.babyAudio2;
        audioRepository.gameObject.GetComponent <AudioSource>().Play();
    }
Exemplo n.º 2
0
    private void BabyCry()
    {
        GameObject event1 = GameObject.Find("Event1");

        event1.GetComponent <AudioSource>().clip = AudioRepository.GetInstance().babyAudio;
        event1.GetComponent <AudioSource>().Play();
    }
Exemplo n.º 3
0
    private void ActivateSoundWoman()
    {
        AudioRepository audioRepository = AudioRepository.GetInstance();

        audioRepository.gameObject.GetComponent <AudioSource>().clip = audioRepository.womanAudio;
        audioRepository.gameObject.GetComponent <AudioSource>().Play();
    }
        public async Task <byte[]> WebAPICall(AudioJob auj)
        {
            //return Encoding.ASCII.GetBytes("test");
            byte[]          byteRes      = null;
            AudioRepository audioJobRepo = new AudioRepository();
            Guid            jobID        = await audioJobRepo.SubmitWorkItem(auj);

            while (audioJobRepo.GetWorkStatus(jobID) == 2)
            {
                //wait
                await Task.Delay(200);
            }
            if (audioJobRepo.GetWorkStatus(jobID) == 1)
            {
                //sucess
                FileResult result = audioJobRepo.GetResultContents(jobID);
                byteRes = result.getFileContents();
            }
            else
            {
                //fail
                throw new Exception("Task with job ID: " + jobID + " failed");
            }
            return(byteRes);
        }
Exemplo n.º 5
0
        void Start()
        {
            SoundManager.GetInstance().PlayOneShot(AudioRepository.LoadExplosionAudio(missile.audioID));

            animator.AnimationCompleted = delegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
            {
                animator.AnimationCompleted = null;

                missile = null;

                Destroy(gameObject);
            };

            if (missile.WOE != 0)
            {
                Collider2D[] hits = Physics2D.OverlapCircleAll(this.transform.position, this.missile.WOE);

                IList <GameObject> hitedCache = new List <GameObject>();
                foreach (Collider2D hit in hits)
                {
                    MonsterEntity2D entity = hit.gameObject.GetComponent <MonsterEntity2D>();

                    if (entity != null && !hitedCache.Contains(entity.gameObject))
                    {
                        entity.OnMissileHit(sender, missile, this.transform.position);

                        hitedCache.Add(hit.gameObject);
                    }
                }

                hitedCache.Clear();
            }
        }
Exemplo n.º 6
0
    private void OpenClosedRoom()
    {
        GameObject porta = GameObject.Find("PortaChave");

        porta.GetComponent <DoorWrapper>().doorAnim.SetTrigger("open2");
        porta.GetComponent <AudioSource>().playOnAwake = false;
        porta.GetComponent <AudioSource>().clip        = AudioRepository.GetInstance().doorOpen;
    }
Exemplo n.º 7
0
    public void OpenDoor()
    {
        AudioSource audio = gameObject.GetComponent <AudioSource>();

        switch (typeAnim)
        {
        case DoorAnim.Locked:

            if (!opened && isUnlocked())
            {
                doorAnim.SetTrigger(doorAnimTrigger);
                audio.clip = AudioRepository.GetInstance().doorOpen;
                audioOpenDoor.Play();
            }
            else
            {
                if (!audio.isPlaying)
                {
                    audio.clip = AudioRepository.GetInstance().doorLocked;
                    audio.Play();
                }
            }

            break;

        case DoorAnim.Shaked:

            if (!audio.isPlaying)
            {
                audio.clip = AudioRepository.GetInstance().doorShaked;
                doorAnim.SetTrigger("shake");
                audioOpenDoor.Play();
                EventManager.GetInstance().SetEvent("lockDoors");
            }

            break;
        }


        /*if(!isUnlocked())
         * {
         *     SubtitleManager.GetInstance ().SetText (sub);
         * }
         *
         * if (!opened && isUnlocked())
         * {
         *     doorAnim.SetTrigger("open");
         *     audioOpenDoor.Play();
         *
         *     opened = true;
         * }*/
    }
Exemplo n.º 8
0
        private static void PlayAudio()
        {
            // first step
            // AudioPlayer ap = new AudioPlayer();
            // Console.WriteLine(ap);

            // middle step
            // AudioPlayer.Play();

            // final-ish step
            // var ap = AudioPlayer.GetInstance();

            // the csharp way
            var ap  = AudioPlayer.Instance;
            var ac  = new AudioRepository();
            var ac2 = new AudioRepositoryGeneric <Song>();
            var ac3 = new AudioRepositoryGeneric <Book>();

            // if (ac.Playlist() != null)
            // {
            //   foreach (var item in ac.Playlist())
            //   {
            //     ap.Play(item);
            //   }
            // }

            try
            {
                foreach (var item in ac.List())
                {
                    ap.Play(item);
                }
            }
            catch (NullReferenceException err)
            {
                Console.WriteLine("NO Playlist for you");
            }
            catch (IndexOutOfRangeException err)
            {
                Console.WriteLine("NO song for you");
            }
            catch (Exception ex)
            {
                // throw;
                throw new Exception("error", ex);
            }
            finally
            {
                GC.Collect();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets and audio clip from the audio repository.
        /// </summary>
        /// <param name="audio">The name of the clip.</param>
        /// <returns>An AudioClip.</returns>
        public static AudioClip GetAudioClip(string audio)
        {
            if (LoadedAudioFiles.ContainsKey(audio))
            {
                return(LoadedAudioFiles[audio]);
            }
            WWW www = new WWW(AudioRepository.GetPathInModFolder(audio));

            AudioClip clip = www.GetAudioClip();

            LoadedAudioFiles[audio] = clip;

            return(clip);
        }
Exemplo n.º 10
0
        private static void PlayAudio()
        {
            // Console.WriteLine(ap);
            //  AudioPlayer.Play();
            // var ap = AudioPlayer.GetInstance();

            //created an object for AudioPlayer class in order to have one Audioplayer object
            var ap2 = AudioPlayer.Instance;

            //created an object for AudioCollection class
            //var ac = new AudioCollection();

            // if(ac.PlayList() != null)
            // {
            // foreach(var item in ac.PlayList())
            //   {
            //     ap2.Play(item);
            //   }
            // }

            var ac  = new AudioRepository();
            var ac2 = new AudioRepositoriesGeneric <Song>();

            try
            {
                foreach (var item in ac.PList())
                {
                    ap2.Play(item);
                    ap2.Stop(item);
                }
            }
            catch (NullReferenceException err)
            {
                //specific to general
                Console.WriteLine("No Song for you", err);
            }
            catch (IndexOutOfRangeException err)
            {
                Console.WriteLine("No Song for you", err);
            }
            catch (Exception ex)
            {
                throw new Exception("error", ex);
            }
            //Final doesn't run if its a fatal exception
            finally
            {
                GC.Collect();
            }
        }
        public AudioData(int id)
        {
            ID = id;

            Dictionary <string, string> AudioRow = AudioRepository.GetRemoteAudio(this);

            if (AudioRow != null)
            {
                name      = Convert.ToString(AudioRow["FileName"]);
                extension = Convert.ToString(AudioRow["FileExtension"]);
                Result    = true;
                return;
            }
            Result = false;
        }
Exemplo n.º 12
0
        private static void PlayAudio()
        {
            //first step
            //AudioPlayer ap = new AudioPlayer();
            //Console.WriteLine(ap);

            //middle step
            //AudioPlayer.Play();

            //var ap = AudioPlayer.GetInstance();

            //the csharp way
            var ap = AudioPlayer.Instance;
            var ar = new AudioRepository();

            //where do we use them, ar2 and ar3?
            var ar2 = new AudioRepositoryGeneric <Song>();
            var ar3 = new AudioRepositoryGeneric <Book>();

            try
            {
                foreach (var item in ar.List())
                {
                    ap.Play(item);
                }
            }
            catch (NullReferenceException err)
            {
                //No necesito var exp = err; es solo para que no reclame
                var exp = err;
                Console.WriteLine("No playlist for you");
            }
            catch (IndexOutOfRangeException err)
            {
                var exp = err;
                Console.WriteLine("No song for you");
            }
            catch (Exception ex)
            {
                //throw;
                throw new Exception("error", ex);
            }
            finally
            {
                GC.Collect();
            }
        }
    public void Interact()
    {
        string[] partsPicture = new string[] {
            Constants.PictureP1Item,
            Constants.PictureP2Item,
            Constants.PictureP3Item,
            Constants.PictureP4Item
        };

        clickCounter += 1;

        if (hasCompletedPicture)
        {
            EventManager.GetInstance().SetEvent("babyPersecution");
            PartsToCompletePicture(partsPicture);
            SubtitleManager.GetInstance().SetText(pictureComplete);
            gameObject.SetActive(false);
        }

        if (clickCounter > 2)
        {
            AudioRepository audioRepo = AudioRepository.GetInstance();

            if (!audioRepo.gameObject.GetComponent <AudioSource>().isPlaying)
            {
                audioRepo.gameObject.GetComponent <AudioSource>().clip = audioRepo.incompletePictureAudio;
                audioRepo.gameObject.GetComponent <AudioSource>().Play();
            }
        }

        Invoke("ResetCounter", 30f);

        AddPartsPicture(partsPicture);

        if (pictureCounter > 0)
        {
            SubtitleManager.GetInstance().SetText(pictureIncomplete);
        }
        else
        {
            hasCompletedPicture = true;
            HelperUtil.FindGameObject(GameObject.Find("Sangue pós quarta foto"), "SangueContainer").SetActive(true);
        }
    }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press \"Q\" for exit");

            string path = Path.Combine(Directory.GetCurrentDirectory(), FOLDER_FOR_TRACKS);

            _device     = new ConsolePlayer();
            _repository = new AudioRepository(path);
            _repository.Init();

            int i = 0;

            _repository.Save(new Track($"{++i}", Zelda));
            _repository.Save(new Track($"{++i}", Sun));
            _repository.Save(new Track($"{++i}", Water));
            _repository.Save(new Track($"{++i}", Fire));
            _repository.Save(new Track($"{++i}", Shadow));
            _repository.Save(new Track($"{++i}", JBells));

            // TODO: M - make audio track.
            // TODO: P - play audio track.
            // TODO: R - recorder audio track.
            // TODO: S - stop audio track.
            // TODO: save audio track config.
            CancellationTokenSource sourceToken = null;

            while (true)
            {
                var pressKey = Console.ReadKey();
                switch (pressKey.Key)
                {
                case ConsoleKey.Q:
                    return;

                case ConsoleKey.M:
                    // TODO: Use strategy.
                    // TODO: Print console make rule.
                    Console.WriteLine("Enter track name ");

                    do
                    {
                        Console.WriteLine("Enter note tone ");
                        Console.WriteLine("Enter note durotation ");

                        // TODO: read key.
                    }while (true);

                    // TODO: Make note.
                    // TODO: Add note list.

                    break;

                case ConsoleKey.P:

                    Track track;
                    do
                    {
                        // TODO: Print play list for select.
                        Console.WriteLine();
                        Console.Write("Enter number track: ");
                    }
                    // TODO: Scan select track.
                    while (!_repository.TryGetValue(Console.ReadLine(), out track));

                    sourceToken?.Cancel();
                    sourceToken = new CancellationTokenSource();

                    _ = _device.Play(track, sourceToken.Token);
                    break;

                case ConsoleKey.S:
                    sourceToken?.Cancel();
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 15
0
        public override void EnterSceneComplete()
        {
            EventBox.Send(CustomEvent.ENTER_SCENE_COMPLETE);

            SoundManager.GetInstance().PlayBackgroundMusic(AudioRepository.LoadBackgroundAudio(dungeon.audioID), 1.0f);
        }
Exemplo n.º 16
0
        public async Task TestPostAudioJob()
        {
            //init
            var mockJobs         = new Mock <DbSet <Job> >();
            var mockServiceUsers = new Mock <DbSet <ServiceUser> >();
            var mockContext      = new Mock <RoboBrailleDataContext>();
            var mockAuSender     = new Mock <IAudioJobSender>();

            // arrange
            var users = new List <ServiceUser> {
                new ServiceUser
                {
                    EmailAddress = "*****@*****.**",
                    UserId       = Guid.Parse("d2b97532-e8c5-e411-8270-f0def103cfd0"),
                    ApiKey       = Encoding.UTF8.GetBytes("7b76ae41-def3-e411-8030-0c8bfd2336cd"),
                    FromDate     = new DateTime(2015, 1, 1),
                    ToDate       = new DateTime(2020, 1, 1),
                    UserName     = "******",
                    Jobs         = null
                }
            }.AsQueryable();

            AudioJob auj = new AudioJob()
            {
                Id              = Guid.NewGuid(),
                FileContent     = new byte[512],
                UserId          = Guid.Parse("d2b97532-e8c5-e411-8270-f0def103cfd0"),
                FileExtension   = ".pdf",
                FileName        = "test",
                MimeType        = "application/pdf",
                Status          = JobStatus.Started,
                SubmitTime      = DateTime.Now,
                DownloadCounter = 0,
                InputFileHash   = new byte[64],
                AudioLanguage   = Language.daDK,
                FormatOptions   = AudioFormat.Mp3,
                SpeedOptions    = AudioSpeed.Normal,
                VoicePropriety  = new VoicePropriety[] { VoicePropriety.Anne }
            };
            AudioJob auj2 = new AudioJob()
            {
                Id              = Guid.NewGuid(),
                FileContent     = new byte[256],
                UserId          = Guid.Parse("d2b87532-e8c5-e411-8270-f0def103cfd0"),
                FileExtension   = ".txt",
                FileName        = "test2",
                MimeType        = "text/plain",
                Status          = JobStatus.Done,
                SubmitTime      = DateTime.Now,
                DownloadCounter = 2,
                InputFileHash   = new byte[2]
            };
            var jobs = new List <AudioJob> {
                auj2
            }.AsQueryable();

            mockJobs.As <IDbAsyncEnumerable <Job> >().Setup(m => m.GetAsyncEnumerator()).Returns(new TestDbAsyncEnumerator <Job>(jobs.GetEnumerator()));
            mockJobs.As <IQueryable <Job> >().Setup(m => m.Provider).Returns(new TestDbAsyncQueryProvider <Job>(jobs.Provider));

            mockJobs.As <IQueryable <Job> >().Setup(m => m.Expression).Returns(jobs.Expression);
            mockJobs.As <IQueryable <Job> >().Setup(m => m.ElementType).Returns(jobs.ElementType);
            mockJobs.As <IQueryable <Job> >().Setup(m => m.GetEnumerator()).Returns(jobs.GetEnumerator());

            mockServiceUsers.As <IDbAsyncEnumerable <ServiceUser> >().Setup(m => m.GetAsyncEnumerator()).Returns(new TestDbAsyncEnumerator <ServiceUser>(users.GetEnumerator()));
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.Provider).Returns(new TestDbAsyncQueryProvider <ServiceUser>(users.Provider));
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.Expression).Returns(users.Expression);
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.ElementType).Returns(users.ElementType);
            mockServiceUsers.As <IQueryable <ServiceUser> >().Setup(m => m.GetEnumerator()).Returns(users.GetEnumerator());

            mockContext.Setup(m => m.Jobs).Returns(mockJobs.Object);
            mockContext.Setup(m => m.ServiceUsers).Returns(mockServiceUsers.Object);
            mockAuSender.Setup(m => m.SendAudioJobToQueue(auj)).Returns(Encoding.UTF8.GetBytes(testFileResult));

            var repo = new AudioRepository(mockContext.Object, mockAuSender.Object);

            var request = new HttpRequestMessage();

            request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Authorization", "Hawk id=\"d2b97532-e8c5-e411-8270-f0def103cfd0\", ts=\"1470657024\", nonce=\"VkcMGB\", mac=\"hXW+BLRoqwlUaQZQtpPToOWnVAh5KbAXGGT5f8dLMVk=\"");
            var serviceController = new AudioController(repo)
            {
                Request = request
            };
            //call
            await serviceController.Post(auj);

            //test
            mockJobs.Verify(m => m.Add(It.IsAny <Job>()), Times.Once());

            mockContext.Verify(m => m.SaveChanges(), Times.Exactly(1));
            //twice if it is synced
            //mockContext.Verify(m => m.SaveChanges(), Times.Exactly(2));

            mockAuSender.Verify(m => m.SendAudioJobToQueue(It.IsAny <AudioJob>()), Times.Once());
            Assert.IsFalse(File.Exists(testFileResult));
        }
Exemplo n.º 17
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }
 public AudioController(AudioRepository audioRepo)
 {
     _audioRepo = audioRepo;
 }