コード例 #1
0
        protected async void InitTimerTick(object sender, EventArgs e)
        {
            if (m_buffer == null)
            {
                return;
            }
            m_buffer.InitStage++;

            switch (m_buffer.InitStage)
            {
            case 1:
                string initialText = await LoadGameForRequest();

                if (m_player == null)
                {
                    tmrInit.Enabled = false;
                }
                else
                {
                    RegisterExternalScripts();
                    RegisterExternalStylesheets();
                }

                OutputTextNow(initialText);
                break;

            case 2:
                tmrInit.Enabled = false;

                m_player.BeginGame();
                OutputTextNow(m_player.ClearBuffer());
                break;
            }
        }
コード例 #2
0
ファイル: Play.aspx.cs プロジェクト: hyrmedia/quest
        private string LoadGame(string gameFile, string id, string folder, string loadData, AzureFileManager.ApiGame apiGameData)
        {
            if (string.IsNullOrEmpty(gameFile) && loadData == null)
            {
                return "No game specified";
            }

            string rootPath = folder ?? ConfigurationManager.AppSettings["GameFolder"];
            string libPath = ConfigurationManager.AppSettings["LibraryFolder"];
            string filename;

            if (Config.ReadGameFileFromAzureBlob)
            {
                filename = gameFile;
            }
            else
            {
                filename = WebPlayer.Play.GetGameFilename(gameFile, rootPath);
                if (filename == null)
                {
                    return "Invalid filename";
                }
            }

            List<string> errors;

            try
            {
                m_player = new PlayerHandler(filename, m_buffer);
                m_player.LoadData = loadData;
                m_player.ApiGameData = apiGameData;
                m_player.GameId = m_gameId;
                m_player.LibraryFolder = libPath;
                Games[m_gameId] = m_player;
                m_player.BeginWait += m_player_BeginWait;
                m_player.BeginPause += m_player_BeginPause;
                m_player.ShowMenuDelegate = m_player_ShowMenu;
                m_player.ShowQuestionDelegate = m_player_ShowQuestion;
                m_player.AddResource += AddResource;
                m_player.PlayAudio += m_player_PlayAudio;
                m_player.StopAudio += m_player_StopAudio;
                if (Config.ReadGameFileFromAzureBlob)
                {
                    m_player.ResourceUrlRoot = AzureFileManager.GetResourceUrlRoot(id);
                }

                if (m_player.Initialise(out errors))
                {
                    Resources.AddGame(m_player.Game);

                    // Successful game start
                    return m_player.ClearBuffer();
                }
            }
            catch (Exception ex)
            {
                return "<b>Error loading game:</b><br/>" + ex.Message;
            }

            string output = string.Empty;

            foreach (string error in errors)
            {
                output += error + "<br/>";
            }

            return output;
        }
コード例 #3
0
        private string LoadGame(string gameFile, bool?isCompiled, string id, string folder, string loadData, AzureFileManager.ApiGame apiGameData)
        {
            if (string.IsNullOrEmpty(gameFile) && loadData == null)
            {
                return("No game specified");
            }

            string rootPath = folder ?? ConfigurationManager.AppSettings["GameFolder"];
            string libPath  = ConfigurationManager.AppSettings["LibraryFolder"];
            string filename;

            if (Config.ReadGameFileFromAzureBlob)
            {
                filename = gameFile;
            }
            else
            {
                filename = WebPlayer.Play.GetGameFilename(gameFile, rootPath);
                if (filename == null)
                {
                    return("Invalid filename");
                }
            }

            List <string> errors;

            try
            {
                m_player                      = new PlayerHandler(filename, m_buffer);
                m_player.LoadData             = loadData;
                m_player.ApiGameData          = apiGameData;
                m_player.GameId               = m_gameId;
                m_player.LibraryFolder        = libPath;
                Games[m_gameId]               = m_player;
                m_player.BeginWait           += m_player_BeginWait;
                m_player.BeginPause          += m_player_BeginPause;
                m_player.ShowMenuDelegate     = m_player_ShowMenu;
                m_player.ShowQuestionDelegate = m_player_ShowQuestion;
                m_player.AddResource         += AddResource;
                m_player.PlayAudio           += m_player_PlayAudio;
                m_player.StopAudio           += m_player_StopAudio;
                if (Config.ReadGameFileFromAzureBlob)
                {
                    m_player.ResourceUrlRoot = AzureFileManager.GetResourceUrlRoot(id);
                }

                if (m_player.Initialise(out errors, isCompiled))
                {
                    Resources.AddGame(m_player.Game);

                    // Successful game start
                    return(m_player.ClearBuffer());
                }
            }
            catch (Exception ex)
            {
                return("<b>Error loading game:</b><br/>" + ex.Message);
            }

            string output = string.Empty;

            foreach (string error in errors)
            {
                output += error + "<br/>";
            }

            return(output);
        }