public void PopulateWithTask(StoryTask task) { // Filling an empty pointer with task info. Used for network task and pointer creation. currentPoint = GENERAL.GetStoryPointByID(task.PointID); currentTask = task; task.Pointer = this; scope = task.scope; }
//int LastUpdateFrame = -1; //int UpdatesPerFrame = 0; //public int LastUpdatesPerFrame = 0; //public int MaxUpdatesPerFrame = 0; // ------------------------------------------------ #region CONSTRUCTOR // Tasks are create by calling spawntask on a pointer. public StoryTask(StoryPointer _fromPointer) : base("StoryTask", _fromPointer.scope) { // Create a task based on the current storypoint in the pointer. Pointer = _fromPointer; __point = _fromPointer.currentPoint; scope = _fromPointer.scope; setDefaults(); GENERAL.AddTask(this); }
public StoryTask(string _fromPointID, SCOPE _scope) { // Creating a task from a storypoint -> pointer to be created from this task. //pointID = storyPointID; __point = GENERAL.GetStoryPointByID(_fromPointID); //description = point.task[0]; scope = _scope; __pointer = null; setDefaults(); GENERAL.ALLTASKS.Add(this); }
public StoryTask(StoryPointer _fromPointer, SCOPE _scope) { // Create a task based on the current storypoint of the pointer. // Note that setting scope is explicit, but in effect the scope of the task is the same as the scope of the pointer. __pointer = _fromPointer; //description = pointer.currentPoint.task[0]; __point = __pointer.currentPoint; //pointID = pointer.currentPoint.ID; _fromPointer.currentTask = this; scope = _scope; setDefaults(); GENERAL.ALLTASKS.Add(this); }
public StoryPointer(string pointID, SCOPE setScope) { // Create a pointer from a given point. Task to be added later. currentPoint = GENERAL.GetStoryPointByID(pointID); currentTask = null; status = POINTERSTATUS.EVALUATE; scope = setScope; // GENERAL.AddPointer(this); GENERAL.ALLPOINTERS.Add(this); // updateMessageSend = new PointerUpdateBundled(); // we'll reuse. }
public Boolean ProgressToNextPoint() { Boolean r = false; if (currentPoint.getNextStoryPoint() == null) { Log("No next point"); } else { currentPoint = currentPoint.getNextStoryPoint(); r = true; } return(r); }
static void parse(string _text) { __idcount = 0; flattened = ""; fullText = _text; manuscript = new List <string>(); string[] lines = _text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { flattened += " " + lines[i]; if (!isComment(lines[i])) { manuscript.Add(lines[i]); } } if (manuscript.Count == 0) { Error("Script has no lines."); } // Verbose(flattened); GENERAL.storyPoints = new Dictionary <string, StoryPoint>(); Dictionary <string, StoryPoint> storyLines = new Dictionary <string, StoryPoint>(); StoryPoint point, previousPoint; string currentStoryline = "default"; previousPoint = null; int l = 0; string storyLine, storyLabel, storyPoint; while (l < manuscript.Count) { storyLine = isStoryLine(l); if (storyLine != null) { l++; storyPoint = isStoryPoint(l); if (storyPoint != null) { // Log.Message ("new storyline: " + storyLine); string[] task = getTask(manuscript[l]); // Log.Message ("task: " + task[0]); point = new StoryPoint(storyLine, storyLine, task); // point.name = storyLine; storyLines.Add(storyLine, point); GENERAL.storyPoints.Add(storyLine, point); currentStoryline = storyLine; previousPoint = point; } else { Warning("#storyline should be followed by storypoint"); } } storyLabel = isStoryLabel(l); if (storyLabel != null) { l++; storyPoint = isStoryPoint(l); if (storyPoint != null) { // Log.Message ("new storylabel: " + storyLabel); string[] task = getTask(manuscript[l]); // Log.Message ("task: " + task[0]); point = new StoryPoint(storyLabel, currentStoryline, task); // point.name = storyLabel; // if (point.taskType != TASKTYPE.BASIC) // storyPoint = getUniqueName (); // storyLabels.Add (storyLabel, point); StoryPoint exists; if (GENERAL.storyPoints.TryGetValue(storyLabel, out exists)) { Debug.LogError("Storylabel exists: " + storyLabel + ". Adding as a non functional duplicate."); storyLabel = storyLabel + "_DUPLICATE"; } GENERAL.storyPoints.Add(storyLabel, point); if (previousPoint != null) { previousPoint.setNextStoryPoint(point); } previousPoint = point; } else { Warning("@storylabel should be followed by storypoint"); } } storyPoint = isStoryPoint(l); if (storyLine == null && storyLabel == null && storyPoint != null) { string[] task = getTask(manuscript[l]); point = new StoryPoint(GetId(), currentStoryline, task); GENERAL.storyPoints.Add(point.ID, point); if (previousPoint != null) { previousPoint.setNextStoryPoint(point); } previousPoint = point; } l++; } // string[] keys = storyLines.Keys.Select(x => x.ToString()).ToArray(); // Enumerable storyLineKeys = storyLines.Keys; string[] keys = storyLines.Keys.ToArray(); for (int sl = 0; sl < keys.Count(); sl++) { string key = keys[sl]; // Debug.Log ("Storyline key: " + key); StoryPoint thePoint; if (!storyLines.TryGetValue(key, out thePoint)) { // Log.Message ("Can't find point"); } else { while (thePoint.getNextStoryPoint() != null) { // Debug.Log (thePoint.ID + " | " + string.Join (" ", thePoint.task)); thePoint = thePoint.getNextStoryPoint(); } // Debug.Log (thePoint.ID + " | " + string.Join (" ", thePoint.task)); } // storyPoint point = storyLines[keys[sl]]; // getNextStoryPointName } // string s = string.Join(";", storyLines.Select(x => x.Key + " : " + x.Value.task[0]+ " -> " + x.Value.getNextStoryPointName()).ToArray()); // // Debug.Log (s); // // s = string.Join(";", storyLabels.Select(x => x.Key + " : " + x.Value.task[0]+ " -> " + x.Value.getNextStoryPointName()).ToArray()); // // Debug.Log (s); // // s = string.Join(";", storyPoints.Select(x => x.Key + " : " + x.Value.task[0]+ " -> " + x.Value.getNextStoryPointName()).ToArray()); // // Debug.Log (s); }
public void SetStoryPointByID(string pointID) { currentPoint = GENERAL.GetStoryPointByID(pointID); status = POINTERSTATUS.EVALUATE; }
bool checkForCallBack(StoryPointer pointer) { // checks for callbacks on the pointer. returns true if the pointer itself was moved. if (pointer.currentTask == null) { return(false); } string callBackValue = pointer.currentTask.getCallBack(); if (callBackValue == "") { return(false); } pointer.currentTask.clearCallBack(); // clear value // a callback refers to a point. if it's a storyline, a new storypoint will launch on the given point. // if it's another point, it works as goto StoryPoint callBackPoint = GENERAL.GetStoryPointByID(callBackValue); if (callBackPoint == null) { return(false); } // check if this point is on our own storyline if (callBackPoint.StoryLine == pointer.currentPoint.StoryLine) { // point is on the storyline our pointer is on, so make our pointer move Log("Callback -> caller's own storyline: " + callBackPoint.StoryLine + " moved to point: " + callBackValue + " task: " + callBackPoint.Instructions[0]); pointer.currentPoint = callBackPoint; pointer.SetStatus(POINTERSTATUS.EVALUATE); return(true); } // check if a pointer exists on the callback point's storyline StoryPointer storyPointer = GENERAL.GetPointerForStoryline(callBackPoint.StoryLine); if (storyPointer == null) { // no pointer for the callback point's storyline exists, we'll create one Log("Callback -> new storyline: " + callBackPoint.StoryLine + " starting at point: " + callBackValue + " task: " + callBackPoint.Instructions[0]); StoryPointer newStoryPointer = new StoryPointer(); newStoryPointer.SetScope(pointer.scope); newStoryPointer.SetStoryPointByID(callBackValue); pointerStack.Add(newStoryPointer); newStoryPointer.persistantData = pointer.persistantData; // inherit data, note that data network distribution is via task only. AD will load value into task } else { // a pointer on the storyline exists, we'll move it Log("Callback -> existing storyline: " + callBackPoint.StoryLine + " moved to point: " + callBackValue + " task: " + callBackPoint.Instructions[0]); storyPointer.currentPoint = callBackPoint; storyPointer.SetStatus(POINTERSTATUS.EVALUATE); } return(false); }