public static void Initialize(NovelMateContext context) { context.Database.EnsureCreated(); if (context.StoryNodes.Any()) { return; // Database has already been seeded } Guid newGuid = Guid.NewGuid(); // Add dummy story nodes var storyNodes = new StoryNode[] { new StoryNode { UserId = newGuid, Name = "Chapter 1", Content = "Some RTF content 1 ", CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now }, new StoryNode { UserId = newGuid, Name = "Chapter 2", Content = "Some RTF content 2", CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now }, new StoryNode { UserId = newGuid, Name = "Chapter 3", Content = "Some RTF content 3", CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now }, new StoryNode { UserId = newGuid, Name = "Chapter 4", Content = "Some RTF content 4", CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now }, new StoryNode { UserId = newGuid, Name = "Chapter 5", Content = "Some RTF content 5", CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now } }; foreach (StoryNode n in storyNodes) { context.StoryNodes.Add(n); } context.SaveChanges(); }
private void OnNodeAddedToStory(NodeAddedToStory evt) { StoryNode introductoryTextNode; if (!ReferenceEquals(rootNode, null)) { introductoryTextNode = rootNode.Find(evt.introductoryText); } else { rootNode = new StoryNode(evt.introductoryText); introductoryTextNode = rootNode; } for (int i = 0; i < evt.playerResponses.Length; i++) { string allowedPlayerResponse = evt.playerResponses [i]; string characterResponse = evt.characterResponses [i]; string[] eventsToPublishOnReaching = null; StoryNode node = rootNode.Find(characterResponse); if (node == null) { node = new StoryNode(characterResponse); } //add child should then accept the entry pattern as one argument and the node as the other. introductoryTextNode.AddChild(allowedPlayerResponse, node); } //events are always in reference to the text for each node, not to the responses. //(why there is only ever one of them) //consequently, to set an event to be published in response to something a character says, //need to specify it in the line of the story csv where that response is the introudctry text. introductoryTextNode.eventsToPublishOnReaching = evt.eventsToPublishOnReaching; }
public IActionResult PutStoryNode([FromRoute] Guid id, [FromBody] StoryNode storyNode) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != storyNode.Id) { return(BadRequest()); } _context.Entry(storyNode).State = EntityState.Modified; try { _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoryNodeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void TriggerStoryNodeChanged(StoryNode newnode) { if (OnStoryNodeChanged != null) { OnStoryNodeChanged(this, new StoryChangedEventArgs(newnode)); } }
StoryNode ParseNode(XmlNode node) { StoryNode storyNode = new StoryNode(); foreach (XmlNode child in node.ChildNodes) { switch (child.Name) { case "title": storyNode.Title = child.InnerText; break; case "pages": foreach (XmlNode page in child.ChildNodes) { storyNode.Body.Add(page.InnerText); } break; case "choices": foreach (XmlNode choice in child.ChildNodes) { storyNode.Choices.Add(ParseChoice(choice)); } break; } } return(storyNode); }
private void DeviceAuthentication(StoryNode cut) { var ti = DependencyService.Get <IAuthService>(); // get device authentication service if (ti == null) { cut.MessageBuffer.WriteLine($"No device authentication capability"); cut.MessageBuffer.WriteLine($"(E902)"); cut.TaskResult = false; return; } var task = ti.GetAuthentication(); task.ContinueWith(delegate { if (task.Result) { Application.Current.Properties["LoginUtc"] = DateTime.UtcNow; cut.TaskResult = true; } else { cut.MessageBuffer.WriteLine($"Device Authentication exception"); cut.MessageBuffer.WriteLine($"(E901)"); cut.TaskResult = false; } }); }
/// <summary> /// Traverse to the next node in the graph, depending on the KeyCode that is passed in /// </summary> /// <param name="key">A KeyCode that determines which edge will be traversed</param> private void TraverseNext(KeyCode key) { int input = _keyToIndexMap[key]; StoryNode nextNode = ChooseNext(input); _graph.SetCurrent(nextNode); }
public void InitSleepingHobby() { StoryNode mother = new StoryNode("My mother was a nice cat. She was big and fluffy, " + "not at all like my father. I only saw my father for a moment just seconds after I was old " + "enough to open my eyes. Male cats don't stick around too long, you see. We're not generally very interested in raising kittens. " + "Anyway, my mother's name was Diamond.", container.UpdateImageAction(FOUR)); StoryNode dreams = new StoryNode("I suppose the most interesting dream I've ever had was one where I was a fish. " + "I was swimming in circles in an aquarium, around a little plastic treasure chest, just like the one in the aquarium over in the living room. " + "You should look at it sometime. It's very peaceful. In my dream the hand appeared and sprinkled some pellets into the aquarium. " + "I swam up to eat them, but when I drew close I saw that the pellets were actually eyeballs. Then I woke up.", () => { container.View.UpdateImage(catImages[FIVE]); }); hobbiesSleeping.AddInputBasedTransition("(mother|mom)".MatchSomewhere(), mother); hobbiesSleeping.AddInputBasedTransition("dream".MatchSomewhere(), dreams); hobbiesSleeping.AddHint(new StoryNode("It's no good... you've got me thinking about my mother... and dreams.", container.UpdateImageAction(TEN)) ); mother.AddInputBasedTransition("dream".MatchSomewhere(), hobbiesSleeping); dreams.AddInputBasedTransition("(mother|mom)".MatchSomewhere(), hobbiesSleeping); mother.GraftLoop(new StoryNode("Sorry. Bit spaced out. Thinking of my mom does that to me."), new StoryNode(string.Format("<--{0} is thinking about his mother.-->", catName))); dreams.GraftLoop(new StoryNode("Dreams are pretty strange. I wonder if other animals have them."), new StoryNode(string.Format("<--{0}'s just staring into space-->", catName))); }
StoryNode ParseStroyNode(JSONObject story_json) { StoryNode stroy_node = new StoryNode(); stroy_node.m_node_type = (int)story_json["type"].i; return(stroy_node); }
private void LoadPrivacy(StoryNode cut) { var task = AzureAD.GetPrivacyDataAsync(() => cut); task.ContinueWith(delegate { if (task.Result) { Setting.LastDisplayName = AzureAD.DisplayName; Setting.SaveFile(); Application.Current.MainPage.Title = AzureAD.DisplayName ?? ""; } else { var title = ""; if (string.IsNullOrEmpty(Setting.LastDisplayName) == false) { title = $"[OFFLINE?] {(Setting.LastDisplayName ?? "")}"; } else { title = $"[OFFLINE?]"; } Application.Current.MainPage.Title = title; } cut.TaskResult = task.Result; }); }
public StoryNode(GameEnums.AnimalCharcter theAnimal, GameEnums.StoryObjects objectInHand) { Next_giveto = null; Prex_OwedToMe = null; TheAnimal = theAnimal; ObjectInHand = objectInHand; }
public StoryNode() { Next_giveto = null; Prex_OwedToMe = null; TheAnimal = GameEnums.AnimalCharcter.Alligator; ObjectInHand = GameEnums.StoryObjects.Ball; }
private void BindData(TreeNode node, StoryNode data) { node.Text = data.Name; node.Tag = data; if (!ReverseNodeMapping.ContainsKey(data)) { ReverseNodeMapping.Add(data, node); } else { ReverseNodeMapping[data] = node; } if (data == Adventure.StartingPoint) { node.ForeColor = Color.Green; } else if (data is ReferenceNode) { node.ForeColor = Color.Blue; } else { node.ForeColor = Color.Black; } }
//BFS; find the shallowest node whose text matches that of the specified text. public StoryNode Find(string text) { if (Regex.Matches(this.text, text, RegexOptions.IgnoreCase).Count > 0) { return(this); } Queue <StoryNode> toVisit = new Queue <StoryNode> (); foreach (StoryNode child in GetChildren()) { toVisit.Enqueue(child); } while (toVisit.Count > 0) { StoryNode next = toVisit.Dequeue(); if (Regex.Matches(next.text, text, RegexOptions.IgnoreCase).Count > 0) { return(next); } foreach (StoryNode grandChild in next.GetChildren()) { toVisit.Enqueue(grandChild); } } return(null); }
public override List <String> doRule(SQLElement eaElement, SQLWrapperClasses.SQLRepository repository) { List <String> results = new List <string>(); if (Serialization.MocaTaggableElement.isIgnored(eaElement)) { return(results); } if (eaElement.Stereotype == SDMModelingMain.StoryNodeStereotype) { StoryNode storyNode = new StoryNode(repository, eaElement); if (!storyNode.loadTreeFromTaggedValue()) { results.Add("StoryNode is invalid and has to be updated manually"); } } else if (eaElement.Stereotype == SDMModelingMain.StatementNodeStereotype) { StatementNode stNode = new StatementNode(repository, eaElement); if (!stNode.loadTreeFromTaggedValue()) { results.Add("StatementNode is invalid and has to be updated manually"); } } else if (eaElement.Stereotype == SDMModelingMain.StopNodeStereotype) { StopNode stopNode = new StopNode(repository, eaElement); if (!stopNode.loadTreeFromTaggedValue()) { results.Add("StopNode is invalid and has to be updated manually"); } } return(results); }
private TreeNode CreateTreeNode(StoryNode storyNode) { TreeNode node = new TreeNode(storyNode.Name); this.BindData(node, storyNode); /* Context Menu Strip */ ContextMenuStrip NodeOptions = new ContextMenuStrip(); NodeOptions.Tag = node; ToolStripItem ExpandAll = NodeOptions.Items.Add("Expand All"); ExpandAll.Tag = node; ExpandAll.Click += new EventHandler(ExpandAll_Click); ToolStripItem CollapseAll = NodeOptions.Items.Add("Collapse All"); CollapseAll.Tag = node; CollapseAll.Click += new EventHandler(CollapseAll_Click); node.ContextMenuStrip = NodeOptions; /* Children */ if (!(storyNode is ReferenceNode)) { foreach (Option option in storyNode.Options) { node.Nodes.Add(CreateTreeNode(option.Node)); } } return(node); }
private void LoadPrivacy(StoryNode cut) { var task = AzureAD.GetPrivacyDataAsync(() => cut); task.ContinueWith(delegate { if (task.Result) { Setting.LastDisplayName = AzureAD.DisplayName; Setting.SaveFile(); _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ApplicationView.GetForCurrentView().Title = AzureAD.DisplayName ?? ""; }); } else { var title = ""; if (string.IsNullOrEmpty(Setting.LastDisplayName) == false) { title = $"[OFFLINE?] {(Setting.LastDisplayName ?? "")}"; } else { title = $"[OFFLINE?]"; } _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { ApplicationView.GetForCurrentView().Title = title; }); } cut.TaskResult = task.Result; }); }
/// <summary> /// Executes if the user clicks the OK button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void bttOK_Click(object sender, EventArgs e) { String activityType = comboTypes.ActivityNodeTypeFromComboBox(); if (activityType != "call") { StoryNode newStoryNode = new StoryNode(repository, activityTabsForm.ActivityNode.ActivityNodeEAElement); this.activityTabsForm.ActivityNode = newStoryNode; if (activityType == "foreach") { newStoryNode.ForEach = true; } else if (activityType == "activity") { newStoryNode.ForEach = false; } //creates a new this object if the radio button is selected if (chkThis.Checked) { createThisObject(); } } this.activityTabsForm.ActivityNode.Name = this.txtName.Text; }
public StoryAdvanced(string characterName, string playerId, string input, StoryNode newNode) { this.characterName = characterName; this.playerId = playerId; this.input = input; this.newNode = newNode; }
private void AddNodeRecursive(StoryNode sn) { if (sn.textId != 0) { sn.text = Read(sn.textId); } else { sn.text = string.Empty; } if (sn.roleId != 0) { sn.characterName = getrole(sn.roleId); } if (!nodeRootList.Contains(sn)) { nodeRootList.Add(sn); } if (sn.childNodeList == null || sn.childNodeList.Count == 0) { return; } for (int i = 0; i < sn.childNodeList.Count; i++) { AddNodeRecursive((StoryNode)sn.childNodeList[i]); } }
protected override void AddNode() { StoryNode nodeRoot = new StoryNode(); nodeRoot.WindowRect = new Rect(mousePosition.x, mousePosition.y, 300, 300); nodeRootList.Add(nodeRoot); }
protected NodeRoot Copy() { NodeRoot nr = new StoryNode(); nr.WindowRect = this.WindowRect; return(nr); }
private void SetAzureADMode(StoryNode cut) { Setting.LoadFile(); StartButton.IsEnabled = false; ErrorMessage.Text = ""; cut.TaskResult = true; }
public static void MoreNode() { NodeRoot nodeRoot = new StoryNode(); nodeRoot.WindowRect = new Rect(100, 100, 300, 300); nodeRootList.Add(nodeRoot); }
private void ResetControl(StoryNode cut) { LocalModeButton.IsEnabled = !string.IsNullOrEmpty(Setting.LastUserObjectID); LocalModeButton.IsVisible = true; StartButton.IsEnabled = true; StartButton.IsVisible = true; cut.TaskResult = true; }
private void IterateNode(StoryNode node) { node.isActive = false; if (node.nextNode) { IterateNode(node.nextNode); } }
private void TakeFreeTransitionsOf(StoryNode of) { foreach (StoryNode free in of.freeTransition) { this.AddFreeTransition(free); } of.FreeTransitionAddedToStory += AddFreeTransition; }
private void LoginSilent(StoryNode cut) { var task = AzureAD.LoginSilentAsync(() => cut); task.ContinueWith(delegate { cut.TaskResult = task.Result; }); }
/// <summary> /// 结束对话 /// </summary> public void FinishDialog() { m_IsDialog = false; UIManager.Singleton.IsShowDialog = false; m_CurrentStoryNode.IsPassed = true; m_CurrentStoryNode = null; m_CurrentSentence = 0; Debug.Log("结束对话"); }
private void NextPage(StoryNode cut) { ConfigUtil.Set("LoginUtc", DateTime.UtcNow.ToString()); Frame.Navigate(typeof(NoteListPage), null, new SlideNavigationTransitionInfo { Effect = SlideNavigationTransitionEffect.FromRight, }); cut.TaskResult = true; }
public NodeLink(StoryNode from, StoryNode to, Challenge challenge) { From = from; To = to; Challenge = challenge; }
public NodeLink(StoryNode from, StoryNode to) { From = from; To = to; }