/// <summary> /// Checks out who the current speaker is, and adjusts the state of every character. /// </summary> /// <param name="candidateSpeaker"></param> /// <returns></returns> public InformSpeakerReturn InformSpeaker(string candidateSpeaker) { // find out who is the active speaker // arrange accordingly bool shouldRearrange = false; // extract description var speakingParts = candidateSpeaker.Split(','); candidateSpeaker = speakingParts[0]; var description = speakingParts.Length != 2 ? "" : speakingParts[1]; if (_narratingCharacter.IsSimilar(candidateSpeaker)) { currentSpeaking = _narratingCharacter; } else if (_mainCharacter.IsSimilar(candidateSpeaker)) { currentSpeaking = _mainCharacter; } else { foreach (var character in _activeCharacterList) { if (character.IsSimilar(candidateSpeaker)) { currentSpeaking = character; shouldRearrange = true; break; } } if (!shouldRearrange) { Debug.LogWarning($"Speaker not found: {candidateSpeaker}"); } } if (shouldRearrange) { _activeCharacterList.Remove(currentSpeaking); _activeCharacterList.Insert(0, currentSpeaking); } _narratingCharacter.UpdateStatus(description); _mainCharacter.UpdateStatus(description); foreach (var character in _activeCharacterList) { character.UpdateStatus(description); } informSpeakerReturnValue.character = currentSpeaking; informSpeakerReturnValue.realName = currentSpeaking.RealName; return(informSpeakerReturnValue); }
private void Awake() { Debug.Assert(gameConfiguration != null); var characterPrefabList = gameConfiguration.characterPrefabList; _characterList = new UnifiedCharacterScript[characterPrefabList.Length]; for (int i = 0; i < characterPrefabList.Length; i++) { _characterList[i] = InstantiateCharacter(characterPrefabList[i]); } _narratingCharacter = InstantiateCharacter(gameConfiguration.narratingCharacterPrefab); _mainCharacter = InstantiateCharacter(gameConfiguration.mainCharacterPrefab); if (_saveClient == null) { _saveClient = gameConfiguration.RequestSaveAccess(this); } }
/// <summary> /// Checks what the index is for an active character in the stack of characters who last spoke. /// This is useful for determining their position when there are multiple side characters active in the scene. /// </summary> /// <param name="unifiedCharacterScript"></param> /// <returns></returns> public int GetSideCharacterIndex(UnifiedCharacterScript unifiedCharacterScript) { return(_activeCharacterList.IndexOf(unifiedCharacterScript)); }