示例#1
0
文件: Silky.cs 项目: nullsquid/Silk
        void AssignDataToNodes(SilkStory newSilkStory, SilkNode newNode, string newTweeData, string newPassage, string storyTitle)
        {
            //TODO figure out where this g----Title is started
            newNode.nodeName = storyTitle + "_" + ReturnTitle(newTweeData).TrimEnd(' ');
            //only to remove it when required in GetNodeName
            newNode.StoryName = storyTitle;
            //add custom tag names
            newNode.tags = ReturnCustomTags(newTweeData);

            //add custom tags
            foreach (KeyValuePair <string, string[]> tagName in newNode.tags)
            {
                string newTagName = "";
                //Right now, you can't use underscores in your custom tag names
                if (tagName.Key.Contains("_"))
                {
                    newTagName = tagName.Key.Remove(tagName.Key.IndexOf('_')).TrimStart().TrimEnd();
                }
                if (tagFactory.SetTag(newTagName, tagName.Value) != null)
                {
                    newNode.silkTags.Add(tagFactory.SetTag(newTagName, tagName.Value));
                }
                else
                {
                    Debug.LogError(newTagName + " is not a recognized tag. Check your TagFactory");
                }
            }
            //Debug.Log(newNode.silkTags[0].TagName);

            //add passage
            newNode.nodePassage = newPassage;
            //TODO Add the correct amount of links to the list
            //add link names
            newNode.links = ReturnLinks(newTweeData);

            newSilkStory.AddToStory(newNode.nodeName, newNode);
        }
示例#2
0
        SilkTagBase ParseRawTag(string inputRawTag, TagFactory tFactory)
        {
            RawTag newRawTag = new RawTag();

            string[] rawArguments;
            //string inputRawTag = rawTag.Replace(" ", String.Empty);
            for (int i = 0; i < inputRawTag.Length; i++)
            {
                if (i == 2)
                {
                    //inputRawTag.Replace(" ", "");

                    for (int j = i; j < inputRawTag.Length; j++)
                    {
                        //Debug.Log(inputRawTag[j]);
                        if (!inputRawTag.Contains("="))
                        {
                            if (inputRawTag[j] != '>')
                            {
                                newRawTag.RawTagName += inputRawTag[j];
                            }
                            else
                            {
                                break;
                            }
                        }
                        else if (inputRawTag[j] == '=')
                        {
                            rawArguments = inputRawTag.Substring(j + 1).Split(',');
                            for (int r = 0; r < rawArguments.Length; r++)
                            {
                                string rawArgument = rawArguments[r].Replace("\"", "").Replace(">>", String.Empty);
                                newRawTag.AddArgument(rawArgument);
                            }

                            break;
                        }
                        else
                        {
                            newRawTag.RawTagName += inputRawTag[j];
                        }
                    }
                }
            }
            return(tFactory.SetTag(newRawTag.RawTagName, newRawTag.TagArgs));


            //return newRawTag;
        }