public void SetCurrentChoice(ChoiceSelector choice) { ChoiceSelect = choice; //Preview = choice.TextMD; CurrentChoices = choice; switch (choice.ChoiceNo) { case 1: SetPreview(choice.TextMD, System.Windows.Media.Color.FromRgb(206, 49, 68)); break; case 2: SetPreview(choice.TextMD, System.Windows.Media.Color.FromRgb(255, 201, 14)); break; case 3: SetPreview(choice.TextMD, System.Windows.Media.Color.FromRgb(34, 177, 76)); break; case 4: SetPreview(choice.TextMD, System.Windows.Media.Color.FromRgb(0, 162, 232)); break; default: SetPreview(choice.TextMD, System.Windows.Media.Color.FromRgb(0, 0, 0)); break; } }
private void RunChoiceDialogue(ChoiceDialogue choiceDialogue) { // Clear the choices menu foreach (Transform child in choicePanelContainer.transform) { GameObject.Destroy(child.gameObject); } // Add new choices to the menu int numberOfChoices = choiceDialogue.choices.Length; for (int i = 0; i < numberOfChoices; i++) { GameObject choiceBox = Instantiate(choicePrefab, new Vector3(0, 0, 0), Quaternion.identity, choicePanelContainer.transform) as GameObject; Text choiceText = choiceBox.GetComponent <Text>(); choiceText.text = choiceDialogue.choicesText[i]; ChoiceSelector choiceOnClick = choiceBox.GetComponent <ChoiceSelector>(); // Capture the value of i for the lambda int currentI = i; choiceOnClick.SelectThisChoice += () => { choicePanel.SetActive(false); // Assume choice box is never last currentDialogue = choiceDialogue.choices[currentI]; RunCurrentDialogue(); }; } choicePanel.SetActive(true); }
/// <summary> /// Method responsible for selecting and instantiating the respective /// Choice Buttons of the current Dialogue /// </summary> private void InstatiateChoices() { foreach (Transform g in buttonLayout.transform) { Destroy(g.gameObject); } int choiceNumb = dialogueLine.OutPorts.Count; if (choiceNumb == 0) { return; } else if (choiceNumb == 1) { if (dialogueLine.OutPorts[0].Name == "") { return; } } for (int i = 0; i < choiceNumb; i++) { GameObject temp = Instantiate(buttonPREFAB, transform.position, Quaternion.identity, buttonLayout.transform); temp.GetComponent <TextMeshProUGUI>().text = dialogueLine.OutPorts[i].Name; ChoiceSelector cs = temp.GetComponent <ChoiceSelector>(); cs.ChoiceNumb = i; cs.NextLine = NextLine; } buttonLayout.SetActive(false); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) { ChoiceSelector choice = (ChoiceSelector)value; if (TestingData.State != "CheckAnswer") { if (choice.ChoiceNo == 0) { var onAns = Colors.Black; onAns.R = (byte)68; onAns.G = (byte)68; onAns.B = (byte)68; return(new SolidColorBrush(onAns)); } else { var Ans = Colors.Black; Ans.R = (byte)44; Ans.G = (byte)84; Ans.B = (byte)234; return(new SolidColorBrush(Ans)); } } else { if (choice.IsCorrect.HasValue && choice.IsCorrect.Value) { var Correct = Colors.Black; Correct.R = (byte)51; Correct.G = (byte)205; Correct.B = (byte)95; return(new SolidColorBrush(Correct)); } else { var InCorrect = Colors.Black; InCorrect.R = (byte)239; InCorrect.G = (byte)71; InCorrect.B = (byte)58; return(new SolidColorBrush(InCorrect)); } } } else { var onAns = Colors.Black; onAns.R = (byte)68; onAns.G = (byte)68; onAns.B = (byte)68; return(new SolidColorBrush(onAns)); } }
private void SetChoice(int chosenChoiceNo) { //this.choices = new ObservableCollection<ChoiceSelector>(); int i = 1; if (QuestionSelect.Question.Choices.Count() > 0) { foreach (var item in QuestionSelect.Question.Choices) { ChoiceSelector choice = new ChoiceSelector() { ChoiceNo = i, _id = item._id, Detail = item.Detail, IsCorrect = false, IsSelected = i == chosenChoiceNo, QuestionNo = QuestionSelect.Question.QuestionNumber }; if (TestingData.State == "CheckAnswer") { choice.IsCorrect = item.IsCorrect.HasValue ? item.IsCorrect.Value : false; choice.IsSelected = item._id == QuestionSelect.Question.UserAnswer?._id; } ChoiceViewModel c = new ChoiceViewModel(); c.Choice = choice; c.ChoiceNo = choice.ChoiceNo; c.Callback = SetCurrentChoice; if (choice.ChoiceNo == 1) { First = c; } else if (choice.ChoiceNo == 2) { Second = c; } else if (choice.ChoiceNo == 3) { Third = c; } else if (choice.ChoiceNo == 4) { Fourth = c; } i++; } } }
public ExamViewModel() { if (!DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { svc = new OnsiteServices(); CurrentSheet = new ExamSheetResponse(); CurrentSheet = TestingData.sheet; IsTimpUp = false; State = TestingData.State; BorderColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)); First = new ChoiceViewModel { Callback = SetCurrentChoice }; Second = new ChoiceViewModel { Callback = SetCurrentChoice }; Third = new ChoiceViewModel { Callback = SetCurrentChoice }; Fourth = new ChoiceViewModel { Callback = SetCurrentChoice }; QuestionSelect = new QuestionViewModel { Callback = SetQPreview }; ChoiceSelect = new ChoiceSelector(); SelectIndex = 0; currentQuestionNo = 1; CurrentAnswer = new Answer(); Answers = new List <Answer>(); InitializeAnswers(); //MainExamVisibility = Visibility.Collapsed; //ExamAns = new ExamAnsViewModel(); //ExamAns.Answers = Answers; QuestionSelect = new QuestionViewModel(); #region TimeCal if (TestingData.State != "CheckAnswer" && this.IsTimpUp == false) { Duration = new TimeSpan(0, 0, TestingData.TestDuration); DisplayDuration = Duration.ToString(); Timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; Timer.Tick += (sndr, se) => { if (Duration <= new TimeSpan(0, 0, 0)) { SendResult(); if (this.IsTimpUp) { SendResultEvent(this, new Models.SendResultArgs { IsTimeUp = true }); this.IsTimpUp = false; } } Duration = Duration.Subtract(TimeSpan.FromSeconds(1)); TestingData.TestDuration = (int)Duration.TotalSeconds; DisplayDuration = Duration.ToString(); }; Timer.Start(); } #endregion TimeCal ProfilePhoto = TestingData.ProfilePhoto; FullName = TestingData.sheet.FirstName + " " + TestingData.sheet.LastName; SubjectName = TestingData.sheet.SubjectName; TestingData.Activity = StudentActivity.Testing; // ART //if (Answers.Count() == 0) //{ // InitializeAnswers(); //} //set current question choice SetCurrentQuestion(currentQuestionNo); MainExamVisibility = Visibility.Visible; ExamAnsVisibility = Visibility.Collapsed; SendExamVisibility = Visibility.Collapsed; AlertResult = Visibility.Collapsed; BtnChooseVisibility = Visibility.Collapsed; } }
// Start void Start() { canNext = false; dialogueActive = false; lastChoiceID = 0; sceneName = SceneManager.GetActiveScene().name; if (sceneName.Contains("Day")) { inputFile = sceneName; } else { // Shops will use the JSON dialogue file belonging to the current Day scene inputFile = GameController.GetPreviousScene(); } switch (inputFile[3]) { case '1': startIndex = startIndexOne; endIndex = endIndexOne; break; case '2': startIndex = startIndexTwo; endIndex = endIndexTwo; break; } try { player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovementController>(); } catch (NullReferenceException e) { } // Initialize all parent GameObjects for hiding and showing dialogue UI uiDialogue = GameObject.FindGameObjectWithTag("DialogueUI"); canDialogue = uiDialogue.transform.GetChild(1).gameObject; // Initialize dialogue text txtSpeaker = canDialogue.transform.GetChild(1).GetComponent <Text>(); txtDialogue = canDialogue.transform.GetChild(0).GetComponent <Text>(); choiceSelector = GetComponent <ChoiceSelector>(); lastNextTime = -999f; lastShowChoiceTime = -999f; dialogue = DialogueUtils.initDialogueForScene(inputFile); // Used only to translate dialogue from CSV into JSON //DialogueUtils.storeDialogueFromFile("Day2", "Day2"); // If there is initial dialogue to display and it hasn't been displayed before if (startIndex != 0 && !GameController.getLoadedScenes().Contains(sceneName) || !sceneName.Contains("Day")) { Show(startIndex); } GameController.addLoadedScene(sceneName); }