public void DisplayChoiceEvent(ChoiceEvent e) { Channel MessageChannel = Channels.Find(x => x.ChannelName == e.Channel); if (MessageChannel != null) { //TODO: Instead of instantly displaying the panel, think about the actual flow we want here - some sort of notification system? /* * if (CurrentlyActiveChannel != e.Channel) * { * HideAllMessagePanels(); * MessageChannel.MessagePanel.SetActive(true); * } */ GameObject message; message = GameObject.Instantiate(ChoicePrefab, MessageChannel.ContentPanel.transform); for (int i = 0; i < e.Choices.Count; i++) { GameObject ChoiceButton = GameObject.Instantiate(ChoiceButtonPrefab, message.transform); ChoiceButton.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = e.Choices[i]; int choiceIndex = i; ChoiceButton.GetComponentInChildren <Button>().onClick.AddListener(delegate { HandleChoice(e, e.Channel, choiceIndex, message, e.Choices); }); //audio for choice AkSoundEngine.PostEvent("ChoiceAppear", gameObject); } CleanCanvases(MessageChannel); } }
public void SetPanel(ChoiceEvent choiceEvent) { if (choiceEvent == null) { Hide(); return; } eventAvailable = choiceEvent; ClearFields(); choice1Btn.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0); choice1Description.GetComponent <RectTransform>().offsetMin = new Vector2(0, 0); choice1Btn.onClick.RemoveAllListeners(); choice2Btn.onClick.RemoveAllListeners(); SetPanel(); choice2Btn.gameObject.SetActive(true); choice1Btn.gameObject.SetActive(true); choice2Btn.onClick.AddListener(choiceEvent.FireSecondEvent); choice1Btn.onClick.AddListener(choiceEvent.FireEvent); choice2Btn.onClick.AddListener(Hide); choice1Btn.onClick.AddListener(Hide); choice1Description.text = choiceEvent.choice1; choice2Description.text = choiceEvent.choice2; choice2Description.text = choice2Description.text.Replace("\\n", "\n"); choice1Description.text = choice1Description.text.Replace("\\n", "\n"); result1.text = choiceEvent.result1; result2.text = choiceEvent.result2; }
public void Update() { if (nextEventTime < Time.time) { ShowScenario(ChoiceEvent.GenerateRandomChoiceEvent()); } }
public void It_has_3_choices() { var choiceInfo = new DummyChoiceEventInfo(); var choiceEvent = new ChoiceEvent(choiceInfo); Assert.AreEqual(choiceEvent.Choices.Count, 3); }
private void SendEvent(string Choice) { if (bIsLoading) { return; // loading previously made choice } ChoiceEvent?.Invoke(new clsChoiceEventArgs(QuestionNumber, Choice)); }
void EventVoteCallback(VoteManager voteManager) { if (currentGameEvent) { Debug.Log(voteManager.winningVote); if ((int)voteManager.winningVote < 4) { Debug.LogError("Direction received instead of answer!"); } else if (voteManager.winningVote == VoteResponse.Yes) { SoundManager.instance.Play2DSong("HoorayChildren"); eventText.text = currentGameEvent.yesResult.text; while (eventText.text.Contains("[p]")) { eventText.text = eventText.text.Replace("[p]", firstNames[Random.Range(0, firstNames.Length - 1)] + " " + lastNames[Random.Range(0, lastNames.Length - 1)]); } Village.instance.AddVillagers(currentGameEvent.noResult.peopleChange); Village.instance.AddVillagers(currentGameEvent.noResult.peopleChange); } else if (voteManager.winningVote == VoteResponse.No) { SoundManager.instance.Play2DSong("KidsBooing"); eventText.text = currentGameEvent.noResult.text; while (eventText.text.Contains("[p]")) { eventText.text = eventText.text.Replace("[p]", firstNames[Random.Range(0, firstNames.Length - 1)] + " " + lastNames[Random.Range(0, lastNames.Length - 1)]); } Village.instance.AddVillagers(currentGameEvent.noResult.peopleChange); Village.instance.AddVillagers(currentGameEvent.noResult.peopleChange); } else if (currentGameEvent is ChoiceEvent && voteManager.winningVote == VoteResponse.Tie) { ChoiceEvent choiceEvent = (ChoiceEvent)currentGameEvent; eventText.text = choiceEvent.tieResult.text; while (eventText.text.Contains("[p]")) { eventText.text = eventText.text.Replace("[p]", firstNames[Random.Range(0, firstNames.Length - 1)] + " " + lastNames[Random.Range(0, lastNames.Length - 1)]); } Village.instance.AddVillagers(choiceEvent.tieResult.peopleChange); Village.instance.AddFood(choiceEvent.tieResult.foodChange); } voteSlider.value = voteManager.noVotePercentage; StartCoroutine(FinishEvent()); } }
public void Returns_true_if_player_passes_condition() { var choiceInfo = new CheckChoiceEventInfo(); var choiceEvent = new ChoiceEvent(choiceInfo); var firstChoice = choiceEvent.Choices[0]; Assert.IsTrue(choiceEvent.Choose(firstChoice, new DummyContext())); Assert.AreEqual(choiceEvent.CurrentChoice, firstChoice); }
public void Returns_false_if_player_cannot_choose_it() { var choiceInfo = new FailChoiceEventInfo(); var choiceEvent = new ChoiceEvent(choiceInfo); var unavailableChoice = choiceEvent.Choices[0]; Assert.IsFalse(choiceEvent.Choose(unavailableChoice, new DummyContext())); Assert.IsNull(choiceEvent.CurrentChoice); }
public void Setup(ChoiceEvent choiceEvent) { titleText.SetText(choiceEvent.title); scenarioText.SetText(choiceEvent.scenario); foreach (ChoiceEvent.Option option in choiceEvent.options) { StoryEventOptionUI optionUI = Instantiate(optionPrefab, optionList); optionUI.Setup(option); } }
void ProcessQueues() { if (WaitingOnChoiceCount <= 0 && TotalWaitCount <= 0 && !DisplayManager.instance.WaitingForPlayerInput) { CurrentGameRealTime += (Time.deltaTime * DebugTimeFactor); //foreach (KeyValuePair<string, PriorityQueue<GameEvent>> kvp in Queues) { if (MainEventQueue.Count() > 0 && MainEventQueue.Peek().GameTimeToBeActivated <= CurrentGameRealTime)//(kvp.Value.Count() > 0 && kvp.Value.Peek().GameTimeToBeActivated <= CurrentGameRealTime) { //GameEvent currentEvent = kvp.Value.Dequeue(); GameEvent currentEvent = MainEventQueue.Dequeue(); ChoiceEvent choiceEvent = currentEvent as ChoiceEvent; if (choiceEvent != null) { Debug.Log("Dequeuing choice event with " + choiceEvent.Choices.Count + " choices in channel " + choiceEvent.Channel + " because its activation time was " + choiceEvent.GameTimeToBeActivated + " and our time is " + CurrentGameRealTime + "."); CurrentGameRealTime = choiceEvent.GameTimeToBeActivated; DisplayManager.instance.DisplayChoiceEvent(choiceEvent); WaitingOnChoiceCount++; CurrentActiveChoices.Add(choiceEvent); } else { Debug.Log("Dequeueing event with content: " + currentEvent.Content + " DisplayTime: " + currentEvent.DisplayTime + " Character: " + currentEvent.CharacterName + " because its activation time was " + currentEvent.GameTimeToBeActivated + " and our time is " + CurrentGameRealTime + "."); CurrentGameEventTime = (currentEvent.GameTimeToBeActivated == 0 ? CurrentGameEventTime : currentEvent.GameTimeToBeActivated); DisplayManager.instance.DisplayEvent(currentEvent); PastEvents.Add(currentEvent); if (currentEvent.ShouldWaitAfter && DisplayManager.instance.GetCurrentlyActiveChannel() != currentEvent.Channel) { TotalWaitCount++; if (ChannelWaitCounts.ContainsKey(currentEvent.Channel)) { ChannelWaitCounts[currentEvent.Channel]++; } else { ChannelWaitCounts.Add(currentEvent.Channel, 1); } } } } if (MainEventQueue.Count() == 0 && WaitingOnChoiceCount <= 0) { //Our queue is empty, let's see if the ink manager has more stuff for us //Debug.Log("Advancing story from queue"); //InkManager.instance.AdvanceStory(kvp.Key); InkManager.instance.AdvanceStories(); } } } else { //Debug.Log("Stuck waiting! Waiting for choice: " + WaitingOnChoiceCount + " waiting for name: " + WaitingForNameInput+" waiting for player: "+DisplayManager.instance.WaitingForPlayerInput); } }
/// <summary> /// Left Menu /// </summary> private void ToolStripButton1_Click(object sender, EventArgs e) { if (!(sender is ToolStripButton tsb)) { return; } switch (tsb.Name) { case "tsbPen": ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.pencil)); break; case "tsbLine": ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.line)); break; case "tsbCircle": ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.circle)); break; case "tsbRectangle": ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.rectangle)); break; case "tsbThickness": if (fontDialog.ShowDialog() != DialogResult.OK || this.tsbThickness.Text == fontDialog.Font.Size.ToString()) { return; } this.tsbThickness.Text = fontDialog.Font.Size.ToString(); ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.width, fontDialog.Font.Size)); break; case "tsbColor": if (colorDialog.ShowDialog() != DialogResult.OK || tsbColor.ForeColor == colorDialog.Color) { return; } tsbColor.ForeColor = colorDialog.Color; ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.color, colorDialog.Color)); break; case "tsbFill": isFill = !isFill; ChoiceEvent?.Invoke(new ChoiceEventArgs(Components.fill)); break; } }
public void AdvanceStory(string Channel) { if (!CurrentStories.ContainsKey(Channel)) { //No channel of that name - for now during early dev, that's fine, but we should put in an error eventually to catch this case Debug.LogError("Tried to advancestory on channel " + Channel + " which was not found!"); return; } Debug.Log("AdvanceStory " + Channel); //If we can continue, that means that we have no choices to worry about and there's still content to go //if (CurrentStories[Channel].canContinue) { while (CurrentStories[Channel].canContinue) { string newText = CurrentStories[Channel].Continue().Trim(); ParseLine(newText, CurrentStories[Channel].currentTags, CurrentStories[Channel].globalTags); } } if (CurrentStories[Channel].currentChoices.Count > 0) { //We have a choice for the player to make - we need to deal with that separately //TODO: Create a new event that is a choice and pass that on to the event manager ChoiceEvent choiceEvent = new ChoiceEvent(); choiceEvent.Channel = Channel; //No data besides the channel applies to choices choiceEvent.Choices = new List <string>(); for (int i = 0; i < CurrentStories[Channel].currentChoices.Count; i++) { choiceEvent.Choices.Add(CurrentStories[Channel].currentChoices[i].text); } //Put in a delay before displaying choices, so that they aren't instantaneous. This gives the player time to read the last message, //plus for us to play the correct animations. if (CurrentTimeClocks.ContainsKey(Channel)) { choiceEvent.GameTimeToBeActivated = CurrentTimeClocks[Channel] + ChoiceDelaySeconds; } else { Debug.LogError("Channel '" + Channel + "' has no associated key in the time clocks dictionary; skipping the choice " + choiceEvent.Choices[0] + "/" + choiceEvent.Choices[1]); return; } TimelineManager.instance.AddEventToQueue(choiceEvent); } //Otherwise we need to figure something else out else { } }
public void NextNode(ChoiceEvent eventdata) { if (!ConversationModeOn) { return; } var curOP = (ConvChoice)CurrentNode; foreach (var choice in curOP.Options) { if (choice.choicedata == eventdata.choicedata) { NextNode(choice.DestinationNode); return; } } }
public void HandleChoice(ChoiceEvent e, string Channel, int ChoiceIndex, GameObject ChoiceUI, List <string> choices) { //Debug.Log("Handle choice called with channel " + Channel + " and index " + ChoiceIndex); InkManager.instance.HandleChoice(Channel, ChoiceIndex); string ChoicesString = ""; foreach (string choice in choices) { ChoicesString += choice + " ---- "; } Debug.Log(AnalyticsEvent.Custom("choice_made", new Dictionary <string, object> { { "choice_chosen", choices[ChoiceIndex] } })); GameObject.Destroy(ChoiceUI); AkSoundEngine.PostEvent("ChoicePick", gameObject); TimelineManager.instance.ChoiceMade(e); }
/// <summary> /// This method is in charge of retrieving the result of the Choice dialog fragment. /// </summary> /// <param name="sender"> Reference to the object that raised the event </param> /// <param name="e"> Contains the event data </param> private void ChoiceAction(object sender, ChoiceEvent e) { using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" }; var url = "resources/getRecipe?id=" + e.RecipeId; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var request = webClient.DownloadString(url); var response = e.Message; if (response == 0) { var recipeIntent = new Intent(this, typeof(RecipeActivity)); recipeIntent.PutExtra("Recipe", request); recipeIntent.PutExtra("LoggedId", _loggedUser.email); StartActivity(recipeIntent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } else { url = "resources/deleteRecipe?email=" + _loggedUser.email + "&id=" + e.RecipeId + "&fromMyMenu=1"; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; webClient.DownloadString(url); url = "resources/getUser?id=" + _loggedUser.email; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var json = webClient.DownloadString(url); var intent = new Intent(this, typeof(MyProfileActivity)); intent.PutExtra("User", json); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); Finish(); _toast = Toast.MakeText(this, "Recipe deleted. Refreshing MyProfile...", ToastLength.Short); _toast.Show(); } }
public void ChoiceMade(ChoiceEvent e) { WaitingOnChoiceCount--; CurrentGameEventTime = CurrentGameRealTime; CurrentActiveChoices.Remove(e); }
public void ImplementChoice(ChoiceEvent eventdata) { choiceInfo = eventdata.choicedata; txt.text = choiceInfo.text; Active = true; }
public void ShowScenario(ChoiceEvent choiceEvent) { nextEventTime = PickNextEventTime(); scenarioUIInstance = PopupManager.Show(scenarioUIPrefab); scenarioUIInstance.Setup(choiceEvent); }
public void BeforeAll() { var choiceInfo = new DummyChoiceEventInfo(); _choiceEvent = new ChoiceEvent(choiceInfo); }