コード例 #1
0
 private AudioEffectProductUnit SpawnAudioUnit()
 {
     return((AudioEffectProductUnit)audioFactoryUnit.Spawn());
 }
コード例 #2
0
        private IEnumerator LoadSubsRoutine(int dayIndex, System.Action callback)
        {
            var subsTextAssets = Resources.LoadAll <TextAsset>("Subs/" + dayIndex.ToString());

            for (int i = 0; i < subsTextAssets.Length; i++)
            {
                yield return(new WaitForEndOfFrame());

                var channelIndex  = i + 1;
                var subsTextAsset = subsTextAssets[i];

                var channelName = "Channel " + channelIndex;

                var subsString = subsTextAsset.ToString();
                subsString = Regex.Replace(subsString, "(\r\n|\r|\n)", " ", RegexOptions.Multiline);
                var words = subsString.Split(' ');

                var isTargetMode        = false;
                var dialogOwnerIndex    = 0;
                var currentWord         = "";
                var currentIsTargetMode = false;
                var currentWordList     = new List <SubsWordUnit>();
                var isEmpty             = false;
                var isEnd = false;

                foreach (var word in words)
                {
                    currentWord         = word;
                    currentIsTargetMode = word.Contains("*");

                    var numberOfStars = 0;

                    if (currentIsTargetMode)
                    {
                        if (word.Contains("***"))
                        {
                            numberOfStars = 3;
                        }
                        else if (word.Contains("**"))
                        {
                            numberOfStars = 2;
                        }
                        else if (word.Contains("*"))
                        {
                            numberOfStars = 1;
                        }
                    }

                    var mistakeScore = 0;
                    var scoreScore   = 0;

                    if (numberOfStars == 3)
                    {
                        mistakeScore = 8;
                        scoreScore   = 12;
                    }

                    if (numberOfStars == 2)
                    {
                        mistakeScore = 5;
                        scoreScore   = 8;
                    }

                    if (numberOfStars == 1)
                    {
                        mistakeScore = 2;
                        scoreScore   = 3;
                    }

                    currentWord = Regex.Replace(currentWord, @"\*", "");

                    if (currentWord == "." || string.IsNullOrEmpty(currentWord.Trim()) || currentWord == " ")
                    {
                        isEmpty = true;
                    }
                    else
                    {
                        isEmpty = false;
                    }

                    if (isTargetMode)
                    {
                        currentIsTargetMode = true;
                    }

                    isEnd = word == "END";

                    if (isEnd)
                    {
                        currentWord = "              ";
                    }

                    if (word.Contains("---"))
                    {
                        currentWord = Regex.Replace(word, "---", "");
                        if (currentWord.Length == 0)
                        {
                            continue;
                        }
                        var indexString = currentWord.Substring(0, 1);
                        currentWord = currentWord.Substring(1, currentWord.Length - 1);
                        int.TryParse(indexString, out dialogOwnerIndex);
                        if (dialogOwnerIndex < 0)
                        {
                            dialogOwnerIndex = 0;
                        }
                        else if (dialogOwnerIndex > 10)
                        {
                            dialogOwnerIndex = 10;
                        }
                    }

                    // currentWord = currentWord;

                    var productUnit = (SubsWordProductUnit)__subsWordFactoryUnit.Spawn();
                    var wordUnit    = productUnit.subsWordUnit;
                    wordUnit.isTarget         = currentIsTargetMode && !isEmpty;
                    wordUnit.isEmpty          = isEmpty;
                    wordUnit.isMale           = IsMale(dialogOwnerIndex);
                    wordUnit.channelIndex     = channelIndex;
                    wordUnit.dialogOwnerIndex = dayIndex * 10000 + i * 100 + dialogOwnerIndex;
                    wordUnit.SetColor(dialogOwnerColors[dialogOwnerIndex]);
                    wordUnit.SetText(currentWord);
                    wordUnit.transform.SetParent(channelRectTransforms[channelIndex - 1], false);
                    wordUnit.isMarked     = false;
                    wordUnit.isMarkedDev  = false;
                    wordUnit.isSpoken     = false;
                    wordUnit.isScored     = false;
                    wordUnit.isEnd        = isEnd;
                    wordUnit.mistakeScore = mistakeScore;
                    wordUnit.scoreScore   = scoreScore;
                    __wordUnitsLookup.Add(wordUnit);
                    currentWordList.Add(wordUnit);

                    var entity = Contexts.state.CreateViewEntity();
                    entity.productUnit = productUnit;
                    entity.levelPart   = true;
                }

                var phoneChannelProductUnit = Contexts.state.phoneManagerUnit.Spawn();
                var phoneChannelUnit        = phoneChannelProductUnit.GetComponent <PhoneChannelUnit>();
                phoneChannelUnit.Initialize();
                phoneChannelUnit.SetActive(false);

                var channelEntity = Contexts.state.CreateViewEntity();
                channelEntity.levelPart        = true;
                channelEntity.productUnit      = phoneChannelProductUnit;
                channelEntity.channel          = channelIndex;
                channelEntity.phoneChannelUnit = phoneChannelUnit;
            }

            if (callback != null)
            {
                callback();
            }
        }
コード例 #3
0
 public FS.PrefabFactory.Scripts.ProductUnit Spawn()
 {
     return(__factoryUnit.Spawn());
 }