Beispiel #1
0
    void EnterSenseMode()
    {
        if (sense_ == null || sense_.Length <= senseIdx_ || sense_.Length == 0)
        {
            return;
        }

        if (sense_[senseIdx_].gameObject == null)
        {
            return;
        }

        SenseBase sb = sense_[senseIdx_].gameObject.GetComponent <SenseBase>();

        if (sb == null)
        {
            return;
        }

        sb.SetUpActor();

        //隐藏所有角色
        Prebattle.Instance.HideAllPeople();

        //隐藏除剧情外所有UI
        HideAllActiveUI();

        sense_[senseIdx_].SetTrigger("Play");
    }
        private void ParseSpecificSenseProperties(Response.SenseBase sourceSense, SenseBase targetSense)
        {
            sourceSense.ParseDefiningText(targetSense, _language, _parseOptions.AudioFormat);

            // sdsense
            if (sourceSense is Response.Sense s && s.DividedSense != null)
            {
                var dSense = ParseGeneralSenseProperties <DividedSense>(s.DividedSense);
                ParseSpecificSenseProperties(s.DividedSense, dSense);
                dSense.SenseDivider = s.DividedSense.SenseDivider;

                ((Sense)targetSense).DividedSense = dSense;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Parses the defining text contents from the source sense and stores it on the target sense.
        /// </summary>
        public static void ParseDefiningText(this Response.SenseBase sourceSense, SenseBase targetSense, Language language, AudioFormat audioFormat)
        {
            foreach (var definingTextObjects in sourceSense.DefiningTexts)
            {
                if (definingTextObjects.Length != 2)
                {
                    continue;
                }

                var definitionType = definingTextObjects[0].TypeOrText;

                if (definitionType == DefiningTextTypes.Text)
                {
                    string definitionText = definingTextObjects[1].TypeOrText;

                    if (targetSense is Sense sense)
                    {
                        sense.Synonyms = SynonymsParser.ExtractSynonyms(definitionText).ToList();

                        var definingText = new DefiningText(definitionText);
                        targetSense.DefiningTexts.Add(definingText);
                        if (sense.Synonyms.Any())
                        {
                            // not very robust, but until now I only found sx links at the beginning of a string in the spanish-english dictionary
                            // in that case the synonyms should be removed from the text, in other cases we keep them between square brackets
                            if (definingText.Text.RawText.StartsWith("{sx"))
                            {
                                foreach (var synonym in sense.Synonyms)
                                {
                                    definitionText = definitionText.Replace(synonym, "");
                                }
                            }
                            else
                            {
                                foreach (var synonym in sense.Synonyms)
                                {
                                    definitionText = definitionText.Replace(synonym, $"[{synonym}]");
                                }
                            }
                        }
                    }
                    else
                    {
                        targetSense.DefiningTexts.Add(new DefiningText(definitionText));
                    }
                }

                else if (definitionType == DefiningTextTypes.VerbalIllustration)
                {
                    foreach (var dto in definingTextObjects[1].DefiningTextObjects)
                    {
                        if (dto.DefiningText != null)
                        {
                            var vis = VisHelper.Parse(dto.DefiningText);
                            targetSense.DefiningTexts.Add(vis);
                        }
                    }
                }

                else if (definitionType == DefiningTextTypes.GenderLabel)
                {
                    targetSense.DefiningTexts.Add(new GenderLabel(definingTextObjects[1].TypeOrText));
                }

                if (definitionType == DefiningTextTypes.BiographicalNameWrap)
                {
                    var dt = definingTextObjects[1].DefiningText;

                    var biographicalNameWrap = new BiographicalNameWrap
                    {
                        AlternateName = dt.Altname,
                        FirstName     = dt.Pname,
                        Surname       = dt.Surname
                    };

                    if (dt.Pronunciations.Any())
                    {
                        biographicalNameWrap.Pronunciations = new List <Pronunciation>();
                        foreach (var pronunciation in dt.Pronunciations)
                        {
                            biographicalNameWrap.Pronunciations.Add(PronunciationHelper.Parse(pronunciation, language, audioFormat));
                        }
                    }

                    targetSense.DefiningTexts.Add(biographicalNameWrap);
                }

                else if (definitionType == DefiningTextTypes.CalledAlsoNote)
                {
                    var ca             = definingTextObjects[1].DefiningText;
                    var calledAlsoNote = new CalledAlsoNote
                    {
                        Intro = ca.Intro
                    };

                    foreach (var cat in ca.Cats)
                    {
                        var calledAlsoTarget = new CalledAlsoTarget
                        {
                            ParenthesizedNumber             = cat.ParenthesizedNumber,
                            Reference                       = cat.Reference,
                            TargetText                      = cat.Text,
                            ParenthesizedSubjectStatusLabel = cat.ParenthesizedSubjectStatusLabel
                        };

                        if (cat.Pronunciations.Any())
                        {
                            calledAlsoTarget.Pronunciations = new List <Pronunciation>();
                            foreach (var pronunciation in cat.Pronunciations)
                            {
                                calledAlsoTarget.Pronunciations.Add(PronunciationHelper.Parse(pronunciation, language, audioFormat));
                            }
                        }

                        calledAlsoNote.Targets.Add(calledAlsoTarget);
                    }

                    targetSense.DefiningTexts.Add(calledAlsoNote);
                }

                else if (definitionType == DefiningTextTypes.RunIn)
                {
                    var arr = definingTextObjects[1].DefiningTextObjects;
                    foreach (var definingTextObject in arr)
                    {
                        var typeOrLabel = definingTextObject.DefiningTextComplexTypeWrappers[0].TypeLabelOrText;
                        if (typeOrLabel == "riw")
                        {
                            var ri = definingTextObject.DefiningTextComplexTypeWrappers[1].RunInWrap;
                            if (ri != null)
                            {
                                var runInWord = new RunInWord
                                {
                                    Text       = ri.Text,
                                    RunInEntry = ri.RunInEntry
                                };

                                if (ri.Vrs.Any())
                                {
                                    runInWord.Variants = VariantHelper.Parse(ri.Vrs, language, audioFormat).ToList();
                                }

                                if (ri.Pronunciations.Any())
                                {
                                    runInWord.Pronunciations = new List <Pronunciation>();
                                    foreach (var pronunciation in ri.Pronunciations)
                                    {
                                        runInWord.Pronunciations.Add(PronunciationHelper.Parse(pronunciation, language, audioFormat));
                                    }
                                }

                                targetSense.DefiningTexts.Add(runInWord);
                            }
                        }

                        if (typeOrLabel == DefiningTextTypes.Text)
                        {
                            targetSense.DefiningTexts.Add(new DefiningText(definingTextObject.DefiningTextComplexTypeWrappers[1].TypeLabelOrText));
                        }
                    }
                }

                else if (definitionType == DefiningTextTypes.SupplementalNote)
                {
                    var arr = definingTextObjects[1].DefiningTextObjects[0].DefiningTextComplexTypeWrappers;
                    var supplementalInformationNote = new SupplementalInformationNote
                    {
                        Text = arr[1].TypeLabelOrText
                    };

                    targetSense.DefiningTexts.Add(supplementalInformationNote);

                    // todo nested ri, vis, requires sample json
                }

                else if (definitionType == DefiningTextTypes.UsageNote)
                {
                    var arr = definingTextObjects[1].DefiningTextObjects[0].DefiningTextComplexTypeWrappers;
                    if (arr == null)
                    {
                        continue;
                    }

                    var un = new UsageNote();

                    foreach (var dtWrapper in arr.Where(x => x.DefiningTextComplexTypes?.Any() == true))
                    {
                        var unType = dtWrapper.DefiningTextComplexTypes[0].TypeOrLabel;
                        if (unType == DefiningTextTypes.Text)
                        {
                            un.Text = dtWrapper.DefiningTextComplexTypes[1].TypeOrLabel;
                        }
                        else if (unType == DefiningTextTypes.VerbalIllustration)
                        {
                            if (un.VerbalIllustrations == null)
                            {
                                un.VerbalIllustrations = new List <VerbalIllustration>();
                            }

                            foreach (var definingText in dtWrapper.DefiningTextComplexTypes[1].DefiningTexts)
                            {
                                var vis = VisHelper.Parse(definingText);
                                un.VerbalIllustrations.Add(vis);
                            }
                        }

                        // todo "ri", requires sample json
                    }

                    targetSense.DefiningTexts.Add(un);
                }
                else if (definitionType == DefiningTextTypes.GenderForms)
                {
                    var dt = definingTextObjects[1].DefiningText;
                    targetSense.DefiningTexts.Add(new GenderForms
                    {
                        GenderWordCutback    = dt.GenderWordCutback,
                        GenderWordSpelledOut = dt.GenderWordSpelledOut
                    });
                }
            }
        }