void UpdateCharPositionAndScale(bool isLeft) { mIsUpdatedPosScale = true; DialogueData.Dialogue currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; if (currDialogue.character.charPosList.Count != 0) { if (isLeft) { if (characterSpriteList[0].spriteState == CharacterSprite.SpriteState.IN_SCREEN) { return; } leftCharacter.transform.localPosition = currDialogue.character.charPosList[0].position; leftCharacter.transform.localScale = currDialogue.character.charPosList[0].localScale; } else { if (characterSpriteList[1].spriteState == CharacterSprite.SpriteState.IN_SCREEN) { return; } rightCharacter.transform.localPosition = currDialogue.character.charPosList[1].position; rightCharacter.transform.localScale = currDialogue.character.charPosList[1].localScale; } } }
// Handle the showing of how to show the sentences to player. void HandleDialogueText(DialogueData.Dialogue currDialogue) { int currSentenceCount = currDialogue.sentenceList.Count; if (mCurrSentenceIndex < currSentenceCount) { DialogueData.Dialogue.Sentence currSentence = currDialogue.sentenceList[mCurrSentenceIndex]; if (mIsShowingSentence) { // Skip the type-writer style writing and show full sentence. StopCoroutine(coroutine); mDialogueText.text = currSentence.text; SetToNextSentence(); } else if (!mIsShowingSentence) { if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.NONE) { if (currDialogue.isLeft) { mActiveCharacterSpriteState = ActiveCharacterSpriteState.LEFT; } else { mActiveCharacterSpriteState = ActiveCharacterSpriteState.RIGHT; } } string charName = currDialogue.character.name.ToString(); UpdateCharacterSprite(currSentence); ShowNextDialogue(currSentence, charName); } } }
//---------------------------------------------------------------------------------------------- //------------------------------------INFO PANEL FUNCTIONS-------------------------------------- //---------------------------------------------------------------------------------------------- void SetCharactersList() { for (int i = 0; i < mSelf.dialogueList.Count; i++) { DialogueData.Dialogue currDialogue = mSelf.dialogueList[i]; string charStr = currDialogue.character.name.ToString(); bool isInside = false; if (charStr == "NONE") { continue; } // Check to see whether charStr is already inside mCharTotalList. If true, +1 count. for (int j = 0; j < mCharTotalList.Count; j++) { if (mCharTotalList[j].name == charStr) { isInside = true; mCharTotalList[j].count++; break; } } if (!isInside) { mCharTotalList.Add(new CharacterTotal(charStr, 1)); } } }
void HandleMoveOutTime(DialogueData.Dialogue currDialogue) { if (currDialogue.disappearMeth == DialogueData.Dialogue.AppearMethod.FADE) { bool isLeft = currDialogue.isLeft; DialogueSlide.sSingleton.MoveChar(false, isLeft, false, currDialogue.time.moveOutTime); if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) { characterSpriteList[0].spriteState = CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN; } else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT) { characterSpriteList[1].spriteState = CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN; } mCurrentState = CurrentState.DIALOGUE_SHOW; } else if (currDialogue.disappearMeth == DialogueData.Dialogue.AppearMethod.SLIDE) { Transform trans = null; if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) { trans = leftCharacter.transform; } else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT) { trans = rightCharacter.transform; } endDialogueIcon.gameObject.SetActive(false); DialogueSlide.sSingleton.SpriteSlideOut(trans, currDialogue.isLeft, currDialogue.time.moveOutTime); } }
IEnumerator ShowDialogueLines() { QuestionBox.SetActive(false); LineBox.SetActive(true); LetterIndex = 0; LineIndex = 0; LineLabel.text = ""; CurrentUnalteredLine = ""; CurrentLine = ""; OnDialogueStarted?.Invoke(); Debug.Log("on dialogue started"); OnLineStarted?.Invoke(); DialogueData.Dialogue currentDialogue = Dialogue.dialogues[DialogueIndex]; Distortion.ApplyDistortion(currentDialogue.lines[LineIndex].Length * SpeakRate); textAudioSource.Play(); while (true) { yield return(new WaitForSeconds(SpeakRate)); string newLetter = "" + currentDialogue.lines[LineIndex][LetterIndex]; CurrentUnalteredLine += newLetter; if (Distortion.IsDistortionActive && newLetter != " ") { if (ReadLips.IsReadingLips) { newLetter = "<color=red>" + newLetter + "</color>"; } else { newLetter = "*"; } } CurrentLine += newLetter; LetterIndex++; if (LetterIndex == currentDialogue.lines[LineIndex].Length) { textAudioSource.Stop(); OnLineFinished?.Invoke(); yield return(new WaitForSeconds(PauseBetweenLines)); LineIndex++; if (LineIndex >= currentDialogue.lines.Length) { break; } OnLineStarted?.Invoke(); CurrentUnalteredLine = ""; CurrentLine = ""; LineLabel.text = ""; LetterIndex = 0; textAudioSource.Play(); Distortion.ApplyDistortion(currentDialogue.lines[LineIndex].Length * SpeakRate); } } OnDialogueFinished?.Invoke(); Debug.Log("On dialogue finished"); ShowQuestion(); }
// Set left and right character's sprite and state. void CharSpriteState() { if (currDialogueData > dialogueDataList.Count - 1) { return; } DialogueData.Dialogue firstDiag = dialogueDataList[currDialogueData].dialogueList [0]; Sprite firstSprite = firstDiag.sentenceList [0].sprite; DialogueData.Dialogue secondDiag = null; Sprite secondSprite = null; for (int i = 1; i < dialogueDataList[currDialogueData].dialogueList.Count; i++) { DialogueData.Dialogue currDiag = dialogueDataList[currDialogueData].dialogueList [i]; if (currDiag.character.name != CharacterData.Info.Character.NONE && firstDiag.character.name != currDiag.character.name) { secondDiag = currDiag; break; } } if (secondDiag != null) { secondSprite = secondDiag.sentenceList [0].sprite; } if (firstDiag.isLeft) { mActiveCharacterSpriteState = ActiveCharacterSpriteState.LEFT; characterSpriteList[0].characterSpriteRend.sprite = firstSprite; if (secondSprite != null) { characterSpriteList[1].characterSpriteRend.sprite = secondSprite; } if (!dialogueDataList[currDialogueData].isBothAppear) { characterSpriteList[1].spriteState = CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN; } } else { mActiveCharacterSpriteState = ActiveCharacterSpriteState.RIGHT; characterSpriteList[1].characterSpriteRend.sprite = firstSprite; if (secondSprite != null) { characterSpriteList[0].characterSpriteRend.sprite = secondSprite; } if (!dialogueDataList[currDialogueData].isBothAppear) { characterSpriteList[0].spriteState = CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN; } } SetActiveCharacterSpriteShade(); }
//---------------------------------------------------------------------------------------------- //-------------------------------------PRIVATE FUNCTIONS---------------------------------------- //---------------------------------------------------------------------------------------------- void Initialize() { if (mSelf == null) { return; } dialogueInfo = mSelf.GetDialogueInfo(); ClearLists(); for (int i = 0; i < mSelf.dialogueList.Count; i++) { DialogueData.Dialogue currDialogue = mSelf.dialogueList[i]; mIsControlList.Add(false); mIsMessedUpList.Add(false); if (currDialogue.time.moveInTime != 0) { mIsAppearList.Add(true); } else { mIsAppearList.Add(false); } if (currDialogue.time.delayTime != 0) { mIsAddDelayList.Add(true); } else { mIsAddDelayList.Add(false); } if (currDialogue.time.reOpenTime != 0) { mIsReOpenList.Add(true); } else { mIsReOpenList.Add(false); } if (currDialogue.time.moveOutTime != 0) { mIsDisappearList.Add(true); } else { mIsDisappearList.Add(false); } } SetMessedUpMessage(); SetCharactersList(); }
// Put sprite out of the screen if it is still within the screen. void PutSpriteOutScreen(DialogueData.Dialogue currDialogue) { if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT && characterSpriteList[0].spriteState == CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN) { DialogueSlide.sSingleton.SpriteOut(leftCharacter.transform, currDialogue.isLeft); characterSpriteList[0].spriteState = CharacterSprite.SpriteState.OUT_SCREEN; } else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT && characterSpriteList[1].spriteState == CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN) { DialogueSlide.sSingleton.SpriteOut(rightCharacter.transform, currDialogue.isLeft); characterSpriteList[1].spriteState = CharacterSprite.SpriteState.OUT_SCREEN; } }
void SetDirectionToNewDialogue() { bool isLeft = true; for (int i = 0; i < mSelf.dialogueList.Count; i++) { DialogueData.Dialogue currDialogue = mSelf.dialogueList[i]; if (currDialogue.character.name == mSelf.defaultCharacter) { isLeft = currDialogue.isLeft; break; } } mSelf.dialogueList[mSelf.dialogueList.Count - 1].isLeft = isLeft; }
//---------------------------------------------------------------------------------------------- //-------------------------------------PUBLIC FUNCTIONS----------------------------------------- //-----------------------Only called when DialogueSlide animation is done----------------------- //---------------------------------------------------------------------------------------------- public void SetDialogueShowInScreen() { if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) { characterSpriteList[0].spriteState = CharacterSprite.SpriteState.IN_SCREEN; } else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT) { characterSpriteList[1].spriteState = CharacterSprite.SpriteState.IN_SCREEN; } mCurrentState = CurrentState.DIALOGUE_SHOW; DialogueData.Dialogue currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; HandleDialogueText(currDialogue); }
void SetCharacterDirectionFromOthers(DialogueData.Dialogue setDialogue) { CharacterData.Info.Character name = setDialogue.character.name; for (int i = 0; i < mSelf.dialogueList.Count; i++) { DialogueData.Dialogue currDialogue = mSelf.dialogueList[i]; if (currDialogue == setDialogue) { continue; } else if (currDialogue.character.name == name) { setDialogue.isLeft = currDialogue.isLeft; break; } } }
// Move the other character into screen if it is not in screen or is invisible. void AppearCharOnScreen(DialogueData.Dialogue currDialogue) { bool isLeft = currDialogue.isLeft; DialogueSlide.sSingleton.MoveChar(true, isLeft, false, currDialogue.time.moveInTime); if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) { characterSpriteList [0].spriteState = CharacterSprite.SpriteState.IN_SCREEN; } else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT) { characterSpriteList [1].spriteState = CharacterSprite.SpriteState.IN_SCREEN; } HandleDialogueText(currDialogue); }
void SetSameCharacterDirection(DialogueData.Dialogue getDialogue) { CharacterData.Info.Character name = getDialogue.character.name; bool isLeft = getDialogue.isLeft; for (int i = 0; i < mSelf.dialogueList.Count; i++) { DialogueData.Dialogue currDialogue = mSelf.dialogueList[i]; if (currDialogue == getDialogue) { continue; } else if (currDialogue.character.name == name) { currDialogue.isLeft = isLeft; } } }
// Check to see whether the next character is None. bool IsNextCharacterNone(DialogueData.Dialogue currDialogue) { CharacterData.Info.Character nextChar; int nextIndex = mCurrDialogueIndex + 1; if (nextIndex >= dialogueDataList[currDialogueData].dialogueList.Count) { nextIndex = 0; } nextChar = dialogueDataList[currDialogueData].dialogueList[nextIndex].character.name; if (nextChar.ToString() == "NONE") { return(true); } return(false); }
public bool isBothAppear; // Do both character sprites appear at the start of the dialogue. public AllDialogueInfo GetDialogueInfo() { allDialogueInfo.Clear(); List <string> charStrList = new List <string>(); allDialogueInfo.totalDialogue = dialogueList.Count; for (int i = 0; i < dialogueList.Count; i++) { DialogueData.Dialogue currDialogue = dialogueList[i]; string charStr = currDialogue.character.name.ToString(); bool isInside = false; if (charStr != "NONE") { for (int j = 0; j < charStrList.Count; j++) { if (charStrList[j] == charStr) { isInside = true; break; } } if (!isInside) { charStrList.Add(charStr); } } allDialogueInfo.totalSentence += currDialogue.sentenceList.Count; int answerCount = dialogueList[i].answerChoiceList.Count; if (answerCount != 0) { allDialogueInfo.selectionPhase += 1; allDialogueInfo.totalAnswer += answerCount; for (int j = 0; j < answerCount; j++) { allDialogueInfo.totalResponse += dialogueList[i].answerChoiceList[j].responseList.Count; } } } allDialogueInfo.totalCharacter = charStrList.Count; return(allDialogueInfo); }
// Skip to the next dialogue box. void SetToNextSentence() { DialogueData.Dialogue currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; int textCount = currDialogue.sentenceList.Count; if (mCurrSentenceIndex + 1 < textCount) { mCurrSentenceIndex++; mIsShowingSentence = false; mCurrentState = CurrentState.DIALOGUE_SHOW; endDialogueIcon.gameObject.SetActive(true); } else { mCurrSentenceIndex = 0; int answerCount = currDialogue.answerChoiceList.Count; StartCoroutine(CoroutineInOrder(DelayTime(currDialogue.time.delayTime), WaitForAnswerChoices(currDialogue.answerChoiceList))); } }
// Check to see whether the next character is the same. bool IsNextCharacterTheSame(DialogueData.Dialogue currDialogue) { CharacterData.Info.Character currChar, nextChar; currChar = currDialogue.character.name; int nextIndex = mCurrDialogueIndex + 1; if (nextIndex >= dialogueDataList[currDialogueData].dialogueList.Count) { nextIndex = 0; } nextChar = dialogueDataList[currDialogueData].dialogueList[nextIndex].character.name; if (currChar == nextChar) { return(true); } return(false); }
void HandleMoveInTime(DialogueData.Dialogue currDialogue) { mCurrentState = CurrentState.DIALOGUE_PAUSE; endDialogueIcon.gameObject.SetActive(false); Transform trans = null; Vector3 defaultTarget = new Vector3(); if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) { trans = leftCharacter.transform; defaultTarget = defaultLeftSprPos; } else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT) { trans = rightCharacter.transform; defaultTarget = defaultRightSprPos; } DialogueSlide.sSingleton.SpriteSlideIn(trans, defaultTarget, currDialogue.isLeft, currDialogue.time.moveInTime); }
IEnumerator WaitTimeBasedOnCurrentDialogue() { mCurrentState = CurrentState.DIALOGUE_PAUSE; DialogueData.Dialogue currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; DialogueSlide.sSingleton.DisappearAll(false); yield return(new WaitForSeconds(currDialogue.time.reOpenTime)); mCurrDialogueIndex++; mIsUpdatedPosScale = false; currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.NONE) { if (currDialogue.isLeft) { mActiveCharacterSpriteState = ActiveCharacterSpriteState.LEFT; } else { mActiveCharacterSpriteState = ActiveCharacterSpriteState.RIGHT; } } DialogueData.Dialogue.Sentence currSentence = currDialogue.sentenceList[0]; string charName = currDialogue.character.name.ToString(); UpdateCharacterSprite(currSentence); ShowNextDialogue(currSentence, charName); if (dialogueDataList[currDialogueData].isBothAppear) { DialogueSlide.sSingleton.AppearAll(); mCurrentState = CurrentState.DIALOGUE_SHOW; } }
// Handle the moving in of character potraits and dialogue sentences. void HandleDialogueShow() { DialogueData.Dialogue currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; // Update current character state. if (currDialogue.isLeft) { mActiveCharacterSpriteState = ActiveCharacterSpriteState.LEFT; } else { mActiveCharacterSpriteState = ActiveCharacterSpriteState.RIGHT; } if (mCurrDialogueIndex != 0 && !mIsUpdatedPosScale) { UpdateCharPositionAndScale(currDialogue.isLeft); } mIsSwapActive = false; // ------------------------------HANDLE MOVE-IN TIME------------------------------ if (currDialogue.time.moveInTime > 0 && ((mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT && characterSpriteList[0].spriteState != CharacterSprite.SpriteState.IN_SCREEN) || (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT && characterSpriteList[1].spriteState != CharacterSprite.SpriteState.IN_SCREEN))) { if (currDialogue.appearMeth == DialogueData.Dialogue.AppearMethod.FADE) { // TODO : defaultLeft and defaultRight to follow characterData postList. // if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) leftCharacter.transform.position = defaultLeftSprPos; // else if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT) rightCharacter.transform.position = defaultRightSprPos; AppearCharOnScreen(currDialogue); } else if (currDialogue.appearMeth == DialogueData.Dialogue.AppearMethod.SLIDE) { PutSpriteOutScreen(currDialogue); UpdateCharacterSprite(currDialogue.sentenceList[0]); HandleMoveInTime(currDialogue); } } else { // Fade in character if it's invisible in screen. (Alpha 0 to 1). if ((mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT && characterSpriteList[0].spriteState == CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN) || (mActiveCharacterSpriteState == ActiveCharacterSpriteState.RIGHT && characterSpriteList[1].spriteState == CharacterSprite.SpriteState.INVISIBLE_IN_SCREEN)) { AppearCharOnScreen(currDialogue); if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.LEFT) { characterSpriteList[0].spriteState = CharacterSprite.SpriteState.IN_SCREEN; } else { characterSpriteList[1].spriteState = CharacterSprite.SpriteState.IN_SCREEN; } } else { HandleDialogueText(currDialogue); } } }
void SetToNextDialogue() { DialogueData.Dialogue currDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; int dialogueCount = dialogueDataList[currDialogueData].dialogueList.Count; mIsShowingSentence = false; if (mCurrDialogueIndex + 1 < dialogueCount) { CharacterData.Info.Character currChar = currDialogue.character.name; CharacterData.Info.Character nextChar = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex + 1].character.name; bool isNextCharNone = IsNextCharacterNone(currDialogue); if (currChar != CharacterData.Info.Character.NONE && isNextCharNone) { mSavedActiveCharacter = currDialogue.character.name; } else if (currChar != CharacterData.Info.Character.NONE && nextChar != mSavedActiveCharacter) { mIsSwapActive = !isNextCharNone && !IsNextCharacterTheSame(currDialogue); } if (currDialogue.time.reOpenTime != 0) { mCurrentState = CurrentState.DIALOGUE_RE_OPEN; } else { // ------------------------------HANDLE MOVE-OUT TIME------------------------------ if (currDialogue.time.moveOutTime > 0) { HandleMoveOutTime(currDialogue); } else { mCurrentState = CurrentState.DIALOGUE_SHOW; } // --------------------------------END MOVE-OUT TIME------------------------------- mCurrDialogueIndex++; mIsUpdatedPosScale = false; // Set back the active character's state. if (mActiveCharacterSpriteState == ActiveCharacterSpriteState.NONE) { DialogueData.Dialogue nextDialogue = dialogueDataList[currDialogueData].dialogueList[mCurrDialogueIndex]; if (nextDialogue.isLeft) { mActiveCharacterSpriteState = ActiveCharacterSpriteState.LEFT; } else { mActiveCharacterSpriteState = ActiveCharacterSpriteState.RIGHT; } } } } else if (mCurrDialogueIndex + 1 >= dialogueCount) { mCurrentState = CurrentState.DIALOGUE_ENDED; currDialogueData++; // mIsFirstStart = true; // GameManager.sSingleton.state = GameManager.State.NONE; // Debug.Log("Ended"); } }
void SetMessedUpMessage() { if (mSelf.dialogueList.Count == 0) { return; } List <List <DialogueData.Dialogue> > totalList = new List <List <DialogueData.Dialogue> >(); List <DialogueData.Dialogue> tempList = new List <DialogueData.Dialogue>(); DialogueData.Dialogue currDialogue = mSelf.dialogueList[0]; tempList.Add(currDialogue); // Separate same bool(isLeft) in an orderly fashion. for (int i = 1; i < mSelf.dialogueList.Count; i++) { DialogueData.Dialogue nextDialogue = mSelf.dialogueList[i]; if (currDialogue.isLeft == nextDialogue.isLeft) { tempList.Add(nextDialogue); } else { totalList.Add(tempList); tempList = new List <DialogueData.Dialogue>(); tempList.Add(nextDialogue); } currDialogue = nextDialogue; } totalList.Add(tempList); int index = 0; for (int i = 0; i < totalList.Count; i++) { int jIndex = 0; string tempStr1 = GetFirstNameNotNone(totalList[i], 0, out jIndex); bool isDifferentName = false; if (tempStr1 != "") { // Check to see whether the names are the different in the nestedList. for (int j = jIndex + 1; j < totalList[i].Count; j++) { string tempStr2 = totalList[i][j].character.name.ToString(); if (tempStr2 == "NONE") { continue; } if (tempStr1 != tempStr2) { isDifferentName = true; break; } } } // Set mIsMessUpList to true or false. for (int j = 0; j < totalList[i].Count; j++) { string tempStr = totalList[i][j].character.name.ToString(); if (tempStr != "NONE" && isDifferentName) { mIsMessedUpList[j + index] = true; } else { mIsMessedUpList[j + index] = false; } } index = index + totalList[i].Count; } string firstStrName = "", secondStrName = ""; int firstNameIndex = -1, secondNameIndex = -1; List <int> savedHasTimeIndexList = new List <int>(); // Check to see whether there's moveOut and moveIn time. If true, messedUp is not shown. for (int i = 0; i < mIsMessedUpList.Count; i++) { if (mIsMessedUpList[i]) { if (firstStrName == "") { firstStrName = GetFirstNameNotNone(mSelf.dialogueList, i, out firstNameIndex); } secondStrName = GetFirstNameNotNone(mSelf.dialogueList, firstNameIndex + 1, out secondNameIndex); if (secondNameIndex == -1) { break; } if (firstStrName != secondStrName) { if (mSelf.dialogueList[firstNameIndex].time.moveOutTime != 0 && mSelf.dialogueList[secondNameIndex].time.moveInTime != 0) { int startIndex = GetStartIndexRecursive(firstStrName, firstNameIndex); for (int j = startIndex; j < firstNameIndex + 1; j++) { mIsMessedUpList[j] = false; } savedHasTimeIndexList.Add(secondNameIndex); } firstStrName = secondStrName; firstNameIndex = secondNameIndex; } } } // Set messedUp for the final character that has moveInTime. // It just follows the value of character before itself(which is not NONE). if (savedHasTimeIndexList.Count > 0) { for (int i = 0; i < savedHasTimeIndexList.Count; i++) { string finalStrName = mSelf.dialogueList[savedHasTimeIndexList[i]].character.name.ToString(); int finalIndex = GetEndIndexRecursive(finalStrName, savedHasTimeIndexList[i]); int prevLastIndex = GetPreviousLastIndexNotNone(finalStrName, savedHasTimeIndexList[i]); for (int j = savedHasTimeIndexList[i]; j < finalIndex + 1; j++) { mIsMessedUpList[j] = mIsMessedUpList[prevLastIndex]; } } } }
public override void OnInspectorGUI() { EditorStyles.textField.wordWrap = true; mSelf.characterData = (CharacterData)EditorGUILayout.ObjectField("CharacterData : ", mSelf.characterData, typeof(CharacterData), true); // EditorGUILayout.ObjectField("CharacterData : ",mSelf.characterData, typeof(UnityEngine.Object), true); EditorGUILayout.Space(); mIsShowInfoPanel = EditorGUILayout.Foldout(mIsShowInfoPanel, "Info panel", true); if (mIsShowInfoPanel) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical("GroupBox"); string allCharacters = ""; for (int i = 0; i < mCharTotalList.Count; i++) { allCharacters += mCharTotalList[i].name + ", "; } if (allCharacters != "") { allCharacters = allCharacters.Remove(allCharacters.Length - 2, 2); } GUIStyle infoStyle = new GUIStyle(EditorStyles.label); infoStyle.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("Info Panel", infoStyle); GUILayout.Label("Total dialogue : " + dialogueInfo.totalDialogue + "\t\tTotal characters : " + dialogueInfo.totalCharacter); GUILayout.Label("Total sentences : " + dialogueInfo.totalSentence + "\t\tSelection phase : " + dialogueInfo.selectionPhase); GUILayout.Label("Total answers : " + dialogueInfo.totalAnswer + "\t\tTotal response : " + dialogueInfo.totalResponse); GUILayout.Label("\nList of characters :\n" + allCharacters); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } mIsShowMarker = EditorGUILayout.Foldout(mIsShowMarker, "Marker Info", true); if (mIsShowMarker) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical("GroupBox"); GUILayout.Label("+/- : Add/Delete sentence\t+D/-D : Add/Delete dialogue"); GUILayout.Label("+A/-A : Add/Delete answer\tApp/Dis : Appear/Disappear"); GUILayout.Label("Dly : Delay\t\tRe : Close and Re-open"); // GUILayout.Label("+R : Add response\t-R : Delete response"); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (mSelf.characterData == null) { return; } GUILayout.BeginVertical("HelpBox"); EditorGUILayout.LabelField("DialogueList"); GUILayout.EndVertical(); for (int i = 0; i < mSelf.dialogueList.Count; i++) { // ------------------------------NEW HORIZONTAL------------------------------ if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } int id = i + 1; if (id == 1 || id % 10 == 0) { GUIStyle s = new GUIStyle(EditorStyles.label); s.normal.textColor = mIDColor; s.fontStyle = FontStyle.Bold; GUILayout.Label("ID " + id, s, GUILayout.Width(50)); } else { EditorGUILayout.LabelField("ID " + id, GUILayout.Width(50)); } DialogueData.Dialogue currDialogue = mSelf.dialogueList[i]; EditorGUI.BeginChangeCheck(); if (mSelf.characterData != null) { GUI.color = mSelf.characterData.GetCharacterColor(currDialogue.character.name.ToString()); } CharacterData.Info.Character prevSelectedName = currDialogue.character.name; currDialogue.character.name = (CharacterData.Info.Character)EditorGUILayout.EnumPopup(currDialogue.character.name, GUILayout.Width(100)); GUI.color = Color.white; CharacterData.Info.Character currCharName = currDialogue.character.name; if (EditorGUI.EndChangeCheck()) { if (currCharName == CharacterData.Info.Character.NONE) { mIsAppearList[i] = false; mIsDisappearList[i] = false; UpdateTotalWhenCharIsDeleted(prevSelectedName.ToString()); } else if (currCharName != CharacterData.Info.Character.NONE) { UpdateTotalWhenSwappingName(currCharName.ToString(), prevSelectedName.ToString()); SetCharacterDirectionFromOthers(currDialogue); mSelf.UpdateSpriteList(i, currCharName); mSelf.UpdateCharacterInfo(ref currDialogue.character); } SetMessedUpMessage(); } // Persistent messedUp message. if (currCharName != CharacterData.Info.Character.NONE) { EditorGUI.BeginChangeCheck(); EditorGUIUtility.labelWidth = 30.0f; currDialogue.isLeft = EditorGUILayout.Toggle("Left", currDialogue.isLeft); if (EditorGUI.EndChangeCheck()) { SetSameCharacterDirection(currDialogue); SetMessedUpMessage(); } if (mIsMessedUpList[i]) { GUIStyle s = new GUIStyle(EditorStyles.label); s.normal.textColor = mMessedUpColor; GUILayout.Label("Messed-up", s); } } GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(new GUIContent("V", "IsVisible"), GUILayout.Width(15)); if (GUILayout.Button("Edit", GUILayout.Width(50))) { SetIsControl(i); } EditorGUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ int textCount = currDialogue.sentenceList.Count; for (int j = 0; j < textCount; j++) { // ------------------------------NEW HORIZONTAL------------------------------ if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } DialogueData.Dialogue.Sentence currSentence = currDialogue.sentenceList[j]; GUI.color = mSentenceBgColor; currSentence.text = EditorGUILayout.TextArea(currSentence.text); GUI.color = Color.white; if (mIsAudio) { currSentence.audioClip = (AudioClip)EditorGUILayout.ObjectField(currSentence.audioClip, typeof(AudioClip), false, GUILayout.Width(50)); } if (currDialogue.character.name == CharacterData.Info.Character.NONE) { GUI.enabled = false; } currSentence.isCharVisible = EditorGUILayout.Toggle(currSentence.isCharVisible, GUILayout.Width(15)); if (GUILayout.Button("Select", GUILayout.Width(50))) { List <Sprite> charSpriteList = new List <Sprite>(); if (mSelf.characterData.GetCharacterSprites(currCharName) != null) { charSpriteList = mSelf.characterData.GetCharacterSprites(currCharName); } int currActiveTexture = mSelf.characterData.GetSpriteIndex(currCharName, currSentence.sprite); if (currActiveTexture != -1) { TexturePickerEditor.ListToEditorWindow(currSentence, currActiveTexture, charSpriteList); } else { Debug.Log("Couldn't find texture"); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ } int answerCount = currDialogue.answerChoiceList.Count; for (int j = 0; j < answerCount; j++) { if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } EditorGUILayout.LabelField("A" + (j + 1).ToString(), GUILayout.Width(20)); GUI.color = mAnswerBgColor; DialogueData.Dialogue.AnswerChoice currAnswer = currDialogue.answerChoiceList[j]; currAnswer.answer = EditorGUILayout.TextArea(currAnswer.answer); GUI.color = Color.white; int responseCount = currAnswer.responseList.Count; if (GUILayout.Button("+", GUILayout.Width(20))) { AddResponse(i, j); } if (responseCount <= 0) { GUI.enabled = false; } if (GUILayout.Button("-", GUILayout.Width(20))) { DeleteResponse(i, j); return; } GUI.enabled = true; // mSelf.characterData = (CharacterData) EditorGUILayout.ObjectField("CharacterData : ",mSelf.characterData, typeof(CharacterData), true); EditorGUILayout.EndHorizontal(); if (responseCount > 0) { for (int k = 0; k < responseCount; k++) { EditorGUILayout.BeginHorizontal(); GUI.color = mResponseBgColor; DialogueData.Dialogue.Sentence currResponse = currAnswer.responseList[k]; currResponse.text = EditorGUILayout.TextArea(currResponse.text); GUI.color = Color.white; currResponse.isCharVisible = EditorGUILayout.Toggle(currResponse.isCharVisible, GUILayout.Width(15)); if (GUILayout.Button("Select", GUILayout.Width(50))) { List <Sprite> charSpriteList = new List <Sprite>(); if (mSelf.characterData.GetCharacterSprites(currCharName) != null) { charSpriteList = mSelf.characterData.GetCharacterSprites(currCharName); } int currActiveTexture = mSelf.characterData.GetSpriteIndex(currCharName, currResponse.sprite); if (currActiveTexture != -1) { TexturePickerEditor.ListToEditorWindow(currResponse, currActiveTexture, charSpriteList); } else { Debug.Log("Couldn't find texture"); } } EditorGUILayout.EndHorizontal(); } } } // ------------------------------NEW HORIZONTAL------------------------------ // --------------------------------SHOW BOXES-------------------------------- if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } GUILayout.FlexibleSpace(); if (mIsAppearList.Count != 0 && mIsAppearList[i] || currDialogue.time.moveInTime > 0) { if (currDialogue.character.name != CharacterData.Info.Character.NONE) { EditorGUILayout.LabelField("Appear", GUILayout.Width(50)); currDialogue.appearMeth = (DialogueData.Dialogue.AppearMethod)EditorGUILayout.EnumPopup(currDialogue.appearMeth, GUILayout.Width(60)); EditorGUIUtility.labelWidth = 35.0f; currDialogue.time.moveInTime = EditorGUILayout.FloatField("Time", currDialogue.time.moveInTime, GUILayout.Width(70)); EditorGUIUtility.labelWidth = 0; } } if (mIsDisappearList.Count != 0 && mIsDisappearList[i] || currDialogue.time.moveOutTime > 0) { if (currDialogue.character.name != CharacterData.Info.Character.NONE) { EditorGUILayout.LabelField("Disappear", GUILayout.Width(65)); currDialogue.disappearMeth = (DialogueData.Dialogue.AppearMethod)EditorGUILayout.EnumPopup(currDialogue.disappearMeth, GUILayout.Width(60)); EditorGUIUtility.labelWidth = 35.0f; currDialogue.time.moveOutTime = EditorGUILayout.FloatField("Time", currDialogue.time.moveOutTime, GUILayout.Width(70)); EditorGUIUtility.labelWidth = 0; } } GUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ // ------------------------------NEW HORIZONTAL------------------------------ // --------------------------------SHOW BOXES-------------------------------- if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } GUILayout.FlexibleSpace(); if (mIsAddDelayList.Count != 0 && mIsAddDelayList[i] || currDialogue.time.delayTime != 0) { EditorGUIUtility.labelWidth = 70.0f; currDialogue.time.delayTime = EditorGUILayout.FloatField("Next Delay", currDialogue.time.delayTime, GUILayout.Width(105)); EditorGUIUtility.labelWidth = 0; } if (mIsReOpenList.Count != 0 && mIsReOpenList[i] || currDialogue.time.reOpenTime != 0) { EditorGUIUtility.labelWidth = 70.0f; currDialogue.time.reOpenTime = EditorGUILayout.FloatField("Re-open", currDialogue.time.reOpenTime, GUILayout.Width(105)); EditorGUIUtility.labelWidth = 0; } if (currDialogue.character.name == CharacterData.Info.Character.NONE) { currDialogue.time.moveInTime = 0; currDialogue.time.moveOutTime = 0; } GUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ if (mIsControlList[i]) { // ------------------------------NEW HORIZONTAL------------------------------ DisplaySeparator(); if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } GUILayout.Label(""); EditorGUILayout.LabelField("Dialogue", GUILayout.Width(60.0f)); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.Width(20))) { mSelf.addTextBox(i, currCharName); } if (currDialogue.sentenceList.Count == 1) { GUI.enabled = false; } if (GUILayout.Button("-", GUILayout.Width(20))) { mSelf.deleteTextBox(i); } GUI.enabled = true; if (GUILayout.Button("+D", GUILayout.Width(30))) { AddDialogue(i); } else if (GUILayout.Button("-D", GUILayout.Width(30))) { DeleteDialogue(i); return; } if (GUILayout.Button("+A", GUILayout.Width(30))) { AddAnswer(i); } else if (GUILayout.Button("-A", GUILayout.Width(30))) { DeleteAnswer(i); return; } // if (GUILayout.Button("+R", GUILayout.Width(30))) AddResponse(i); // else if (GUILayout.Button("-R", GUILayout.Width(30))) { DeleteResponse(i); return; } GUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ // ------------------------------NEW HORIZONTAL------------------------------ if (mIsControlList[i]) { EditorGUILayout.BeginHorizontal(mDifferentColorBgStyle); } else { EditorGUILayout.BeginHorizontal(); } GUILayout.Label(""); EditorGUILayout.LabelField("Others", GUILayout.Width(60.0f)); GUILayout.FlexibleSpace(); // Appear button. if (currDialogue.character.name == CharacterData.Info.Character.NONE) { GUI.enabled = false; } if (GUILayout.Button("App", GUILayout.Width(42))) { if (!mIsAppearList[i]) { mIsAppearList[i] = true; if (currDialogue.time.moveInTime == 0 && DialogueSlide.sSingleton.moveTime != 0) { currDialogue.time.moveInTime = DialogueSlide.sSingleton.moveTime; } } else { currDialogue.time.moveInTime = 0.0f; mIsAppearList[i] = false; } SetMessedUpMessage(); } GUI.enabled = true; // Disappear button. if (currDialogue.character.name == CharacterData.Info.Character.NONE) { GUI.enabled = false; } if (GUILayout.Button("Dis", GUILayout.Width(42))) { if (!mIsDisappearList[i]) { mIsDisappearList[i] = true; if (currDialogue.time.moveOutTime == 0 && DialogueSlide.sSingleton.moveTime != 0) { currDialogue.time.moveOutTime = DialogueSlide.sSingleton.moveTime; } } else { currDialogue.time.moveOutTime = 0.0f; mIsDisappearList[i] = false; } SetMessedUpMessage(); } GUI.enabled = true; // Delay button. if (GUILayout.Button("Dly", GUILayout.Width(42))) { if (!mIsAddDelayList[i]) { mIsAddDelayList[i] = true; } else { currDialogue.time.delayTime = 0.0f; mIsAddDelayList[i] = false; } } // Re-open button. if (GUILayout.Button("Re", GUILayout.Width(42))) { if (!mIsReOpenList[i]) { mIsReOpenList[i] = true; } else { currDialogue.time.reOpenTime = 0.0f; mIsReOpenList[i] = false; } } GUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); EditorGUILayout.Space(); } // ------------------------------NEW HORIZONTAL------------------------------ EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUIUtility.labelWidth = 70.0f; mIsAudio = EditorGUILayout.Toggle("Has audio", mIsAudio, GUILayout.Width(90.0f)); EditorGUIUtility.labelWidth = 80.0f; mSelf.isBothAppear = EditorGUILayout.Toggle("Both appear", mSelf.isBothAppear); EditorGUIUtility.labelWidth = 0.0f; EditorGUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ // ------------------------------NEW HORIZONTAL------------------------------ EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("+Dialogue", GUILayout.Width(80))) { AddDialogue(); } else if (GUILayout.Button("-Dialogue", GUILayout.Width(80))) { DeleteDialogue(); } else if (GUILayout.Button("Reset", GUILayout.Width(60))) { ResetInspector(); } EditorGUILayout.EndHorizontal(); // ------------------------------END HORIZONTAL------------------------------ if (GUI.changed) { dialogueInfo = mSelf.GetDialogueInfo(); EditorUtility.SetDirty(target); } }