public void InitializeAndStartGame() { Setup(); Initialize(); BeginStory.StartStory(); }
private async void NextQuestion() { Selected = string.Empty; var _Available = m_Questions.Where(x => !x.Answered).ToArray(); if (!_Available.Any()) { return; } var _NextIndex = m_Random.Next(0, (_Available.Count() - 1)); this.m_Question = _Available[_NextIndex]; this.Image = m_Question.Image; this.Answer = m_Question.Answer; // choices this.Choices.Clear(); await Task.Delay(100); // use the developer-supplied choices if (m_Question.Choices != null) { foreach (var item in m_Question.Choices) { this.Choices.Add(item); } } // use random choices from other answers if (!this.Choices.Any()) { // all the wrong answers var _Answers = m_Questions .Where(x => !x.Answer.Equals(m_Question.Answer)) .Select(x => x.Answer).Distinct().ToList(); for (int i = 0; i < m_Question.DesiredChoices; i++) { var _Index = m_Random.Next(0, _Answers.Count() - 1); var _Answer = _Answers[_Index]; this.Choices.Add(_Answer); _Answers.Remove(_Answer); } // an the correct answer { m_Random = new Random((int)DateTime.Now.Ticks); var _Index = m_Random.Next(0, this.Choices.Count() - 1); this.Choices.Insert(_Index, m_Question.Answer); } } // start animation BeginStory.Begin(); // update live tile (SQUARE ONLY) await SetTileNotification(); }