예제 #1
0
        public LongRunningAction Say(int id, string line, string customSound, string customAnimation)
        {
            SpeechLine speechLine = new SpeechLine()
            {
                Text = line
            };
            NpcInstance npc = this.LevelManager.NonPlayerCharacters[id];

            if (!string.IsNullOrEmpty(customSound))
            {
                if (speechLine.OverrideContent == null)
                {
                    speechLine.OverrideContent = new NpcActionContent();
                }
                speechLine.OverrideContent.Sound = this.LoadSound(customSound);
            }
            if (!string.IsNullOrEmpty(customAnimation))
            {
                if (speechLine.OverrideContent == null)
                {
                    speechLine.OverrideContent = new NpcActionContent();
                }
                speechLine.OverrideContent.Animation = this.LoadAnimation(npc, customAnimation);
            }
            npc.CustomSpeechLine = speechLine;
            return(new LongRunningAction((Func <float, float, bool>)((_, __) => npc.CustomSpeechLine == null)));
        }
예제 #2
0
    private void Display(SpeechLine line)
    {
        float duration = ((float)line.Text.Length) / ((float)this.LettersPerSecond);

        this.TextArea.Display(line.Text, duration, line.CompleteDisplayDuration);
        this.TV.ChangeMood(line.Mood);
        this.TV.SpeakFor(duration + (line.CompleteDisplayDuration / 2));
    }
예제 #3
0
 public void SetSpeechLine(SpeechLine speechLine)
 {
     speechImage.enabled = true;
     speechText.enabled = true;
     portraitImage.sprite = characterSprites[(int)speechLine.emotion];
     speechImage.sprite = speechSprites[(int)speechLine.speech];
     speechText.text = speechLine.text;
 }
예제 #4
0
    private void ExtractLine(ActionSpeech action, bool onlySeekNew, bool isInScene)
    {
        string speaker = "";

        if (action.isPlayer)
        {
            speaker = "Player";
        }
        else if (action.speaker)
        {
            speaker = action.speaker.name;
        }

        if (speaker != "" && action.messageText != "")
        {
            if (onlySeekNew && action.lineID == -1)
            {
                // Assign a new ID on creation
                SpeechLine newLine;
                if (isInScene)
                {
                    newLine = new SpeechLine(GetIDArray(), EditorApplication.currentScene, speaker, action.messageText, languages.Count - 1);
                }
                else
                {
                    newLine = new SpeechLine(GetIDArray(), "", speaker, action.messageText, languages.Count - 1);
                }
                action.lineID = newLine.lineID;
                lines.Add(newLine);
            }

            else if (!onlySeekNew && action.lineID > -1)
            {
                // Already has an ID, so don't replace
                if (isInScene)
                {
                    lines.Add(new SpeechLine(action.lineID, EditorApplication.currentScene, speaker, action.messageText, languages.Count - 1));
                }
                else
                {
                    lines.Add(new SpeechLine(action.lineID, "", speaker, action.messageText, languages.Count - 1));
                }
            }
        }
        else
        {
            // Remove from SpeechManager
            action.lineID = -1;
        }
    }
예제 #5
0
    static void ShowLine(SpeechLine line)
    {
        inLine   = true;
        currLine = line;
        // hide other ui boxes
        foreach (GameObject obj in uiElements.Values)
        {
            obj.SetActive(false);
        }

        GameObject  currDialogueUI = uiElements[line.speakerName];
        DialogueBox dialogueBox    = currDialogueUI.GetComponent <DialogueBox>();

        //dialogueBox.currLine = line.lineText;

        // show this ui box
        currDialogueUI.SetActive(true);

        // apply effects...
        float typingSpeed = 0.03f; // default speed

        switch (line.lineEffect)
        {
        case LineEffect.SHAKE:
            dialogueBox.gameObject.GetComponent <Animator>().SetTrigger("shake");
            //dialogueBox.StartCoroutine(ShakeUIItem(dialogueBox));
            break;

        case LineEffect.SLOW:
            typingSpeed = 0.3f;
            break;

        case LineEffect.FAST:
            typingSpeed = 0.0001f;
            break;

        default: break;
        }

        //Debug.Log("Type Speed: " + typingSpeed);

        // "type out" the dialogue
        dialogueBox.StartCoroutine(TypeDialogue(dialogueBox, line.lineText, typingSpeed));
    }
        /// <summary>
        /// Rejects speech lines when the current filter does not apply
        /// </summary>
        /// <param name="line">Line to filter</param>
        /// <returns>True when the line should be considered</returns>
        bool DoShow(SpeechLine line)
        {
            if (string.IsNullOrEmpty(currentTextFilter))
            {
                return(true);
            }

            var speechAction = (line.ContainedList.actions[line.ActionIndex] as ActionSpeech);

            if (speechAction.messageText.Contains(currentTextFilter))
            {
                return(true);
            }

            if (speechAction.speaker != null && speechAction.speaker.speechLabel.Contains(currentTextFilter))
            {
                return(true);
            }

            return(false);
        }
    private void TinkerbellDialogue()
    {
        var rows     = tinkerbellText.text.Split(new char[] { '\n' });
        var firstRow = rows[0].Split(new char[] { ',' });

        string[] keywords = new string[] { "Fork", "BG", "Show", "Text", "Aff", "Health", "Execute" };

        for (int i = 1; i < rows.Length; i++) //Ignore first & last line
        {
            print("Line " + tinkerbellDialogues.Count);
            var columns = rows[i].Split(new char[] { ',' }); //No, Speaker, Dialogue
            if (Useful.IsEmpty(columns))
            {
                continue;                                        //If all columns in single line is empty, continue
            }
            var speeches = columns[2].Split(new char[] { '+' }); //Array of SpeechLines.Speech

            if (!string.IsNullOrEmpty(columns[0]))               //If column isn't empty, new Dialogue
            {
                var speechLines = new Queue <SpeechLine>();
                speechLines.Enqueue(new SpeechLine
                {
                    Speaker = SoldierManager.moreSoldierDict[columns[1]],
                    Speech  = columns[2],
                });
                tinkerbellDialogues.Add(new Dialogue {
                    speechLines = speechLines,
                });
            }
            else
            {
                var speechLine = new SpeechLine
                {
                    Speaker = SoldierManager.moreSoldierDict[columns[1]],
                    Speech  = columns[2],
                };
                tinkerbellDialogues[tinkerbellDialogues.Count - 1].speechLines.Enqueue(speechLine);
            }
        }
    }
예제 #8
0
    void ProcessLines()
    {
        List <SpeechLine> currentLines = new List <SpeechLine>();
        string            speaker      = "";

        foreach (string line in rawTextArray)
        {
            if (string.IsNullOrEmpty(line))
            {
                continue;
            }                                             // skip line if it's empty

            string processedLine = line;
            if (line.IndexOf("//") > -1)
            {
                processedLine = line.Substring(0, line.IndexOf("//"));
            }                                                                                       // remove comments

            bool isSpeakingLine = true;

            if (processedLine.IndexOf(':') > -1) // determine speaker OR effect
            {
                string preText = processedLine.Substring(0, processedLine.IndexOf(':'));
                processedLine = processedLine.Remove(0, processedLine.IndexOf(':') + 1); // remove pretext from the line
                preText       = preText.Replace(":", string.Empty);

                // process preText
                if (!string.IsNullOrEmpty(preText))
                {
                    // if this line has pretext, save and clear the previous line(s)
                    if (currentLines.Count > 0)
                    {
                        lines.Add(currentLines);
                    }                                       // add prev if it had anything
                    currentLines = new List <SpeechLine>(); // clear and make a new instance

                    switch (preText)                        // check if pretext is a tag
                    {
                    case "EFFECTS":                         // if this is an interaction effect, add it to the list
                        string[] effectTags = processedLine.Split(' ');
                        foreach (string str in effectTags)
                        {
                            interactionEffects.Add(str);
                        }
                        isSpeakingLine = false;
                        break;

                    // add more cases as needed

                    default:     // default: if it's not an effect, then this is a name
                        speaker        = preText;
                        isSpeakingLine = true;
                        break;
                    }
                }
            }

            if (!isSpeakingLine || string.IsNullOrEmpty(processedLine))
            {
                continue;
            }
            else //continue processing if this is a speaker line
            {
                int        optionNum    = -1; // defaults to -1 if no branching
                string     lineText     = "";
                string     synopsisText = "";
                LineEffect lineEffect   = (LineEffect)0;
                bool       isBranching  = false;

                // check if this is a branching line
                if (processedLine.Contains("~"))
                {
                    isBranching = true;
                    string[] branches = processedLine.Split('~');
                    foreach (string option in branches)
                    {
                        if (!string.IsNullOrEmpty(option))
                        {
                            // get option number (and remove it from the rest of the string)
                            optionNum = Int32.Parse(option.Substring(0, option.IndexOf(" ")));
                            lineText  = option.Remove(0, option.IndexOf(" ")); // remove the number in the beginning

                            // process the synopsis text (and remove it)
                            if (lineText.IndexOf('%') != -1)
                            {
                                synopsisText = lineText.Substring(lineText.IndexOf('%') + 1, lineText.LastIndexOf('%') - lineText.IndexOf('%') - 1);
                                lineText     = lineText.Remove(lineText.IndexOf('%'), lineText.LastIndexOf('%') - lineText.IndexOf('%') + 1);
                            }

                            // process lines
                            processedLine = ProcessSpeech(lineText, ref lineEffect);
                        }
                    }
                }
                else //non-branching: process normally
                {
                    // process lines
                    processedLine = ProcessSpeech(processedLine, ref lineEffect);
                }

                // after processing is complete, make a SpeechLine & add it
                SpeechLine lineToAdd = new SpeechLine()
                {
                    speakerName  = speaker,
                    synopsisText = synopsisText,
                    lineText     = processedLine,
                    lineEffect   = lineEffect,
                    isBranch     = isBranching,
                    optionNum    = optionNum
                };

                currentLines.Add(lineToAdd);
            }
        }

        // add the last line
        if (currentLines.Count > 0)
        {
            lines.Add(currentLines);
        }
    }
예제 #9
0
        private void Talk()
        {
            if (this.Npc.CustomSpeechLine != null)
            {
                this.CurrentLine = this.Npc.CustomSpeechLine;
            }
            else
            {
                SpeechLine speechLine = this.CurrentLine;
                if (this.Npc.Speech.Count <= 1 || this.Npc.SayFirstSpeechLineOnce && !this.SaidFirstLine)
                {
                    this.CurrentLine = Enumerable.FirstOrDefault <SpeechLine>((IEnumerable <SpeechLine>) this.Npc.Speech);
                }
                else
                {
                    do
                    {
                        if (this.Npc.RandomizeSpeech)
                        {
                            this.CurrentLine = RandomHelper.InList <SpeechLine>(this.Npc.Speech);
                        }
                        else
                        {
                            this.CurrentLine = this.Npc.Speech[this.SequentialLineIndex];
                            ++this.SequentialLineIndex;
                            if (this.SequentialLineIndex == this.Npc.Speech.Count)
                            {
                                this.SequentialLineIndex = 0;
                            }
                        }
                    }while (speechLine == this.CurrentLine || this.Npc.SayFirstSpeechLineOnce && this.SaidFirstLine && this.CurrentLine == this.Npc.Speech[0]);
                }
                this.SaidFirstLine = true;
            }
            IPlayerManager playerManager1 = this.PlayerManager;
            Vector3        vector3_1      = playerManager1.Velocity * Vector3.UnitY;

            playerManager1.Velocity   = vector3_1;
            this.PlayerManager.Action = ActionType.ReadingSign;
            Vector3 a = this.PlayerManager.Position - this.Position;

            this.SpeechManager.Origin = this.Position + Vector3.UnitY * 0.5f;
            string s;

            if (this.LevelManager.SongName == "Majesty")
            {
                this.SpeechManager.Font = SpeechFont.Zuish;
                string stringRaw = GameText.GetStringRaw(this.CurrentLine.Text);
                this.SpeechManager.Origin       = this.Position + Vector3.UnitY * 0.5f + FezMath.RightVector(this.CameraManager.Viewpoint);
                this.SpeechManager.ChangeText(s = stringRaw);
            }
            else
            {
                this.SpeechManager.ChangeText(s = GameText.GetString(this.CurrentLine.Text));
            }
            this.LookingDirection = FezMath.DirectionFromMovement(FezMath.Dot(a * FezMath.Sign(this.Npc.DestinationOffset), FezMath.SideMask(this.CameraManager.Viewpoint)));
            this.PlayerManager.LookingDirection = FezMath.DirectionFromMovement(-FezMath.Dot(a, FezMath.RightVector(this.CameraManager.Viewpoint)));
            float num = FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint));

            if ((double)Math.Abs(num) < 1.0)
            {
                Vector3 center   = this.PlayerManager.Center;
                Vector3 velocity = this.PlayerManager.Velocity;
                MultipleHits <TrileInstance> ground = this.PlayerManager.Ground;
                IPlayerManager playerManager2       = this.PlayerManager;
                Vector3        vector3_2            = playerManager2.Center + (float)Math.Sign(num) * (1.25f - Math.Abs(num)) * FezMath.SideMask(this.CameraManager.Viewpoint);
                playerManager2.Center = vector3_2;
                this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                this.PlayerManager.Velocity = velocity;
                if (!this.PlayerManager.Grounded)
                {
                    this.PlayerManager.Center = center;
                    this.PlayerManager.Ground = ground;
                }
                else
                {
                    this.PlayerManager.Center = center + (float)Math.Sign(num) * (1f - Math.Abs(num)) * FezMath.SideMask(this.CameraManager.Viewpoint);
                }
            }
            this.CurrentAction = NpcAction.Talk;
            this.Npc.Talking   = true;
            if (this.Npc.ActorType == ActorType.LightningGhost)
            {
                this.Group.Material.Opacity = 0.0f;
            }
            this.talkWaiter = Waiters.Wait(0.100000001490116 + 0.0750000029802322 * (double)Util.StripPunctuation(s).Length *(Culture.IsCJK ? 2.0 : 1.0), (Action)(() =>
            {
                if (this.talkEmitter == null)
                {
                    return;
                }
                this.talkEmitter.FadeOutAndPause(0.1f);
            }));
            this.talkWaiter.AutoPause = true;
            this.UpdateAction();
        }
예제 #10
0
 public static SpeechLines Interrupt(SpeechLine line)
 {
     SpeechLine[] lines = { line };
     return(new SpeechLines(lines, true));
 }
예제 #11
0
 public static SpeechLines Simple(SpeechLine line)
 {
     SpeechLine[] lines = { line };
     return(new SpeechLines(lines));
 }