Example #1
0
 internal MusicPlayer(AudioClipsStorer clipStorer)
 {
     if (!SharedServices.HasService <ICoroutineRunner>())
     {
         SharedServices.RegisterService <ICoroutineRunner>(new CoroutineRunner());
     }
     _clipStorer = clipStorer;
     _source     = new GameObject("MusicPlayer").AddComponent <AudioSource>();
     UnityEngine.Object.DontDestroyOnLoad(_source.gameObject);
     _source.playOnAwake  = false;
     _source.spatialBlend = 0f;
 }
Example #2
0
        private void ProcessInputFile()
        {
            try
            {
                if (_challengeConfiguration != null)
                {
                    if (SharedServices.HasService(typeof(ChallengeInitializationService)))
                    {
                        _challenge = SharedServices.GetService <ChallengeInitializationService>().InitializeChallenge(_challengeConfiguration);
                        OnReportMessageSet(this, new EventArgs.HandlerEventArgs(this, "Toy Robot Challenge initialized...", false));

                        if (!String.IsNullOrEmpty(_inputCommandFilePath))
                        {
                            List <string> stringCommands = null;

                            if (SharedServices.HasService(typeof(CommandParsingService)))
                            {
                                stringCommands = SharedServices.GetService <CommandParsingService>().ParseCommandFile(_inputCommandFilePath);

                                if (stringCommands != null && SharedServices.HasService(typeof(CommandConversionService)))
                                {
                                    List <List <IRobotCommand> > robotCommands = SharedServices.GetService <CommandConversionService>().ConvertStringCommands(stringCommands);

                                    if (robotCommands != null && robotCommands.Count > 0 && SharedServices.HasService(typeof(CommandExecutionService)))
                                    {
                                        SharedServices.GetService <CommandExecutionService>().CommandExecuted += CommandExecutionService_CommandExecuted;

                                        foreach (List <IRobotCommand> commandlist in robotCommands)
                                        {
                                            SharedServices.GetService <CommandExecutionService>().ExecuteCommands(_challenge.ActiveRobot, commandlist);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _errMsg = String.Format("Unable to process the configuration due to an error. {0}", ex.Message);
                throw new Exception(_errMsg);
            }
        }