public StoryLineViewModel(StoryLine story) { this.Id = story.Id; this.Source = story.Type; this.Description = story.Description; this.Language = story.Language; }
private string AddLinkSanti(StoryLine riga, string nomefile, string NormalTag, string LinkedTag) { var fileSanti = Directory.GetFiles(dirSanti).Where(x => x.Contains("santi_" + nomefile)).Select(x => x.Substring(x.LastIndexOf("\\") + 1)).ToList(); if (fileSanti.Count == 0) { return(dictEPUBDecode[NormalTag][2] + SetCaseRiga(riga.getText(), NormalTag) + dictEPUBDecode[NormalTag][3] + Environment.NewLine); } var santiText = riga.getText().Split(';').ToList(); string ret = dictEPUBDecode[NormalTag][2]; Dictionary <string, string> santi = BestFitDistance(santiText, fileSanti); foreach (var santo in santi) { if (santo.Value == null) { ret += SetCaseRiga(santo.Key.Trim(), NormalTag) + "; "; } else { ret += dictEPUBDecode[LinkedTag][2].Replace("!!!!", WebUtility.HtmlEncode(santo.Value)) + SetCaseRiga(santo.Key, LinkedTag) + dictEPUBDecode[LinkedTag][3] + "; "; } } ret = ret.Substring(0, ret.Length - 2) + dictEPUBDecode[NormalTag][3] + Environment.NewLine; return(ret); }
public void AddEntry(StoryLine sentence) { GameObject entryObject = GameObject.Instantiate(entryPrefab, transform); LogEntry entry = entryObject.GetComponent <LogEntry>(); entry.time_txt.text = System.DateTime.Now.ToShortTimeString(); entry.sentence_txt.text = sentence.MakeSentence(); }
public void HandleLoad() { ClearText(); ClearChoices(); GameManager.instance.mainScreenManager.ChangeState("Game"); GameManager.instance.gameScreen.ChangeState("Story"); StoryLine _line = new StoryLine(); _line.text = ((List <object>)StoryManager.story.state.jsonToken["outputStream"])[0].ToString().Substring(1); Debug.Log(_line.text); StartCoroutine(WriteLine(_line)); }
public override void Update(GameTime gameTime) { sys.LevelScriptComponents.TryGetFirstEnabled(out LevelScriptComponent level); if (talkBox == null) { Bind(); } if (level.Story == null) { return; } level.WaitTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (level.StoryProgress < 0) { //foreach (Entity entity in scene.GetGroup("talk")) entity.Enable(); level.StoryProgress = 0; level.WaitTimer = 0; StoryLine line = level.Story.Lines[0]; ShowNarrator(line.Message); ShowTalker1(line.Left, line.LeftMessage); ShowTalker2(line.Right, line.RightMessage); foreach (BulletComponent bullet in sys.BulletComponents.EnabledList) { if (bullet.Type > BulletType.Items) { bullet.Owner.Delete(); } } } else if (InputManager.JustPressed(GameCommand.Action1) && level.WaitTimer >= 0.5f) { level.StoryProgress++; if (level.StoryProgress >= level.Story.Lines.Count) { level.Story = null; level.WaitMode = LevelWaitMode.Start; ShowNarrator(null); ShowTalker1(null, null); ShowTalker2(null, null); InputManager.Reset(); } else { StoryLine line = level.Story.Lines[level.StoryProgress]; ShowNarrator(line.Message); ShowTalker1(line.Left, line.LeftMessage); ShowTalker2(line.Right, line.RightMessage); } } }
public void OnEventRaised(ActionLevel action) { StoryLine cStoryLine = storyBook.GetStoryLine(); /* * // is this a change of location? * ChangeLocation cLocation = cStoryLine as ChangeLocation; * if (cLocation != null) * locationBack.sprite = cLocation.location.background; */ if (cStoryLine != null) { Response.Invoke(cStoryLine); } }
List <StoryLine> GetLines() { List <StoryLine> lines = new List <StoryLine>(); //int _lines = 0; while (StoryManager.story.canContinue) { string line = StoryManager.story.Continue().Trim(); StoryLine _line = new StoryLine(); _line.text = HandleLine(line); _line.tags = StoryManager.story.currentTags.ToArray(); Debug.Log(StoryManager.story.currentChoices.Count); lines.Add(_line); } return(lines); }
public StoryLine GetNextLine() { if (currentNode == null || currentNode.dialog == null) { return(null); } StoryLine returnval = null; if (currentIndex < currentNode.dialog.Count) { returnval = currentNode.dialog[currentIndex]; currentIndex++; } return(returnval); }
private string ChangeTagForStyleIfBold(StoryLine riga, string NormalTag, string ChangedTag) { string ret = dictEPUBDecode[NormalTag][2]; foreach (CTextpart tp in riga.TextParts) { if (tp.font.Bold) { ret += dictEPUBDecode[ChangedTag][2] + tp.text + dictEPUBDecode[ChangedTag][3]; } else { ret += tp.text; } } return(ret += dictEPUBDecode[NormalTag][3] + Environment.NewLine); }
// Update is called once per frame void Update() { if (player.short_name.RuntimeValue == player.short_name.InitialValue) { return; } intervalCountDown -= Time.deltaTime; if (intervalCountDown < 0) { StoryLine storyLine = storyBook.GetStoryLine(false); if (storyLine != null) { AddEntry(storyLine); } intervalCountDown = interval; } }
public void loadChapter(StoryLine.Chapter chapter, bool reset = true) { if (reset) { GameState.clearVariableScope("Story.CurrentChapter"); GameState.currentGame["Story.CurrentChapter.Episode"] = 0; GameState.currentGame["Story.CurrentChapter.PlayedOpening"] = false; GameState.currentGame["Story.CurrentChapter.Level"] = 0; } if (!(bool)GameState.currentGame["Story.CurrentChapter.PlayedOpening"]) { CurrentEpisodeIndex = 0; currentSequence = GameState.getCurrentChapter().OpeningSequence; loadEpisode(GameState.getCurrentChapter().OpeningSequence.interactions[0]); } else { //already played the opening, so load the current location loadLevels(); } }
IEnumerator WriteLine(StoryLine line) { List <Choice> _choices = StoryManager.story.currentChoices; yield return(ManageTextBlock()); GameObject go = lastTextBlock; Text t = go.GetComponentInChildren <Text>(); RectTransform r = lastTextBlock.GetComponent <RectTransform>(); CanvasGroup g = lastTextBlock.GetComponent <CanvasGroup>(); lastTextBlock.GetComponent <FadeElement>().target = 1; //r.name = line.text.Trim().Substring(0,30); t.text = line.text.Trim() + "\n"; if (line.tags.Length > 0) { foreach (string tag in line.tags) { Debug.Log(tag); string[] tokens = tag.Split(':'); for (int i = 0; i < tokens.Length; i++) { tokens[i] = tokens[i].Trim(); } if (tokens.Length > 1) { switch (tokens[0]) { case "startChoice": if (!storeChoices) { break; } string[] derp = tokens[1].Split(','); for (int i = 0; i < derp.Length; i++) { derp[i] = derp[i].Trim(); } if (derp.Length >= 1) { foreach (string s in derp) { CheckStartChoice(s); } } else { CheckStartChoice(tokens[1]); } break; case "endChoice": if (!storeChoices) { break; } int choiceIndex = -1; int.TryParse(tokens[1], out choiceIndex); if (choiceIndex != -1) { for (int ii = 0; ii < choices.Count; ii++) { ChoiceObject _choice = choices[ii].GetComponent <ChoiceObject>(); if (_choice.choiceIndex == choiceIndex) { StartCoroutine(RemoveChoice(_choice.gameObject)); } } } break; default: break; } } } } Canvas.ForceUpdateCanvases(); StopCoroutine("ScrollTo"); //StartCoroutine(ScrollTo(go)); yield return(null); }
public IEnumerator Next(bool userPrompted = false) { //if (GameManager.instance.stopWriting) {yield break;} GameObject duh = EventSystem.current.currentSelectedGameObject; //Debug.Log(duh ? duh.name : "No object"); if (userPrompted && duh && duh.GetComponent <Button>()) { yield return(null); } else { if (storeChoices) { if (lines.Count == 0 && StoryManager.story.canContinue) { lines = GetLines(); pendingChoices = StoryManager.story.currentChoices; } else if (lines.Count == 0 && !StoryManager.story.canContinue) { //Debug.Log("DOOP"); foreach (Choice c in StoryManager.story.currentChoices) { string cleanText = CleanText(c.text); //Debug.Log(cleanText); if (silentOptions.Contains(cleanText)) { //Debug.Log(":)"); StartCoroutine(SelectChoice(c.index, true)); } } } //Debug.Log(lines.Count); if (lines.Count > 0) { if (userPrompted) { PlaySound(instance.clipOnNext); } StoryLine line = lines[0]; lines.RemoveAt(0); //Debug.Log(line.text); StartCoroutine(WriteLine(line)); if (lines.Count == 0) { StartCoroutine(LoadChoices(pendingChoices)); pendingChoices.Clear(); //LoadChoices(); } } else { } } else { if (StoryManager.story.canContinue) { if (userPrompted) { PlaySound(instance.clipOnNext); } StoryLine line = new StoryLine(); line.text = HandleLine(StoryManager.story.Continue()); line.tags = StoryManager.story.currentTags.ToArray(); //Debug.Log("Writing a line now"); if (GameManager.instance.latestDiceRoll > -1) { GameManager.instance.stopWriting = true; int roll = GameManager.instance.latestDiceRoll; int required = GameManager.instance.latestDiceRollRequirement; Debug.Log("There was a dice roll of " + roll + " against " + required + ", which is a " + ((roll >= required) ? "success" : "failure")); GameManager.instance.latestDiceRoll = -1; GameManager.instance.latestDiceRollRequirement = -1; GameManager.instance.PlaySound(GameManager.instance.soundDiceRoll, 1, Random.Range(0.9f, 1.1f)); yield return(new WaitForSeconds(1.1f)); GameManager.instance.stopWriting = false; } StartCoroutine(WriteLine(line)); FadeElement _fade = choiceAnchor.GetComponent <FadeElement>(); if (!StoryManager.story.canContinue) { //ClearChoices(StoryManager.story.currentChoices); StartCoroutine(LoadChoices(StoryManager.story.currentChoices)); } else { //ClearChoices(); if (_fade) { _fade.target = 0; } } if (canContinueIndicator) { FadeElement __fade = canContinueIndicator.GetComponent <FadeElement>(); if (__fade) { __fade.target = (CanContinue() ? 1 : 0); } else { canContinueIndicator.gameObject.SetActive(CanContinue()); } } } else { bool woo = false; foreach (Choice c in StoryManager.story.currentChoices) { if (c.text.Trim() == "NONE") { StartCoroutine(SelectChoice(c.index, true)); woo = true; yield return(null); } } if (!woo) { foreach (Choice c in StoryManager.story.currentChoices) { string cleanText = CleanText(c.text); //Debug.Log(cleanText); if (silentOptions.Contains(cleanText)) { StartCoroutine(SelectChoice(c.index, true)); } } } } } } yield return(null); }
// Use this for initialization void Awake() { storyLine = this; }
public static bool CreateNewProject(string campaignName, string parentDirectory, ContentLoadSource defaultSaveLocation, DateTime ingameStartTime, out Campaign outCampaign) { // Create the campaign directories and folder structure: if (!CreateProjectDirectories(campaignName, parentDirectory, out string projectRootDir)) { outCampaign = null; return(false); } // Create a project object, for later serialization to file: Project project = new Project() { name = campaignName, rootPath = projectRootDir, }; // Set the new project as active, thus updating content root directories to the new project's: if (!ProjectManager.LoadProject(project)) { Debug.LogError("[ProjectCreator] Error! Failed to load and activate newly created project!"); outCampaign = null; return(false); } // Create basic contents for the project and its main campaign: string storylineName = $"{campaignName} Timeline"; StoryEvent startEvent = new StoryEvent() { name = $"{campaignName} beginning", description = "The player characters first meet in the taproom of their hostel, attracted by a scream of terror. " + "Seconds later, the woman at the origin of the scream collapses; blood running from her eyes, she dies on the spot. " + "On her hand, a strange marking has appeared, strangely similar to the symbol Baal, the god of death.", startTime = ingameStartTime, storyline = new ContentAccessor(storylineName), }; ContentAccessor startEventCA = new ContentAccessor(startEvent.name, startEvent); ContentLoader.SaveContent(startEventCA, out ContentRefAndHandle startEventRaH, defaultSaveLocation); StoryLine storyline = new StoryLine() { name = storylineName, description = $"This is the main storyline of the '{campaignName}' campaign, telling the tale of a group " + "of unlikely companions banding together to vanquish the great evil that is threatening their home.", startTime = ingameStartTime, endTime = ingameStartTime + new TimeSpan(1, 0, 0, 0), events = new List <ContentAccessor>(new ContentAccessor[] { startEventCA }), }; ContentAccessor storylineCA = new ContentAccessor(storylineName, storyline); ContentLoader.SaveContent(storylineCA, out ContentRefAndHandle storylineRaH, defaultSaveLocation); Campaign campaign = new Campaign() { name = campaignName, description = "A grand adventure involving great heroes, vile foes, and an excessive number of murder hobos.", mainStoryline = new ContentAccessor(storyline.name, storyline), }; ContentAccessor campaignCA = new ContentAccessor(campaignName, campaign); ContentLoader.SaveContent(campaignCA, out ContentRefAndHandle campaignRaH, defaultSaveLocation); WorldMap worldMap = new WorldMap() { name = $"{campaignName} World Map", description = "The home world of our great heroes, and the place they persistently haunt in quest for murder and loot.", }; ContentAccessor worldMapCA = new ContentAccessor(worldMap.name, worldMap); ContentLoader.SaveContent(worldMapCA, out ContentRefAndHandle worldMapRaH, defaultSaveLocation); // Link the above contents to the project: project.mainCampaign = campaignCA; project.mainWorldMap = worldMapCA; ContentAccessor projectCA = new ContentAccessor(project.name, project); // Save project to file: ContentLoader.SaveContent(projectCA, out ContentRefAndHandle projectRaH, ContentLoadSource.File); // Output the newly created and populated campaign object and return success: outCampaign = campaign; return(true); }
public void loadEpisode(StoryLine.Episode episode) { this.state = states.Sequence; //TODO load resources!!! //get string this.renderString = ctext.processString(episode.DialogText); currentEpisode = episode; this.Invalidate(); }
public void DisplayNextLine() { // call when in conversation convo = currentConversation.GetComponent <Conversation>(); //consequences = convo.GetConsequences(); currentLine = convo.GetNextLine(); if (currentLine == null) { // is this an error? advanceConversation = true; return; } if (currentLine.conditions != null) { GameController game = FindObjectOfType <GameController> (); foreach (StatCondition condition in currentLine.conditions) { if (!condition.Test(game.gameProgress)) { advanceConversation = true; return; } } } switch (currentLine.GetType()) { case StoryLine.ScriptType.Narrator: { NarratorSpeaks(); break; } case StoryLine.ScriptType.LeftCharacter: { LeftCharacterSpeaks(); break; } case StoryLine.ScriptType.RightCharacter: { RightCharacterSpeaks(); break; } case StoryLine.ScriptType.Choice: { DisplayChoices(); return; } case StoryLine.ScriptType.Image: { ChangeImage(); break; } case StoryLine.ScriptType.HideImage: { HideImage(); break; } case StoryLine.ScriptType.Music: { FindObjectOfType <MusicManager>().ChangeMusic(currentLine.music); advanceConversation = true; break; } case StoryLine.ScriptType.Sound: { FindObjectOfType <SoundManager>().PlaySound(currentLine.sound); advanceConversation = true; break; } case StoryLine.ScriptType.Next: { NextConversation(currentLine.next); break; } case StoryLine.ScriptType.None: { Debug.Log("empty node"); advanceConversation = true; break; } } DisplayPrompt(); }