public virtual void AddIcons(DialogueOptionInitializer doi, RHSpeaker speaker, RHConversation conversation) { string timeStr = Time.ToString("F2") + " s"; doi.AddTextIcon(timeStr, Color.white); for (int i = 0; i < 5; i++) { RHStat s = (RHStat)i; float sum = 0; int numListeners = 0; foreach (RHListener l in conversation.Listeners.Keys) { if (l == speaker.GetComponent <RHListener>()) { continue; } float f = GetPower(speaker, l, conversation, s); sum += f; numListeners++; } if (Mathf.Abs(sum) <= 1) { continue; } Color c = RHManager.ProportionToColor(GetBasePower(s), sum / numListeners); doi.AddIcon(RHManager.GetStatIcon(s), sum.ToString("F1"), c, (sum > 0) ? Color.white : Color.red); } }
private void initializeSpeaker(RHSpeaker s, int colorIndex, RHSpeaker startingSpeaker) { this.m_speakers.Add(s); RHListener l = s.GetComponent <RHListener>(); this.m_listeners_with_scores.Add(l, startingScore(l)); this.m_listeners.Add(l); m_queue.RegisterSpeaker(s); if (s.speakerColor == Color.white) { m_speakerColorMaps[s] = m_defaultColors[colorIndex]; } else { m_speakerColorMaps[s] = s.speakerColor; } List <RHStatement> stlist = GetAvailableStatements(s); s.OnRhetoricStart(stlist, this, this.m_listeners); if (s == startingSpeaker) { return; } GameObject go = Instantiate(RHManager.PrefabUIListener(), RHManager.ListenersBaseTransform()); go.GetComponent <RHUIListener>().InitializeUI(l, this, startingSpeaker, m_speakerColorMaps[l.GetComponent <RHSpeaker>()]); l.GetComponent <AITaskManager>()?.triggerEvent(new AIEVConversationStarted(this)); }
public void OnReceiveStatement(RHRegisteredStatement rs) { RHStatement statement = rs.statement; RHSpeaker speaker = rs.speaker; RHConversation c = rs.conversation; GetComponent <AITaskManager>()?.triggerEvent(new AIEVStatementReceived(c, statement, speaker)); Dictionary <RHStat, float> results = new Dictionary <RHStat, float>(); for (int i = 0; i < 5; i++) { RHStat s = (RHStat)i; float power = statement.GetPower(speaker, this, c, s); float diff = applyStatementModifiers(power, rs, s); if (diff == 0) { continue; } results[s] = diff; ModifyStat(speaker, c, s, diff); } statement.OnStatementReceived(speaker, this, c, results); RHManager.AddHistoryText(GetResponseString(statement, speaker, results)); }
private void Update() { if (m_checkTextboxFinished) { if (m_textboxToCheckFinished == null || m_textboxToCheckFinished.IsFinished()) { RHManager.SetPause(false); } } }
private void ProcessHistoryText(RHStatement st, RHSpeaker speaker, RHListener listener, float diff) { foreach (RHResponseString s in m_registeredResponses) { if (s.IsConditionTrue(st, m_previousStatements, speaker, listener, diff, m_startingSpeaker)) { RHManager.AddHistoryText(s); } } }
void Awake() { if (m_instance == null) { m_instance = this; } else if (m_instance != this) { Destroy(gameObject); return; } }
public void OnRhetoricStart(List <RHStatement> availableStatements, RHConversation conversation, List <RHListener> listeners) { if (GetComponent <MovementBase>() != null && GetComponent <MovementBase>().IsPlayerControl) { //RHManager.CreateDialogueOptionList(availableStatements,this, conversation); RHManager.SetResourceUIActive(this); } foreach (RHPersonalityTrait t in m_traits) { t.OnSpeakerStart(this, listeners, conversation); } }
void updateIcons() { foreach (Transform rt in m_iconTransform) { Destroy(rt.gameObject); } foreach (RHResource r in speaker.RHResources) { GameObject icon = Instantiate(TextboxManager.ImagePrefab, m_iconTransform); icon.GetComponentInChildren <Image>().sprite = RHManager.GetResourceIcon(r.m_resourceType); icon.GetComponentInChildren <TextMeshProUGUI>().text = r.m_Amount.ToString(); } }
public void RefreshStatementMenu(RHSpeaker s) { List <RHStatement> stlist = GetAvailableStatements(s); float scroll = 0f; DialogueOptionBox dop = FindObjectOfType <DialogueOptionBox>(); if (dop != null) { Destroy(dop.gameObject); scroll = dop.GetScrollValue(); } RHManager.CreateDialogueOptionList(stlist, s, this, "Select your next statement", scroll); }
// Update is called once per frame void Update() { if (m_conversation == null && !convoGenerated) { m_conversation = GenerateConversation(); if (m_autoGenerateListener) { randomizeListener(DefaultListener, m_conversation.GetComponent <RHConversation>()); } List <RHSpeaker> participants = new List <RHSpeaker>(); participants.Add(DefaultSpeaker); participants.Add(DefaultListener.GetComponent <RHSpeaker>()); RHManager.StartRhetoricBattle(m_conversation.GetComponent <RHConversation>(), participants, DefaultSpeaker); convoGenerated = true; } }
private static DialogueOptionInitializer convertToDialogueOption(RHStatement s, List <RHStatement> allStatements, RHSpeaker speaker, RHConversation baseConversation) { DialogueOptionInitializer doi = new DialogueOptionInitializer(); void SelectionFunction(DialogueOption selectedOption) { baseConversation.QueueStatement(s, baseConversation.Speakers[0]); RHManager.CreateDialogueOptionList(allStatements, speaker, baseConversation, "Select your next Statement", FindObjectOfType <DialogueOptionBox>().GetScrollValue()); } string name = s.StatementName; if (name == null || name == "") { name = s.gameObject.name; } doi.SelectionText = name; doi.OnSelect = SelectionFunction; doi.CloseDialogueWindow = true; s.AddIcons(doi, speaker, baseConversation); string missingRequirements = baseConversation.MeetsRequirements(s, speaker); doi.Interactable = (missingRequirements == "Meets Requirements"); doi.hoverText = (doi.Interactable) ? s.GetHoverText(baseConversation) : missingRequirements; //string timeStr = s.Time.ToString("F2") + " s"; //doi.AddTextIcon(timeStr, Color.white); //foreach (RHListener l in baseConversation.Listeners.Keys) //{ // if (l == speaker.GetComponent<RHListener>()) // continue;v // float f = s.GetPower(baseConversation.Speakers[0], l, baseConversation); // Color c = proportionToColor(s.BasePower, f); // doi.AddTextIcon(f.ToString("F2"), c); // doi.Interactable = s.IsEnabled(baseConversation.Speakers[0],baseConversation); //} return(doi); }
public void AddLine(string s, Color c, int fontSize, bool checkTextboxFinished = false) { GameObject go = Instantiate(TextPrefab, Content); TextMeshProUGUI t = go.GetComponentInChildren <TextMeshProUGUI>(); Textbox tbox = go.GetComponent <Textbox>(); tbox.setText(s); t.color = c; t.alpha = 1.0f; t.fontSize = fontSize; Vector2 oldSize = Content.sizeDelta; Content.sizeDelta = new Vector2(oldSize.x, oldSize.y + SIZE_OF_TEXT); ScrollSlider.value = 0.0f; if (checkTextboxFinished) { RHManager.SetPause(true); m_checkTextboxFinished = true; m_textboxToCheckFinished = tbox; } }
public void CloseConversation() { RHManager.UITime().SetActive(false); RHManager.UITime().GetComponent <RHUITime>().ClearItems(); RHManager.ClearHistory(); RHManager.SetHistoryTextActive(false); RHManager.SetResourceUIInActive(); RHManager.FinishBox.gameObject.SetActive(false); m_isFinished = true; if (m_currentDialogueBox != null) { Destroy(m_currentDialogueBox); } if (m_destroyAfterFinish) { Destroy(gameObject); } ScaledTime.SetPause(false, true); ScaledTime.SetScale(1f); }
public static void CreateDialogueOptionList(List <RHStatement> statements, RHSpeaker speaker, RHConversation baseConversation, string prompt = "Select your next statement", float scroll = 0.0f) { DialogueSelectionInitializer dialogue = new DialogueSelectionInitializer(prompt); List <RHStatement> sortedStatements = new List <RHStatement>(); sortedStatements = RHManager.SortedList(statements, speaker, baseConversation); foreach (RHStatement s in sortedStatements) { DialogueOptionInitializer doi = convertToDialogueOption(s, statements, speaker, baseConversation); dialogue.AddDialogueOption(doi); } void Close(DialogueOption selectedOption) { } dialogue.AddDialogueOption("Close", Close); GameObject go = TextboxManager.StartDialogueOptions(dialogue); go.GetComponent <DialogueOptionBox>().SetScrollValue(scroll); baseConversation.SetDialogueBox(go); }
public void StartRhetoricBattle(List <RHSpeaker> participants, RHSpeaker startingSpeaker) { if (participants.Count == 0) { Debug.LogError("Conversation attempted with 0 participants"); return; } ScaledTime.SetPause(true, true); m_nextStatementEnd = ScaledTime.UITimeElapsed; m_nextInterestTimeLimit = ScaledTime.UITimeElapsed + m_startingInterest; RHManager.UITime().SetActive(true); m_timeUI = RHManager.UITime().GetComponent <RHUITime>(); m_timeUI.StartUI(this); m_queue = new RHQueue(); ScaledTime.SetScale(0f); m_lastScaled = ScaledTime.UITimeElapsed; this.m_listeners_with_scores = new Dictionary <RHListener, float>(); this.m_listeners = new List <RHListener>(); this.m_speakers = new List <RHSpeaker>(); m_speakerColorMaps = new Dictionary <RHSpeaker, Color>(); int colorIndex = 0; m_startingSpeaker = startingSpeaker; foreach (RHSpeaker s in participants) { initializeSpeaker(s, colorIndex, startingSpeaker); colorIndex = (colorIndex + 1) % m_defaultColors.Count; } RefreshStatementMenu(m_startingSpeaker); m_previousStatements = new List <RHStatement>(); RHManager.ClearHistory(); RHManager.SetHistoryTextActive(true); RHManager.AddHistoryText(m_introText); }
private void processSlowInput() { if (!m_canSlow) { return; } if (Input.GetKeyDown("space")) { if (ScaledTime.GetScale(true) == 0.0f) { RHManager.SetPause(false); } else if (ScaledTime.GetScale(true) == 1.0f) { RHManager.SetSlowTextActive(true); ScaledTime.SetScale(0.5f, true); } else { RHManager.SetSlowTextActive(false); ScaledTime.SetScale(1.0f, true); } } }