public float CalculateQueuedStatementExecutionTime(RHRegisteredStatement RHRegisteredStatement, float m_nextStatementEnd) { float executionTime = m_nextStatementEnd; int tempIndex = m_nextSpeakerIndex; Dictionary <RHSpeaker, int> nextEntry = new Dictionary <RHSpeaker, int>(); int emptyQueues = 0; while (emptyQueues < m_speakers.Count) { RHSpeaker nextSpeaker = m_speakers[tempIndex]; tempIndex = (tempIndex + 1) % m_speakers.Count; List <RHRegisteredStatement> queue = m_statementQueue[nextSpeaker]; if (!nextEntry.ContainsKey(nextSpeaker)) { nextEntry[nextSpeaker] = 0; } if (queue.Count > nextEntry[nextSpeaker]) { RHRegisteredStatement next_statement = queue[nextEntry[nextSpeaker]]; if (next_statement == RHRegisteredStatement) { break; } executionTime += next_statement.statement.Time; nextEntry[nextSpeaker]++; emptyQueues = 0; } else { emptyQueues++; } } return(executionTime); }
private void onStatementStarted(RHRegisteredStatement st) { m_currentStatement = st; st.statement.OnStatementStarted(st.speaker); registerEvents(st.statement.RHEvents, st.speaker, ScaledTime.UITimeElapsed); m_nextStatementEnd = ScaledTime.UITimeElapsed + m_currentStatement.statement.Time; }
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 float applyStatementModifiers(float baseValue, RHRegisteredStatement rs, RHStat s) { foreach (RHPersonalityTrait t in m_traits) { baseValue = t.OnStatementUsed(baseValue, rs.statement, this, rs.speaker, rs.conversation, s); } return(baseValue); }
private void BroadcastStatement(RHRegisteredStatement rs) { rs.statement.OnStatementFinished(rs.speaker); foreach (RHListener listener in m_listeners) { if (listener.GetComponent <RHSpeaker>() == rs.speaker) { continue; } listener.OnReceiveStatement(rs); } }
public void RemoveItem(RHRegisteredStatement rs) { foreach (Transform t in ActiveTransform.transform) { RHUITimePiece piece = t.gameObject.GetComponent <RHUITimePiece>(); if (piece.Statement == rs) { moveFollowingStatements(piece.TimeItemStarts, piece.Statement.statement.Time); Destroy(t.gameObject); break; } } }
public void SetPiecePiece(RHRegisteredStatement rs, float startingTime, Color backgroundColor, bool interactable, float scaling_factor = 32) { string name = rs.statement.StatementName; float duration = rs.statement.Time; GetComponent <Image>().color = new Color(backgroundColor.r * DARKEN_FACTOR, backgroundColor.g * DARKEN_FACTOR, backgroundColor.b * DARKEN_FACTOR, 0.75f); GetComponent <RectTransform>().sizeDelta = new Vector2(duration * scaling_factor, 40f); m_text.text = name; m_statement = rs; m_timeItemStarts = startingTime; m_button.interactable = interactable; }
private void advanceStatements() { RHRegisteredStatement next_statement = m_queue.PopStatement(); if (next_statement == null) { QueueStatement(RHManager.DeadAirPrefab.GetComponent <RHStatement>(), m_startingSpeaker, true); advanceStatements(); } else { onStatementStarted(next_statement); } }
public void RemoveStatement(RHRegisteredStatement registeredStatmenet) { int removeIndex = 0; bool found = false; foreach (RHRegisteredStatement rs in m_statementQueue[registeredStatmenet.speaker]) { if (rs.statement == registeredStatmenet.statement) { found = true; break; } removeIndex++; } if (found) { m_statementQueue[registeredStatmenet.speaker].RemoveAt(removeIndex); } }
public void QueueStatement(RHStatement statement, RHSpeaker speaker, bool stack = false) { if (!m_battleStarted) { startActiveBattle(); } statement.OnStatementQueued(speaker); RHRegisteredStatement rs = new RHRegisteredStatement(statement, speaker, this); m_queue.RegisterStatement(rs); bool clickable = speaker == m_startingSpeaker && ((statement as RHSDeadAir) == null); m_timeUI.AddItem(rs, m_speakerColorMaps[speaker], m_queue.CalculateQueuedStatementExecutionTime(rs, m_nextStatementEnd), stack, clickable); if (!m_battleStarted) { advanceStatements(); } m_battleStarted = true; }
public void AddItem(RHRegisteredStatement rs, Color backgroundColor, float timeItemStarts, bool canStack = false, bool clickable = false) { float duration = rs.statement.Time; string name = rs.statement.StatementName; if (canStack && m_lastStatementName == name) { ExpandLastStatement(duration); return; } GameObject newObj = Instantiate(TimeElementActivePrefab, ActiveTransform.transform); moveFollowingStatements(timeItemStarts, duration); float t = (timeItemStarts - startingTime) * SCALING_FACTOR; newObj.GetComponent <RHUITimePiece>().SetPiecePiece(rs, timeItemStarts, backgroundColor, clickable, SCALING_FACTOR); newObj.GetComponent <RectTransform>().anchoredPosition = new Vector2(t, 0f); m_lastStatementName = name; m_lastTimePiece = newObj; }
public RHRegisteredStatement PopStatement() { RHRegisteredStatement next_statement = null; int emptyQueues = 0; while (emptyQueues < m_statementQueue.Keys.Count) { RHSpeaker nextSpeaker = m_speakers[m_nextSpeakerIndex]; m_nextSpeakerIndex = (m_nextSpeakerIndex + 1) % m_speakers.Count; List <RHRegisteredStatement> queue = m_statementQueue[nextSpeaker]; if (queue.Count > 0) { next_statement = m_statementQueue[nextSpeaker][0]; m_statementQueue[nextSpeaker].RemoveAt(0); break; } else { emptyQueues++; } } return(next_statement); }
public void RegisterStatement(RHRegisteredStatement rs) { m_statementQueue[rs.speaker].Add(rs); }
public void DequeueStatement(RHRegisteredStatement rs) { rs.statement.OnStatementCancelled(rs.speaker); m_timeUI.RemoveItem(rs); m_queue.RemoveStatement(rs); }