// Start is called before the first frame update
    void Start()
    {
        if (gameObject.activeInHierarchy)
        {
            gameObject.SetActive(false);
        }

        // button listeners
        resume.onClick.AddListener(delegate { Resume(); });
        restart.onClick.AddListener(delegate { Restart(); });
        help.onClick.AddListener(delegate { Help(); });
        exit.onClick.AddListener(delegate { Exit(); });

        // find the level's main script
        levelScript = GameObject.Find("Quiz UI").GetComponent <Jeopardy>();
    }
Esempio n. 2
0
        /// <summary>
        /// Gets the questions from the XML file
        /// </summary>
        /// <returns></returns>
        public List <Category> GetQuestions()
        {
            //Create a new instance of the XML Serializer class
            XMLSerializer ser = new XMLSerializer();

            //Variable to hold the path of the file
            string path = string.Empty;

            //Variables to hold the input and output
            string xmlInputData  = string.Empty;
            string xmlOutputData = string.Empty;

            path         = Directory.GetCurrentDirectory() + @"\Jeopardy.xml";
            xmlInputData = File.ReadAllText(path);

            //Use the XML serializer to walk through the XML structure and assign
            //Each node to customer class properties
            Jeopardy jeopardy = ser.Deserialize <Jeopardy>(xmlInputData);

            return(jeopardy.Category);
        }
Esempio n. 3
0
            public async Task Jeopardy(params string[] args)
            {
                JeopardyOptions opts = OptionsParser.ParseFrom(new JeopardyOptions(), args);

                if (Service.ActiveGames.TryGetValue(Context.Channel.Id, out Jeopardy activeGame))
                {
                    await Context.Channel.SendErrorAsync("Jeopardy game is already in progress in current channel.").ConfigureAwait(false);

                    await Context.Channel.EmbedAsync(new EmbedBuilder().WithColor(activeGame.Color)
                                                     .WithAuthor("Jeopardy!")
                                                     .WithTitle($"{activeGame.CurrentClue.Category.Name} - ${activeGame.CurrentClue.Value}")
                                                     .WithDescription(activeGame.CurrentClue.Text)
                                                     .WithFooter($"#{activeGame.CurrentClue.Id} | answer with a question, e.g. what's x, who's x"))
                    .ConfigureAwait(false);

                    return;
                }

                await _semaphore.WaitAsync();

                Jeopardy jeopardy;

                try
                {
                    List <Category> categories = await Service.GenerateGame(opts.NumCategories).ConfigureAwait(false);

                    jeopardy = new Jeopardy(_client, await _config.GetGuildConfigAsync(Context.Guild.Id), categories, Context.Guild, Context.Channel as ITextChannel, _currency, await Service.GenerateFinalJeopardy());
                }
                catch (Exception e)
                {
                    Log.Error(e, "Could not start jeopardy game");
                    _semaphore.Release();
                    return;
                }


                if (Service.ActiveGames.TryAdd(Context.Channel.Id, jeopardy))
                {
                    _semaphore.Release();
                    try
                    {
                        await jeopardy.StartGame().ConfigureAwait(false);
                    }
                    finally
                    {
                        Service.ActiveGames.TryRemove(Context.Channel.Id, out jeopardy);
                        if (jeopardy != null)
                        {
                            await jeopardy.EnsureStopped().ConfigureAwait(false);

                            jeopardy.Dispose();
                        }
                    }
                }
                else
                {
                    _semaphore.Release();
                    Log.Error("Could not start jeopardy game");
                    jeopardy.Dispose();
                }
            }
Esempio n. 4
0
 public GameModel()
 {
     JRound  = new Jeopardy();
     DJRound = new DoubleJeopardy();
     FJRound = new FinalJeopardy();
 }